Question

One of our partners provided us with an assembly we need to access from our application. Unfortunately, this is not strong-name so we can't install it to the GAC. And we can't place it in the same place as our executable.

Is there a solution for this?

EDIT: This will be a temporary solution only for testing, when they go RC, we will have a strong-named assembly.

Was it helpful?

Solution

You have a few options at that point.

The first is to place the assembly in a directory that has the name of the assembly (without the extension) which is a subdirectory of the application directory.

The second is to specify the sub directory you want the CLR to probe for references in the app.config file using the probing element.

Finally, you can load the assembly dynamically using the various Load methods on the Assembly class but I would say that's a very bad idea in this case, given that you have the assembly, and you have concrete types that you want to use in it. Late time assembly loading like this is typically used when you want to subsitute the implementation of certain abstractions, which doesn't seem to be the case here.

OTHER TIPS

Workaround using decompilation & signing (using Developer Command prompt for Visual studio):

ildasm.exe /all /typelist /out=DataSystem.il DataSystem.dll
ilasm.exe /dll /optimize /key=DataSystem.snk DataSystem.il

DataSystem.snk can be generated as a file using Visual Studio IDE http://www.bloggedbychris.com/2011/09/29/signing-a-net-assembly-in-visual-studio/

then you should be able to run

gacutil.exe -i DataSystem.dll

Yet another solution is to add the following to the machine.config file:

<runtime>
  <developmentMode developerInstallation="true"/>  
</runtime>

And add DEVPATH = path to the system environment variables.

The best and most straight-forward solution to sign and register an assembly I found was here: http://codeingaddiction.blogspot.com/2011/06/how-to-add-strong-name-to-existing-dll_16.html

For me to get this to work easily I CD'd to some directory like C:\temp - this seemed to work a lot better to me, probably because of file permissions being more accessible in somewhere like that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top