Question

I have a windows service written in C#. It dynamically generates C# code and compiles them to assemblies as abc.dll, xyz.dll etc. These assemblies are later loaded for execution. When compiling, I pass /keyfile: mykeyfile.snk" as one of the compiler options to System.CodeDom.Compiler.CompilerParameters class. Now the problem: Some of these assemblies fail to load because strong name validation fails.

I got the generated assemblies from the test system and when I check them with sn,exe, I see that about 1 in 6 assembly is delay or test signed. Running sn.exe -v xyz.dll gives me xyz.dll is a delay-signed or test-signed assembly. Obviously it will fail to load.

Why some assemblies aren’t properly signed?

Était-ce utile?

La solution

I was able to resolve it, sharing it for everyone's benefit. The cause of the issue is that compilation is a 2 step process. The compiler first produces the dll, then attempts to sign it. See http://msdn.microsoft.com/en-us/library/yh7ks237(v=vs.90).aspx

The dll will still be there and one won't notice that its test signed until one attempts to load it. I had 1 sign file, xyz.snk which was locked in another thread.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top