Visual Studio Unit Tests : dll is not trusted

▼魔方 西西 提交于 2019-12-19 11:31:43

问题


I'm struggling getting some unit tests running and wondering if anyone might have anything insightful.

The setup is that we've got a bunch of referenced DLL's on a server and when I try and execute I get the old

Test Run deployment issue: The location of the file or directory 'c:\source\ProjectName\bin\debug\3rdPartyLibrary.dll' is not trusted.

I've tried the old caspol command:

caspol -m -ag 1.2 -url file:\server\binaries* FullTrust

Which seems to work for everything bar one DLL. I'm currently having to manually change the permissions everytime I do a build of the test project, which is a pain. Anyone have any suggestions? Running a Win7 64bit OS btw.


回答1:


Ian had the key that started the fix for me. I'm attempting to use WatiN on Windows 7 64bit and kept getting the "not trusted" error. Here are the steps I took to fix it.

  1. Close VS.
  2. Delete the WatiN directory from Programs Files (x86)
  3. Navigate to my user directory. Search for and delete WatiN dll's.
  4. Navigate to my project directory. Search for and delete all WatiN dll's.
  5. Re-download WatiN.
  6. Right click on the .zip file and unblock the contents before the copy operation.
  7. Recreate the WatiN directory under the Programs Files (x86) and copy the file from the .zip.

Unless you get the stray WatiN dll's VS will continue to access the untrusted DLL's and drive you nuts.




回答2:


If you go to the dll through Winodws Explorer, right click and go to properties there's an "Unblock" button.




回答3:


Are the .dlls in question files downloaded from the internet?

If so, they may be 'blocked' by the OS unless you explicitly unblock them. You can do this by right-clicking the files in question and select Properties, and then click on the Unblock button.




回答4:


Uncheck 'readonly' before you select 'Unblock' from the properties dialog of the assembly in question. It should stay unblocked if it is not readonly.




回答5:


You need to download the streams.exe from the below path: http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx

place it in the same folder where you have the problem with the dll and navigate to that path in powershell/command prompt and run the below command: streams -s -d(command prompt) .\streams.exe -s -d "Folder Name"(from powershell)



来源:https://stackoverflow.com/questions/2264988/visual-studio-unit-tests-dll-is-not-trusted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!