Unit Tests fail to load when solution is on a network share (LAN)

0

i'm using Visual Studio 2012 and cannot see any Unit Tests when i go to the TestExplorer.

The solution is is a network share.

I already tried adding <loadFromRemoteSources enabled="true"/> to various .config files, and even making the network share "Fully Trusted" using caspol.exe.

My network share is mounted as unit X:, so the command looks like this:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\CasPol.exe -machine -addgroup All_Code -url X:\* FullTrust

I also tried adding <legacyCasPolicy enabled="true" /> to the config without luck.

If I try to Debug the Test directly using Resharper plugin, the error I get is:

Unable to get type ProductDataModules.DataModel.Tests.TSD_InformationModule. Error: System.IO.FileLoadException: Could not load file or assembly 'file:///X:\Source\ProductDataModulesTests\bin\Debug\ProductDataModulesTests.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) File name: 'file:///X:\Source\ProductDataModulesTests\bin\Debug\ProductDataModulesTests.dll' ---> System.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. 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.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(String typeName, String assemblyName)

Did anybody have this issue? How did you solve it?

c#
visual-studio
visual-studio-2012
asked on Stack Overflow Nov 13, 2013 by canolucas • edited Oct 29, 2015 by pnuts

1 Answer

0

Visual Studio 2012 refused to trust my network share.

However I found a workaround to foolish it (make it assume my environment is on a local drive):

First of all, I had to map the network unit permanently, it asked for the user and password to authenticate. I chose to remember credentials, so that the trust relationship loads automatically even after a restart or shutdown.

Then I had to make a symbolic link from cmd.exe, using the following command:

mklink /D c:\symLink \\192.168.0.206\<share name>

Now I had to browse to the new path, and open the .SLN file.

I could even make a shortcut to my Desktop. The link now points to c:\symLink...\solution.sln

I never had a permission bug again. Hope it helps.

answered on Stack Overflow Nov 18, 2013 by canolucas • edited Nov 18, 2013 by canolucas

User contributions licensed under CC BY-SA 3.0