the .net framework has a new security model which is quit different from its ancestor/predecessor/forerunner/antecessor/forebearer....
In a simple word, every application running from places other than local then it is not trusted. and the caspol does not work anymore.
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
.NET 4.0 doesn't have CasPol?. If you are running a non-hosted application (launching an exe), it'll be full-trusted, no-matter from where you started it. Sandboxing of assemblies is possible if they are loaded into an explicit host application (office, iis, etc...). If the exe is full-trusted, it wouldn't be safe to load an assembly from the network (afs) without limiting its permissions, that's why it throws this exception.
http://msdn.microsoft.com/en-us/magazine/ee677170.aspx
You can also enable the caspol settings. and relying on the dist benig full-trusted by default:
<configuration>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
</configuration>
Without doing so , you may end up having the following error:
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
Loading mixed mode or managed c++ assemblies fails
You may need to do this:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup>
.NET 4.0 changed the runtime activation policy. Mixed mode and managed c++ assemblies are built with earlier versions of .NET cannot be loaded without the configuration snippet above.
http://blogs.msdn.com/b/clrteam/archive/2010/06/23/in-proc-sxs-and-migration-quick-start.aspx
http://msdn.microsoft.com/en-us/magazine/ee819091.aspx
.NET 4.0引入了新的安全模型,不再默认启用CAS策略,这可能会影响从远程位置加载的程序集。本文解释了如何配置应用程序以允许加载远程程序集,并解决了混合模式及托管C++程序集的加载问题。
1万+

被折叠的 条评论
为什么被折叠?



