Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BouncyCastle in conflict with iTextSharp

I have a c# program that uses BouncyCastle. If I insert a reference to iTextSharp, the compiler generates many errors of classes already existing in both references. I have specified all the namespaces but it does not change anything. Example:

 Org.BouncyCastle.X509.X509Certificate certCopy = DotNetUtilities.FromX509Certificate(oCertificato);

How can I use BouncyCastle and iTextSharp together?

like image 645
Franco De Giorgi Avatar asked Jan 04 '19 18:01

Franco De Giorgi


1 Answers

Just like @franco-de-giorgi said. Add an Alias to the library.

I'm just writing a full answer because I had to learn what is an Alias and how to add and Alias

Go to your references and go to properties on BouncyCastle, then change global to your personal Alias:

enter image description here

Then in your class use an external alias to your references like this (instead of using)

//using Org.BouncyCastle.Crypto.Parameters;
extern alias Merged;

In your classes add your alias

new Merged::Org.BouncyCastle.OpenSsl.PemReader
like image 130
Augusto Avatar answered Oct 01 '22 05:10

Augusto