.NET 4.0的第三方库导致"该程序集不允许部分受信任的调用方" [英] .NET 4.0 third-party library causing "That Assembly does not allow partially trusted callers"
问题描述
我有引用第三方库的源$ C $ C,我没有一个控制台应用程序:
I have a console application that references third party libraries whose source code I don't have:
1)Common.Logging.NLog,2)Common.Logging,3)NLOG
1) Common.Logging.NLog, 2) Common.Logging, 3) NLog
切换安全选项这是一个部分信任的应用程序(部署在网络共享驱动器)后,VS了4警告:
After switching the Security option to "This is a partial trust application" (deployed in a network share drive), VS gave 4 warnings:
Warning 1 Reference 'Common.Logging.NLog' does not allow partially trusted callers.
Warning 2 Reference 'Common.Logging' does not allow partially trusted callers.
Warning 3 Reference 'NLog' does not allow partially trusted callers.
Warning 4 Use of app.config binding redirects requires full trust.
我想在<一个解决方案href="http://stackoverflow.com/questions/4260782/c-sharp-net-4-0-that-assembly-does-not-allow-partially-trusted-callers">C# - .NET 4.0 - 该程序集不允许部分受信任的调用方通过 1)创建使用SN.EXE的关键 2)登录我所有的组件用此键。
I tried the solution in C# - .NET 4.0 - That Assembly does not allow partially trusted callers by 1) Create a key using SN.EXE 2) Sign all my assemblies with this key.
在编译器抱怨说,第三方库没有一个强大的名字。
After that the compiler complained that the third party libraries don't have a strong name.
会有人提出一个解决方案吗?我没有在客户机上直接控制,所以我preFER不需要客户机配置一个解决方案(例如,的Caspol.exe)。
Would anyone suggest a solution? I don't have direct control on the client machine, so I'd prefer a solution that doesn't require client machine configuration (for example, CASPOL.EXE).
UPDATE_1
我添加&LT; NetFx40_LegacySecurityPolicy启用=真/&GT;
来的app.config。它接着通过了第一个SecurityException异常,但在以后的同样的错误死亡。
I added <NetFx40_LegacySecurityPolicy enabled="true" />
to app.config. It went passed the first SecurityException, but died at a later point for the same error.
感谢。
推荐答案
一些试验和错误之后,我发现了一个方式来获得示例应用程序的工作。
After some trial and error, I found a way to get the sample app working.
- 下载code。
- 设置每个项目的目标框架.NET 4
- 登入每个项目使用相同的密钥。 (我没有 实验签约他们用不同的密钥)
- 在编译的一切。
-
添加到App.config中
- Download the code.
- Set the Target Framework of each project to .NET 4.
- Sign each project with the same key. (I didn't experiment signing them with different keys)
- Compile everything.
Add to App.config
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true" />
</runtime>
这篇关于.NET 4.0的第三方库导致&QUOT;该程序集不允许部分受信任的调用方&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!