Microsoft (R) Visual C# Interactive Compiler version 2.9.0.63208
Windows 7 64 bit
NBitcoin 4.1.1.68
====
System.Security.Cryptography.Algorithms
version 4.3.0.0 has an SHA256Managed
class that I want to use in C# Interactive (csi.exe
).
I added that assembly to the GAC with the gacutil -i [path_to_dll]
command. I launched csi
with an /r:[path_to_dll_dir]/System.Security.Cryptography.Algorithms.dll
command line option.
On top of that, after csi
started, I also did an #r "[path_to_dll]"
reference. Belt and suspenders type stuff. I know. But I guess I was hoping the overkill would force it to do the right thing.
My application uses a class from a third-party library. The following code was copied pretty much verbatim from the third-party method my app calls. If I run the following code in csi
, it works fine...
using System;
using System.Security.Cryptography;
byte[] b = Guid.NewGuid().ToByteArray();
var sha = new SHA256Managed();
byte[] c = sha.ComputeHash(b, 0, 15);
Now, here's the thing. That third-party class defines a method that calls SHA256Managed.ComputeHash(byte[], int, int)
exactly like the code above.
For the sake of discussion, let's refer to the third party class and method as Foo.m()
.
The problem is, when I call the third party Foo.m()
from csi
, csi
balks with...
Could not load type 'System.Security.Cryptography.SHA256Managed' from assembly 'System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
+ Third.Party.Foo.m(byte[], int, int)
Remember I explicitly added the version 4.3.0.0 crypto algorithm assembly into the GAC. Plus I explictly referenced the dll with both #r
and /r:
. So what gives?
I can see in the FusLogVw
binding logs that csi
is loading the version 4.0.0.0 assembly; in spite of me explicitly insisting on using version 4.3.0.0. System.Security.Cryptography.Algorithms
version 4.0.0.0 does not have an SHA256Managed
class.
Please help me figure out how to make csi
use the assembly I tell it to use? Bear in mind, that it uses the right version for code written directly in csi
. So why is it not using the correct assembly version for the exact same code in a third-party library?