Can not load module on some machines

398 views
Skip to first unread message

bru...@resultants.eu

unread,
Jul 6, 2015, 3:51:20 AM7/6/15
to eid-middl...@googlegroups.com

Hello,

I have a problem with the latest version (PKcs11.dll & beidpkcs11.dll).
I got version 4.0.4 to work fine, but when some newer cards were not working anymore
I had to upgrade to 4.0.7.
On some of my development machines it actually works but on other machines
I keep getting this error when i try to load the module:

"Could not load module. Module name:beidpkcs11.dll"

The code:


private Module m = null;
private String mFileName;

public bool CheckSlot()
        {
            try
            {
                if (m == null)
                {
                    m = Module.GetInstance(mFileName);
                }
                Slot[] slotlist = m.GetSlotList(true);
                if (slotlist.Length > 0)
                {
                    Slot slot = slotlist[0];
                    SlotInfo info = slot.SlotInfo;
                    return info.IsTokenPresent;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                Log.Info("Could not load eID reader software. " + e.Message + ": detail: " + e.StackTrace);
                return false;
            }
        }

Any help would be greatly appreciated. Thank you.

WKR Bruno

Frederik Vernelen

unread,
Jul 6, 2015, 4:21:08 AM7/6/15
to eID Middleware Dev
Hello Bruno,

Could it be that by accident the 32bit msi got installed on 64bit machines?

Can you verify that the beidpkcs11.dll  is present in syswow64 (for 32 bit app), or system32 (for 64bit app) on the 64bit machines where it doesn't work?
(on 32bit machines it should be in system32)

The fact that it works on development machines, but not on others could be explained by missing VS2012 dependancy modules (though they should be installed by the quick installer, or msi installers).
(the 4.0.7 version is build with VS2012, whereas the 4.0.4 build might still have been build with VS2005)

Wkr,
 Frederik



--
You received this message because you are subscribed to the Google Groups "eID Middleware Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eid-middleware-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bru...@resultants.eu

unread,
Jul 9, 2015, 4:04:37 AM7/9/15
to eid-middl...@googlegroups.com
Hello Frederik,

All my machines are 64bit, the beidpkcs11.dll is present in the system32.
In the previous version there was no need to install the software because
I just build the beidpkcs.dll as content in the application and copy it to output.

Now I installed the software on the test machine and if I try to read my card
using the software it works fine, but my application keeps giving the same error:


Could not load module. Module name:beidpkcs11.dll

When I remove the beidpkcs11.dll from the application and try to load it from system32:

mFileName = "C:\\Windows\\System32\beidpkcs11.dll";

It also gives the error on my development machine:
Could not load module. Module name:C:\Windows\System32\beidpkcs11.dll

Is there anything else I can try?

WKR Bruno

Frederik Vernelen

unread,
Jul 9, 2015, 5:12:02 AM7/9/15
to eID Middleware Dev
Hello Bruno,

Might there be a typo in your code?

mFileName = "C:\\Windows\\System32\beidpkcs11.dll"

before beidpkcs11.dll, I see a single backslash

Wkr,
 Frederik

--

bru...@resultants.eu

unread,
Jul 9, 2015, 7:21:14 AM7/9/15
to eid-middl...@googlegroups.com
Hello

Sorry, it was a typo in my message, in my code it is
mFileName = "C:\\Windows\\System32\\beidpkcs11.dll";

Frederik Vernelen

unread,
Jul 9, 2015, 8:11:05 AM7/9/15
to eID Middleware Dev
hehe, nps :)

Does it work when you attach the new "C:\\Windows\\System32\beidpkcs11.dll" to your application the same way it used to work?
(to check whether the use is with the file, or the file path)).




--

bru...@resultants.eu

unread,
Jul 9, 2015, 8:34:26 AM7/9/15
to eid-middl...@googlegroups.com
No always that same error.
It only works on my development machine when I attach the dll to the application.
On the other machines it always fails, I even tried to find missing dependencies
in the dll and downloaded MSVCR120.dll and MSVCP120.dll to place it in the
system32 map of the test machine but still no luck...

bru...@resultants.eu

