如何注册要加载的非强名称程序集,就像它在 GAC 中一样?
我们的一位合作伙伴为我们提供了我们需要从应用程序访问的程序集。不幸的是,这不是强名称,因此我们无法将其安装到 GAC。我们不能将它放在与可执行文件相同的位置。
有解决办法吗?
编辑:这将是一个仅用于测试的临时解决方案,当它们进入 RC 时,我们将有一个强命名的程序集。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
那时你有几个选择。
第一种是将程序集放置在具有 程序集名称的目录中(不带扩展名)它是应用程序目录的子目录。
第二种是使用 探测元素。
最后,您可以使用各种 Load 方法动态加载程序集程序集类,但我想说,在这种情况下,这是一个非常坏主意,因为您拥有程序集,并且您有要在其中使用的具体类型。当您想要替换某些抽象的实现时,通常会使用像这样的后期程序集加载,但这里的情况似乎并非如此。
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.
使用反编译和解决方法签名(使用 Visual Studio 的开发人员命令提示符):
可以使用 Visual Studio IDE 将 DataSystem.snk 生成为文件
http://www.bloggedbychris。 com/2011/09/29/signing-a-net-assemble-in-visual-studio/
那么你应该能够运行
Workaround using decompilation & signing (using Developer Command prompt for Visual studio):
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
另一种解决方案是将以下内容添加到 machine.config 文件中:
并将 DEVPATH = path 添加到系统环境变量中。
Yet another solution is to add the following to the machine.config file:
And add DEVPATH = path to the system environment variables.
我发现的最好、最直接的签名和注册程序集的解决方案在这里:
http://codeingaddiction。 blogspot.com/2011/06/how-to-add-strong-name-to-existing-dll_16.html
为了让这个功能轻松工作,我将 CD 复制到 C:\temp 等目录 -这对我来说似乎效果更好,可能是因为在类似的地方更容易访问文件权限。
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.