Question

I have a strange problem: I deployed a .NET 2.0 application that uses reflection and I got a Policy Exception once I call Assembly.LoadFile. The error is the following:

Could not load file or assembly 'xxx, Version=11.5.23.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. PolicyException thrown. (Exception from HRESULT: 0x80131416)    at System.Reflection.Assembly.nLoadFile(String path, Evidence evidence)   at System.Reflection.Assembly.LoadFile(String path)

The assembly to load is in a subfolder of the calling assembly. The application is runnning fine in other environment and I never faced this kind of problem. I suppose that this problem happens because I downloaded the zip containing the assembly from the web and the binary files where marked as untrusted and I had to "unblock" each single file.

The destination pc is running W2008 R2. In the same pc I'm running another software wich uses reflection in the same way and works fine. I tried to reinstall the application but I got the same problem. I cannot find a way to set the default trust level for the .NET assembly in the pc.

Any idea would be appreciated.

Thanks in advance.

Était-ce utile?

La solution

I run into this issue when I have added the same group policy to the same folder. I perform the following steps to solve this issue:

View the list of group permissions:

CD C:\Windows\Microsoft.NET\Framework\v2.0.50727
Caspol -a -listgroups 

Look for duplicate group permissions and remove the duplicate group permissions by running:

Caspol -rg {Add here the group policy number}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top