unread,
Jul 16, 2015, 3:43:17 AM7/16/15
to eid-middl...@googlegroups.com
Could you give me a list of VS2012 dependency modules needed by the EID software?
Maybe I can get it to work if I add them manually?
Thank you

Frederik Vernelen

unread,
Jul 16, 2015, 3:53:33 AM7/16/15
to eID Middleware Dev
Hello Bruno,

You can find the VS2012 redistributable package here:
https://www.microsoft.com/en-us/download/details.aspx?id=30679

bru...@resultants.eu

unread,
Jul 16, 2015, 9:14:51 AM7/16/15
to eid-middl...@googlegroups.com
Hey Frederik

Is er een manier om rechtstreeks telefonisch contact met u op te nemen?
Ik krijg het probleem maar niet opgelost en de klanten beginnen ongeduldig
te worden. De versie 4.0.4 werkte prima tot de nieuwe kaarten uit kwamen
maar met deze versie 4.0.7 blijft het maar fout lopen en ik snap niet waar
het probleem ligt...

MVG

Bruno

bru...@resultants.eu

unread,
Jul 23, 2015, 6:36:36 AM7/23/15
to eID Middleware Dev, bru...@resultants.eu

Hey Frederik

Mijn problemen met de middleware zijn nog steeds niet opgelost en
het lijkt er op dat je telefonisch contact niet ziet zitten?
Zijn er manieren om van de identiteitskaart gegevens te lezen
zonder gebruik te maken van jullie middleware?
Als je voorbeeldcode hebt van een applicatie die dit zonder de middleware
zou ik je zeer dankbaar zijn.

MVG Bruno

Frederik Vernelen

unread,
Jul 23, 2015, 7:10:24 AM7/23/15
to eID Middleware Dev
Dag Bruno,

Excuses, mijn vorige mail blijkt naar u persoonlijk verstuurd ipv naar de groep.
Heb je dit al eens kunnen bekijken?


Als je de beidpkcs.dll v4.0.4 die je voorheen gebouwd hebt (als deel van je oplossing) in System32 van je testmachine plaatst, kan hij dan de pkcs11 module laden?
(indien niet, dan ligt het aan het path)

Indien dit lukt: die beidpkcs.dll v4.0.4, die je zelf bouwde, met welke architectuur was dat? (32bit, 64bit, any CPU)?
Onze dll's zijn single architecture (die van 64bit staat in system32, en die van 32 bit en folder syswow64 )
Moest je applicatie gebouwd zijn als 32bit app, kan je dan linken met de beidpkcs.dll in syswow64?

Moest je applicatie gebouwd zijn onder anyCPU, kan je dan nagaan onder welke runtime je draait, en afhankelijk daarvan de 32 of 64 bit beidpkcs.dll laden?


Mvg,
 Frederik

Wouter Verhelst

unread,
Jul 23, 2015, 7:14:43 AM7/23/15
to eid-middl...@googlegroups.com
On 23-07-15 12:36, bru...@resultants.eu wrote:
>
> Hey Frederik
>
> Mijn problemen met de middleware zijn nog steeds niet opgelost en
> het lijkt er op dat je telefonisch contact niet ziet zitten?
> Zijn er manieren om van de identiteitskaart gegevens te lezen
> zonder gebruik te maken van jullie middleware?

In theorie kan dat als je zelf PC/SC gaat spreken tegen de kaart (de
specificaties zijn publiek). In de praktijk zou ik dat niet aanraden,
wegens "overdreven complex". Wat je aan het proberen bent (gebruik maken
van de middleware), zou in theorie "gewoon" moeten werken.

Je zegt "het werkt niet". Heb je een wat gedetailleerdere foutmelding?

> Als je voorbeeldcode hebt van een applicatie die dit zonder de middleware
> zou ik je zeer dankbaar zijn.

--
Wouter Verhelst

Bruno Dovogja

unread,
Jul 29, 2015, 11:09:14 AM7/29/15
to eID Middleware Dev, wouter....@fedict.be

Dag Frederik en Wouter

Bedankt voor jullie hulp en reacties.
Het probleem van de module die niet ingeladen wordt
is opgelost. Door op de testcomputers Visual C++ Redistributable Packages for Visual Studio 2013 (x86) te installeren
werkt het nu.
Helaas krijg ik nu op de productiecomputer een andere fout.

