.net - .net 4.0 security model framework v2 and v4 compatibility issues

 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值