如何注册要加载的非强名称程序集,就像它在GAC中一样?

问题描述 投票:7回答:4

我们的合作伙伴为我们提供了一个我们需要从我们的应用程序访问的程序集。不幸的是,这不是强名称,因此我们无法将其安装到GAC。我们不能将它放在与可执行文件相同的位置。

这有解决方案吗?

编辑:这将是一个临时解决方案,仅用于测试,当他们去RC时,我们将有一个强名称的程序集。

.net gac fusion
4个回答
5
投票

那时你有几个选择。

第一种是将程序集放在具有name of the assembly (without the extension) which is a subdirectory of the application directory的目录中。

第二种是使用probing element指定您希望CLR使用Load methods on the Assembly class探测app.config文件中的引用的子目录。

最后,您可以使用各种ildasm.exe /all /typelist /out=DataSystem.il DataSystem.dll ilasm.exe /dll /optimize /key=DataSystem.snk DataSystem.il 动态加载程序集,但我想在这种情况下这是一个非常糟糕的主意,假设您有程序集,并且您有想要在其中使用的具体类型。像这样的延迟组装加载通常在你想要替换某些抽象的实现时使用,这在这里似乎并非如此。


4
投票

使用反编译和签名的解决方法(使用Visual Studio的Developer命令提示符):

http://www.bloggedbychris.com/2011/09/29/signing-a-net-assembly-in-visual-studio/

可以使用Visual Studio IDE gacutil.exe -i DataSystem.dll 将DataSystem.snk生成为文件

那么你应该能够跑

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

1
投票

另一种解决方案是将以下内容添加到machine.config文件中:

http://codeingaddiction.blogspot.com/2011/06/how-to-add-strong-name-to-existing-dll_16.html

并将DEVPATH = path添加到系统环境变量中。


0
投票

我发现签署和注册程序集的最佳和最直接的解决方案是:qazxswpoi

为了让我轻松工作,我将CD转到某个目录,比如C:\ temp - 这似乎对我来说好多了,可能是因为文件权限在某些地方更容易访问。

© www.soinside.com 2019 - 2024. All rights reserved.