简体   繁体   English

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

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

i'm using Visual Studio 2012 and cannot see any Unit Tests when i go to the TestExplorer . 我使用的是Visual Studio 2012 ,转到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 . 我已经尝试将<loadFromRemoteSources enabled="true"/>到各种.config文件中,甚至使用caspol.exe使网络共享“完全可信”

My network share is mounted as unit X: , so the command looks like this: 我的网络共享安装为X:单元,因此命令如下所示:

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. 我也尝试将<legacyCasPolicy enabled="true" />到配置中,但不走运。

If I try to Debug the Test directly using Resharper plugin, the error I get is: 如果我尝试使用Resharper插件直接调试测试,我得到的错误是:

Unable to get type ProductDataModules.DataModel.Tests.TSD_InformationModule. 无法获取类型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. 错误:System.IO.FileLoadException:无法加载文件或程序集'file:/// X:\\ Source \\ ProductDataModulesTests \\ bin \\ Debug \\ ProductDataModulesTests.dll'或其依赖项之一。 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. (来自HRESULT的异常:0x80131515)文件名:'file:/// X:\\ Source \\ ProductDataModulesTests \\ bin \\ Debug \\ ProductDataModulesTests.dll'---> System.NotSupportedException:试图从网络加载程序集该位置可能导致程序集在.NET Framework的早期版本中被沙箱化。 This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. 默认情况下,此版本的.NET Framework不启用CAS策略,因此此加载可能很危险。 If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. 如果此负载不是要对程序集进行沙箱处理,请启用loadFromRemoteSources开关。 See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. 有关更多信息,请参见http://go.microsoft.com/fwlink/?LinkId=155569
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, Bool 在System.Reflection.RunRunAsAsName处位于System.Reflection.RunTimeAsName处的System.Reflection.RuntimeAssembly._nLoad(AssemblyName文件名,字符串codeBase,证据assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔型throwOnFileNotFound,布尔值用于自省,布尔值抑制安全检查)。 ,证据组装安全性,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔throwOnFileNotFound,布尔forIntrospection,布尔hibitSecurityChecks)位于System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName AssemblyRef forIntrospection,在System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile,Evidence securityEvidence,Byte [] hashValue,AssemblyHashAlgorithm hashAlgorithm,Bool)中进行布尔运算 ean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(String typeName, String assemblyName) ean forIntrospection,布尔型抑制安全检查,Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(String typeName,String assemblyName)的System.Reflection.Assembly.LoadFrom(String assemblyFile)处的StackCrawlMark&stackMark)

Did anybody have this issue? 有人遇到这个问题吗? How did you solve it? 您是如何解决的?

Visual Studio 2012 refused to trust my network share . Visual Studio 2012拒绝信任我的网络共享

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: 然后,我必须使用以下命令从cmd.exe建立符号链接

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

Now I had to browse to the new path, and open the .SLN file. 现在,我必须浏览到新路径,然后打开.SLN文件。

I could even make a shortcut to my Desktop. 我什至可以为桌面创建快捷方式。 The link now points to c:\\symLink...\\solution.sln 现在,链接指向c:\\ symLink ... \\ solution.sln

I never had a permission bug again. 我再也没有权限错误。 Hope it helps. 希望能帮助到你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单元测试在一起运行时失败,单独传递 - Unit Tests fail when run together, pass individually 单元测试在Visual Studio中“全部运行”但单独传递时失败 - Unit Tests Fail when “Run All” in Visual Studio but passes individually 单元测试在“全部运行”时失败,但在单次运行时通过 - Unit tests fail on Run All but pass when are run single 当多个单元测试复制同一文件时,运行所有单元测试失败 - When multiple unit tests copy the same file, running all unit tests fail 更改数据库架构和实体但不更改单元测试时,单元测试将失败 - Fail the unit tests when the database schema, and entity are changed, but unit tests are not changed 具有Shouldly语句的单元测试失败 - Unit Tests with Shouldly statement fail Azure Devops - MSTest - 如果我的单元测试失败,我如何使构建失败,但在集成测试失败时继续(带有警告/通知) - Azure Devops - MSTest - How can I fail a build if my unit tests fail, but continue (with warning/notification) when integration test fail 使用LAN上的Mono上传到Android设备上的Windows网络共享 - Uploading to a Windows network share on Android device using Mono on LAN 为什么使用HostType(“ Moles”)进行的单元测试中的断言在单独运行时可以通过,而在一组测试中运行时却失败? - Why would an assert on a unit test with HostType(“Moles”) pass when run individually, but fail when run with a group of tests? Flurl&HttpTest:单元测试在全部运行时失败,但在单独运行时通过 - Flurl & HttpTest: Unit tests fail when Run All, but pass when run individually
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM