Visual Studio – Is Your Project Location Trusted?

Sometimes when opening a Visual Studio solution or project you may see the following error which informs you that the project location is not trusted.

As the dialog box informs us, this can cause security exceptions when attempting to perform tasks requiring full trust. One such task is the execution of unit tests within the team editions of Visual Studio and as you can see here the unit tests within the CodePlex.Diagnostics framework failed to execute. I know I can trust CodePlex.Diagnostics considering I wrote the library myself and so why does Visual Studio believe that the location cannot be trusted?

If you click on the Test run error hyperlink in the Test Results window (see above), you’ll be taken to the results summary for that test run where errors and warnings are listed. As you can see here the unit tests could not be ran because the codePlex.diagnostics.internal.unittests.dll is untrusted.

According to the MSDN documentationthe trust associated with the project location can be edited using either the mscorcfg.msc control panel or the code access security policy tool (caspol.exe).

Unfortunately that is not the whole story and following the MSDN documentation will not necessarily resolve the trust issue and allow you to execute the unit tests.

Windows is aware that the zip file downloaded from CodePlex originated from the Internet and therefore you must delete the Visual Studio solution you previously extracted from the zip file and first unblock the zip file. If you right click on the zip file and look at the properties associated with the zip file you’ll see an Unblock button. If you click this button and then unzip the Visual Studio solution and all the code again you’ll no longer be presented with the Visual Studio dialog advising you that the project location is not trusted.

Once the project location is trusted you’ll be able to once again run the unit tests and you’ll no longer have the risk of running into security exceptions caused by trust issues.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: