Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strongly naming 3rd party 2.0 .dll with VS 2010 Ilasm.exe

So, I have a 3rd party .dll written in C# 2.0 that needs to be strongly typed and I do not have access to the source code. I found several articles on how to disassembly the .dll and re-assembly it with a strongly named key file.

Problem I am having is that VS2010 recompiles it as a .NET 4.0 .dll instead of a 2.0 .dll (the version our application is currently in). I can't include the "new" dll in my project because it gives me a runtime error of: "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." If I don't sign the dll, I get the "assembly is not strongly typed." error.

Is there a way to recompile this .dll in the 2.0 framework using VS2010 ilasm.exe?

like image 390
Sean Avatar asked May 07 '11 01:05

Sean


1 Answers

You are probably using the Visual Studio 2010 Command Prompt. It will setup the environment to run C:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm.exe when you type "ilasm.exe". Wrong version, you want v2.0.50727\ilasm.exe. Type the full name. Or copy and edit vc\bin\vsvarsall.bat

like image 133
Hans Passant Avatar answered Oct 29 '22 19:10

Hans Passant