Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with PubSub when referencing BouncyCastle 1.8.1 #453

Closed
jose3m opened this issue Oct 14, 2016 · 7 comments
Closed

Problem with PubSub when referencing BouncyCastle 1.8.1 #453

jose3m opened this issue Oct 14, 2016 · 7 comments
Assignees

Comments

@jose3m
Copy link

jose3m commented Oct 14, 2016

Hi.

I am using the Google.Pubsub.V1 1.0.0-beta02 in an app and all works perfect, but now I am integrating it in another app and suddently it fails (just launching the app).

What is the difference between both apps? The difference is that in the new app it is used another package that forces to reference the BouncyCastle package with version 1.8.1 intead of the 1.7 (used in the first app and required for the Pubsub.V1 internal references).

The thrown error is:

An exception of type 'System.InvalidOperationException' occurred in Google.Api.Gax.dll but was not handled in user code

Additional information: Error reading credential file from location C:\x\x\xx.json: No se puede cargar el archivo o ensamblado 'BouncyCastle.Crypto, Version=1.7.4137.9688, Culture=neutral, PublicKeyToken=a4292a325f69b123' ni una de sus dependencias. La definición del manifiesto del ensamblado no coincide con la referencia al ensamblado. (Excepción de HRESULT: 0x80131040)

Please check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS

I can't use the version 1.7 of BouncyCastle because the other package does not allow it, so I have to use the 1.8.1.
Do you know how to solve this problem? Is there any solution?

Thank you.
Jose

@jskeet
Copy link
Collaborator

jskeet commented Oct 14, 2016

@chrisdunelm You know more about the crypto side than I do. Any thoughts? It sounds like an assembly binding redirect should do the right thing here...

@jose3m
Copy link
Author

jose3m commented Oct 17, 2016

Hi.
Any news about this?

I have tried an assembly binding redirect and it doesn't work, the error is still thrown.

Thanks.

@chrisdunelm
Copy link
Contributor

@jose3m I've reproduced this in a simple test-case. I'm now investigating why this occurs, and how to fix it.

@chrisdunelm
Copy link
Contributor

@jose3m Hmmm, actually I'm getting a different error message, but it may be related.

I've created a library that depends on BouncyCastle 1.8.1
And an application that depends on the above library and on Google.Pubsub.V1 1.0.0-beta02
When a call is made into the library, where the callee calls into BouncyCastle, I get a FileLoadException

Additional information: Could not load file or assembly 'BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Looking at the BouncyCastle.Crypto.dll file in the bin directory, it is v1.7, where I would have expected the 1.8.1 dll to be present.

However, in your case it's saying it can't load v1.7, so presumably v1.8.1 is present.

@jose3m
Copy link
Author

jose3m commented Oct 18, 2016

@chrisdunelm
You are wright. In my bin directory it is present v1.8.1 and it is looking for v1.7.

The only way to "solve" it has been to remove the reference to BouncyCastle v1.8.1 and change its use by an alternative code. I didn't want to do it this way but I am not able to find a solution.

@chrisdunelm
Copy link
Contributor

I've reproduced this with no Google dependencies at all.
Simply create two libraries, one depending on BouncyCastle 1.7.0, the other depending on BouncyCastle 1.8.1, each with a method that calls into BouncyCastle.
Then create a application that depends on both libraries, and call each function, and it crashes with exactly the same error.
Interestingly, trying this with a different nuget package (I used Json.NET) does not show this problem. The redirect appears to happen correctly, without anything required in App.config

I suspect this may be because the public key token changes between BouncyCastle version 1.7.0 and 1.8.1
Whereas the public key token is identical for all versions of Json.NET

If this is the cause, then I'm not sure there's anything we can do :(

@jose3m
Copy link
Author

jose3m commented Oct 21, 2016

I tried to force the asembly reference binding in App.config and it didn't work.

I agre with you that the main problem is in the different public key token associated to the different versions of the BouncyCastle, so the only solution for me at this moment was to have all references only to one version, the used in Google packages.

Thank you very much for your help.

@jose3m jose3m closed this as completed Oct 21, 2016
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
@jskeet jskeet removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants