Share via


Visual Studio Project Sample Loading Error: Assembly could not be loaded and will be ignored. Could not load file or assembly or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

Some folks have mentioned to me that they are having trouble getting some of my samples to work.  And in fact, just the other day, I ran into a problem getting my own samples to work.  It turns out to be a problem with the way windows treats the sample that you down load.

Specifically, because you downloaded the sample from the internet, windows treats the sample as “untrusted” content.  When you unzip untrusted content you get a directory full of untrusted content.  Visual Studio is not so good and running untrusted content.  Unfortunately, you get some really bad error messages like the one above.

Here is the error message from VB

image

Warning    1    Assembly 'C:\Users\brada\Desktop\MyApp.VB\MyApp.VB.Web\bin\MyApp.VB.Web.dll' could not be loaded and will be ignored.
Could not load file or assembly 'file:///C:\Users\brada\Desktop\MyApp.VB\MyApp.VB.Web\bin\MyApp.VB.Web.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)    MyApp.VB

 

And here is the message from C#:

image

Warning    1    Assembly 'C:\Users\brada\Desktop\MyApp.Starter\MyApp.Web\bin\MyApp.Web.dll' could not be loaded and will be ignored.
Could not load file or assembly 'file:///C:\Users\brada\Desktop\MyApp.Starter\MyApp.Web\bin\MyApp.Web.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)    MyApp

 

Notice these are warnings, so if you are only looking at errors, you will be even more confused. 

 

There is at least a good warning when the project is being loaded.     I am not sure why you are giving the option to continue here, because there are very few projects that will just work in the semi-trusted way.  If you see this, hit cancel and fix the issue first. 

image

 

Luckily fixing this is very easy.  Just go back to the ZIP file you downloaded, select properties, then “unblock” the content. 

image

 

 

 

 

 

Then extract the contents and rerun it.  Everything should work fine.

 

Good luck!

Comments

  • Anonymous
    December 11, 2009
    minus a few points for the unintuitive error messages (the first doesn't mention it's a trust issue; the second implies continuing will fix things) plus several more points for having VS pick up on the downloaded-from-web flag ;)

  • Anonymous
    December 11, 2009
    Funny it turns up like this; it's not like the issue was new, but somehow people on many fronts have been hitting it of late. I blogged on the Windows level implementation of this a couple of days ago: http://www.heikniemi.net/hardcoded/2009/12/security-problems-with-downloaded-net-assemblies/ (which may be of interest to some of the geekier readers... Wait, are there any other sorts here?)

  • Anonymous
    December 12, 2009
    That's why you should use a 3rd party unpacker!

  • Anonymous
    December 12, 2009
    If you've already unzipped the files, an alternative to unblocking the zip, deleting the already extracted files, and re-extracting the files is to run streams -s -d * in the folder with the solution/project files. This will remove the streams that tag the files as untrusted. If you still have the project open in Visual Studio, click Yes to allow Visual Studio to reload the project.

  • Anonymous
    December 12, 2009
    Oh, I forgot to mention... streams is part of the free SysInternals suite available from Microsoft.

  • Anonymous
    February 09, 2010
    Brad, I am starting a new application using silverlight. Its for internal and external use. I wanted to use WCF and want to make UI independent, so that later I can add other UI(Winform etc). The application also should have security, multiple projects, OOB etc. my question is, I am getting confused which particular sample I should download from your blog to start with!!

  • Anonymous
    March 11, 2010
    Brad, We just lose hours because our VS 2010 Add-In didn't work on a client machine. It was because one of our redistributable file was blocked. When VS cannot load an Add-In, at the very least the error should be explained in plain english instead of a generic dialog.