Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not allowed to load assembly from network location

I've recently set up a new Windows Server 2012 R2 environment and installed Visual Studio 2012.

Now I'm having a problem with multiple .NET 4.5 project's I migrated from my old server, a Windows Server 2008 machine. This never occurred on the old server.

When trying to load an assembly from a network location, I run into the following issue:

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.

I've looked at some other questions, but none of them provide a working solution.

This is what I've tried so far:

  • Added the loadFromRemoteSources switch to devenv.config, XDesProc.exe.appx.config and XDesProc.exe.config.
  • Checked whether the assembly was blocked, which it wasn't.
  • Tried using the CasPol utility, even though this only applies to pre .NET 4.0 projects.

All without success.

Is there another solution to solve this problem?

like image 274
Stijn Avatar asked Feb 05 '15 08:02

Stijn


People also ask

Which would have caused the assembly to be sandboxed in previous versions of the .NET framework?

NotSupportedException: 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.

Where can I find machine config file?

The machine. config file is stored in the %WINDIR%\Microsoft.NET\Framework folder in the directory where Microsoft Windows is installed. By default, it is located in the following path: C:\WINDOWS\Microsoft.NET\Framework\v1. 1.4322\CONFIG.


1 Answers

Adding the loadFromRemoteSources switch to machine.config solved the problem.

MSDN

The loadFromRemoteSources element specifies whether assemblies from remote sources should be granted full trust.

Example

<configuration>
    <runtime>
       <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>

You can find machine.config here:

32-bit

%windir%\Microsoft.NET\Framework\[version]\config\machine.config

64-bit

%windir%\Microsoft.NET\Framework64\[version]\config\machine.config
like image 54
Stijn Avatar answered Sep 25 '22 05:09

Stijn