De code die wordt aangeroepen is:

private Module m = null;
        private String mFileName;
        private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(Reader));

        public Reader()
        {
            //mFileName = "C:\\Subversion\\CMRKiosks\\CMRKiosks\\beidpkcs11.dll";
            mFileName = "beidpkcs11.dll";

        }

        public bool CheckSlot()
        {
            try
            {
                if (m == null)
                {
                    m = Module.GetInstance(mFileName);
                }
                Slot[] slotlist = m.GetSlotList(true);
                if (slotlist.Length > 0)
                {
                    Slot slot = slotlist[0];
                    SlotInfo info = slot.SlotInfo;
                    return info.IsTokenPresent;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                Log.Info("Could not load eID reader software. " + e.Message + ": detail: " + e.StackTrace);
                return false;
            }
        }

Maar ik krijg dan de volgende fout in mijn logs:
INFO  EIDService.Reader [(null)] - Could not load eID reader software. DEVICE_ERROR: detail:    at Net.Sf.Pkcs11.Wrapper.Pkcs11Module.checkCKR(CKR retVal)
   at Net.Sf.Pkcs11.Wrapper.Pkcs11Module.GetSlotList(Boolean tokenPresent)
   at Net.Sf.Pkcs11.Module.GetSlotList(Boolean onlyTokenPresent)
   at EIDService.Reader.CheckSlot()

Dus het loopt mis wanneer ik de slotlist opvraag, zou dit kunnen liggen aan de hardware van de reader? Ik kan dit zelf niet gemakkelijk nakijken omdat
deze machine bij de klant staat, dus ik heb alleen mijn logs en besturing op afstand om dit na te kijken. Mijn vraag is dus eigenlijk wat die checkCKR(CKR retVal) precies doet?
In elk geval bedankt voor de support!

MVG Bruno

Verhelst Wouter (Consultant)

unread,
Jul 29, 2015, 12:12:36 PM7/29/15
to Bruno Dovogja, eID Middleware Dev
Dit is hoogstwaarschijnlijk een hardware-issue.

CK_RV is een datatype voor "CryptoKey Return Values". Dat zijn allemaal constanten met namen in de stijl van "CKR_OK" of "CKR_FUNCTION_FAILED" of "CKR_DEVICE_ERROR", ofzo.

checkCKR controleert gewoon die return value, en gooit een .net exception (wat in C niet gekend is) indien het niet CKR_OK is.

De fout die je krijgt is CKR_DEVICE_ERROR. Volgens de documentatie[1] is dat:

"CKR_DEVICE_ERROR: Some problem has occurred with the token and/or slot."

Zaken die je kan proberen:

- Kaartlezer in- en uittrekken
- Kaart uittrekken en opnieuw insteken
- Andere kaartlezer gebruiken

[1] https://github.com/Fedict/eid-mw/blob/master/doc/sdk/documentation/pkcs-11v2-11r1.pdf

--
Wouter Verhelst
________________________________________
Van: Bruno Dovogja [bru...@resultants.eu]
Verzonden: woensdag 29 juli 2015 17:09
Aan: eID Middleware Dev
CC: Verhelst Wouter (Consultant)
Onderwerp: Re: [eid-mw-dev] Can not load module on some machines

Lem.C

unread,
Jul 6, 2020, 7:22:05 AM7/6/20
to eID Middleware Dev
Hi There,

I'm just wandering on where did you get those files PKcs11.dll and beidpkcs11.dll
I'm maintaining an old application uses card readers, however I don't have any idea
where to get this PKcs11.dll.

The problem that I have encountered is that I have to install a legacy application
on a 64bit pc and how it gave an error that sad the PKcs11.dll is not applicable
with 64bit pc. 

Regards,
Lem.C

Frederik Vernelen

unread,
Jul 6, 2020, 7:22:55 AM7/6/20
to eID Middleware Dev
Hello,

The beidpkcs11.dll is part of the eID middleware (software), and can be downloaded from https://eid.belgium.be/en .
It will be installed in the windows system folders (on 64-bit systems: Windows/system32 for 64 bit and Windows/syswow64 for 32-bit )

--
You received this message because you are subscribed to the Google Groups "eID Middleware Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eid-middleware-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages