FindPrivateKey under Windows 7 64 bit doesn't work

1.1k Views Asked by At

I've downloaded .net sample FindPrivateKey, compiled for framework 4.0, tried for different platforms (32bit, 64bit, Any CPU) but it didn't work. Always the same error: the ordinal 345 could not be located in the dynamic link library comctl32.dll. I use Windows 7 Enterprise, 64 bit version. This method call fails: matches = X509Certificate2UI.SelectFromCollection(store.Certificates, "Select certificate", "Select the certificate to find the location of the associated private key file:", X509SelectionFlag.SingleSelection); What could be problem here?

Aleksandar

1

There are 1 best solutions below

1
On

This morning I’ve encountered the same problem (ordinal 345 could not be located ...)… I’ve tried the application in 3 different PC with Win7 64bit; but only in one of these the exception throws. I found that the problem was in the use of the comctl32.dll library (which was different from mine).

You can execute this piece of code in order to check which version of the library you are using:

foreach (ProcessModule module in System.Diagnostics.Process.GetCurrentProcess().Modules)
            if (module.ModuleName.ToLower() == "comctl32.dll")
                MessageBox.Show(module.FileVersionInfo.ToString());

Then add a manifest and force the application to use a specific library version: [Project] -> Add new item -> Application manifest And edit it adding the following dependency part.

I hope this works for you...

    <?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>

… 
… 
…

  <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>
</asmv1:assembly>