Today I need to do some Open PGP encryption/decryption in My web application so I using nuget to add BouncyCastle to my solution, and add some sample code from stackoverflow (SOF) to test encrypt a file.
And the error appear:
Error CS0433 The type 'PgpPublicKey' exists in both 'BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942' and 'iTextV***, Version=5.6.140.0, Culture=neutral, PublicKeyToken=null'
So How to fix that?
After searching in SOF, I found some solution, but cannot fix it yet:
Change all dll to reference the same version 1.9.0.0 of BouncyCastle.Crypto. But unluckily, we use 2 third-party dll iTextV***.dll and itext.v***.dll of same company, but we don't have code for them to change reference and rebuild dll.
One post in SOF told about asembly "Aliases", but we use Web application and have no project reference dll like that to change alias. I tried adding this in web.config but not working, too:
<dependentAssembly> <assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral"/> <bindingRedirect newVersion="1.9.0.0"/>
</ dependentAssembly>