当解决方案位于网络共享(LAN)上时,单元测试无法加载

时间:2013-11-13 20:11:32

标签: c# visual-studio visual-studio-2012

我正在使用 Visual Studio 2012 ,当我转到 TestExplorer 时看不到任何单元测试。

解决方案是网络共享

我已尝试将<loadFromRemoteSources enabled="true"/>添加到各种 .config 文件中,甚至使用 caspol.exe <使网络共享“完全信任” /强>

我的网络共享以 X:为单位安装,因此命令如下所示:

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

我还尝试将<legacyCasPolicy enabled="true" />添加到配置中,但没有运气。

如果我尝试使用Resharper插件直接调试测试,我得到的错误是:

  

无法获得类型   ProductDataModules.DataModel.Tests.TSD_InformationModule。   错误:System.IO.FileLoadException:无法加载文件或程序集   '文件:/// X:\来源\ ProductDataModulesTests \ BIN \调试\ ProductDataModulesTests.dll'   或其中一个依赖项。不支持操作。 (例外   来自HRESULT:0x80131515)文件名:   '文件:/// X:\来源\ ProductDataModulesTests \ BIN \调试\ ProductDataModulesTests.dll'   ---&GT; System.NotSupportedException:尝试从网络位置加载可能导致程序集的程序集   在以前版本的.NET Framework中沙箱化。这个   .NET Framework的发布默认情况下不启用CAS策略,   所以这个负载可能很危险。如果此负载不是沙箱   程序集,请启用loadFromRemoteSources开关。看到   http://go.microsoft.com/fwlink/?LinkId=155569了解更多信息   在System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,   String codeBase,Evidence assemblySecurity,RuntimeAssembly   locationHint,StackCrawlMark&amp; 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(字符串   assemblyFile,Evidence securityEvidence,Byte [] hashValue,   AssemblyHashAlgorithm hashAlgorithm,Boolean forIntrospection,Boolean   suppressSecurityChecks,StackCrawlMark&amp; stackMark)at   System.Reflection.Assembly.LoadFrom(String assemblyFile)at   Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(字符串   typeName,String assemblyName)

有人有这个问题吗?你是怎么解决的?

1 个答案:

答案 0 :(得分:0)

Visual Studio 2012拒绝信任我的网络共享

但是我找到了一个愚弄它的解决办法(让它假设我的环境在本地驱动器上):

首先,我必须映射网络单元永久,它要求用户和密码进行身份验证。我选择记住凭据,以便即使在重新启动或关闭后信任关系也会自动加载。

然后我必须使用以下命令从cmd.exe创建符号链接

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

现在我必须浏览到新路径,然后打开.SLN文件。

我甚至可以创建一个桌面快捷方式。 该链接现在指向 c:\ symLink ... \ solution.sln

我再也没有获得过许可错误。希望它有所帮助。