2

I want to develop Application which can read Token and perform PDF Signing. FYI i successfully signed pdf document, but after im update the Pkcs11Interop version from 3.3.0.0 to 4.1.1.0 Then the signed turn into failed. I've tried to enable AutoGenerateBindingRedirects but i still cant sign the PDF

Expecting the PDF is successfully signed, but i get this error

System.IO.FileLoadException: Could not load file or assembly 'Pkcs11Interop, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Screenshot error

what i understand is, this application was trying to call the Pkcs11interop version=3.3.0.0

However its already mention in the Nuget Repo about its dependencies. So it's suppose to be okay right?

Pkcs11Interop.PDF

/* App.config */

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
    <dependentAssembly>
        <assemblyIdentity name="Pkcs11Interop" publicKeyToken="c10e9c2d8c006d2a"/>
        <bindingRedirect oldVersion="3.3.0.0" newVersion="4.1.1.0"/>
    </dependentAssembly>
</configuration>

what i must do to solve this dependencies error?

dejulz Zul
  • 53
  • 8
  • have you try to recompile? show us you `App.config` file? Is there an image of text? – vasily.sib May 31 '19 at 03:30
  • i try to clean and build but that error still show up. Already add the App.config on my post Sir @vasily.sib – dejulz Zul May 31 '19 at 03:44
  • shouldn't it be ``? (extra `.0` in version numbers) – vasily.sib May 31 '19 at 03:50
  • It didnt work Sir :(( – dejulz Zul May 31 '19 at 06:58
  • Close Visual Studio and then remove all references to that assembly from the .csproj file, using a text editor (not Visual Studio). Delete the bin and obj folders from the project folder, and then open VS and re-add the reference to the DLL. – Reinstate Monica Cellio May 31 '19 at 08:43
  • There is a mismatch on the publicKeyToken, it looks for one that isn't strong-named but the bindingRedirect can only work for a strong-named one. You can't force it to go from one without to one that has one. If the one you deploy must have a strong name then all you can do is update the project reference. – Hans Passant May 31 '19 at 10:37

1 Answers1

0

I see two problems in what you're trying to do:

  1. Pkcs11Interop 3.3.0 is not strongly signed but all newer versions are. So you would need to redirect from unsigned to signed assembly which AFAIK is not possible.
  2. Pkcs11Interop 4.x contains API changes that are not compatible with 3.x versions so even if you somehow made redirection work Pkcs11Interop.PDF would not be able to use newer version of Pkcs11Interop.

I might update Pkcs11Interop.PDF for newer versions of Pkcs11Interop but I have no ETA for that yet => currently it's best to just stick to Pkcs11Interop 3.3.0.

jariq
  • 11,681
  • 3
  • 33
  • 52
  • Hi jariq, thanks for your answer! however i got error on code at AppType and SlotsType when i used 3.3.0 – dejulz Zul Jun 09 '19 at 15:03
  • @dejulzZul sure. There are API breaking changes between 3.x and 4.x versions and `AppType` and `SlotsType` enums are just two of them. You need to adjust your code. – jariq Jun 09 '19 at 15:21