Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

MS Tests failing due to Security Errors


:P
On this page:

I'm working on some of my DevConnections demos this weekend and as I'm working through them I've been playing around with some add-in graphing tools to provide some basic graphing support for one of my demos. I played around with Google graphs a bit today but frankly their interface is freaking painful. They don't provide direct point mapping, but you basically have to map your points into their coordinate system which means every data set needs to be translated first then you need to figure out how to configure the axis labels etc. to reflect the data. Free is good but not good enough when you have to go through rigamarole like that.

Anyway, there are a number of nice commercial tools I've used in the past, but I can't use those for samples that are given out. I've looked at ZedGraph which is open source and looks nice and relatively easy to use. I downloaded and installed it ran a few of their samples, customized it out a bit for my demo and I have a workable solution which is great. A lot quicker than the Google option and actually a better fit for this demo since it is a Web Service backend.

Break me will 'ya?

However, after just checking out the control and finally adding it to my sample classes and adding it to my business classes running unit tests I found that I immediately ran into an error.

Failed to queue test run 'rstrahl@RASNOTE 2008-03-16 18:12:33': Test Run deployment issue: The location of the file or directory 'c:\projects2008\articles\wcfajaxbusinesstest\wcfajaxbusinesstest\bin\debug\ZedGraph.dll' is not trusted.

Eh, ok. It's just a file on my hard disk. WTF is it complaining about security?

Well, Windows is trying to be very helpful. The file came from a directly downloaded ZIP file (Open, rather than Save As). I then dragged the files immediately into their own folder and added the assembly reference to the required project from there. I'm not sure under which condition Windows tags files as potentially dangerous but directly opening a Zip file off a Web download is definitely one of them. Oddly the DLL works fine for debugging and execution in Visual Studio. It just doesn't work for running tests with MS Test. Go figure.

The problem? Well it turns out that Windows tags the file as unsecure because it came out of a downloaded ZIP file. I'm very familiar with this problem in relation to CHM Help Files, which also don't work properly when downloaded directly or coming out of an internet downloaded Zip file. The solution to the problem is to view the File Properties in Explorer and on the Security tab use the Unblock button to reset the security.

The following screen shot demonstrates the error and the dialog to fix it:

TestNotExecuted_Security

Once unblocked the tests run just fine. Note that you need to exit Visual Studio and come back in after unblocking. You should also unblock any related assemblies (if there are more than one) and any Xml documentation files that might be loaded by Visual Studio.

Note that there can be other reasons for this same error in tests. I ran a few searches and in most cases that turned up, the problem was running an assembly from a network share that wasn't configured in the .NET Framework  security. By default network shares are part of the Intranet Zone which is not accessible through strict .NET permissions if they are checked. Same issue, different solution. In that case you'll need to allow that network share access by adding it to your trusted locations in the .NET framework configuration tool.

<sigh> Security - necessary as it is - can be such a freaking pain in the ass.

Posted in .NET  Security  

The Voices of Reason


 

Nate
March 17, 2008

# re: MS Tests failing due to Security Errors

Indeed! Imagine if we counted up all the productivity hours lost just trying to chase down stuff like this. Thanks as always for documenting the solution you found.

Steve
April 15, 2008

# re: MS Tests failing due to Security Errors

Worked great! Thanks a lot!!!

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024