How to register a non-strong-name assembly to be loaded as if it were in the GAC?

前端 未结 4 1155
无人及你
无人及你 2020-12-17 01:14

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 ca

相关标签:
4条回答
  • 2020-12-17 01:34

    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.

    0 讨论(0)
  • 2020-12-17 01:37

    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
    
    0 讨论(0)
  • 2020-12-17 01:40

    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.

    0 讨论(0)
  • 2020-12-17 01:42

    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.

    0 讨论(0)
提交回复
热议问题