Magnus Rahl
Feb 18, 2011
  4931
(0 votes)

Todays gotcha: Windows 7 assembly blocking

Yesterday I was playing with our new build server, trying to get it to run my fully-functional unit tests with code coverage analysis. Why that didn’t work is a different story, but in the progress of changing project settings and checking in updates something strange happened. Suddenly my local web site stopped working.

The error message

My local copy of the site with the web root set to my working folder for the project suddenly refused to start, prompting me with the yellow screen of death and this cryptic error message:

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:

Mapper.CreateMap<OtherProject.ClientProxies.Core.Person, MyProject.ExternalDataAccess.DTO.Person>();

(In the example above, I removed all the lines except the one where it indicated failure, which was the first line of my AutoMapper bootstrapper.)

Troubleshooting

I started troubleshooting blindly, rolling back the project, cleaning, rebuilding, checking that all dependencies were copied on build etc. etc., but all looked fine. I then checked the trust settings of IIS in case they had been messed up. No luck there either.

After some time googling I decided to follow a vague tip about checking the properties of all assemblies that are references or other dependences. BOOM – at the very bottom of the properties dialog of the AutoMapper assembly was this message:

This file came from another computer and might be blocked to help protect this computer.

Why on earth Windows had suddenly decided that the assembly came from another computer (and what does that mean, don’t most assemblies come from other computers?) I had no Idea about. But luckily it left me the option to unblock the assembly. After doing so, and after deleting the copy in the bin folder letting the rebuild take a fresh copy the unblocked assembly and finally restarting IIS, the site came back to life.

Feb 18, 2011

Comments

Feb 20, 2011 02:11 PM

This typically happen if you download files using IE, and the site is not among the Trusted Sites (not many are).

I've seen this happen several times, when people deploy to production servers and download the new files by zipping them, sending an email to themselves, and open the email through the browser. The zip file has this blocked flag, and when using Windows Explorer to unzip, all files in the zip fill also be blocked (using 7zip or Winrar remove the block flag when unpacking.) I always check and remove that flag before I unzip anything.

This is especially nasty when you deploy only one new .dll, cause the error message may vary, depending on how that dll is loaded into memory.

Magnus Rahl
Magnus Rahl Feb 20, 2011 08:53 PM

Agreed, it's very deceitful because there's no special error message for this type of "security breach", it will simply depend on the first time anything from that assembly is requested. In my case the clues pointed clearly to AutoMapper, but It might as well have been something deeper within the call stack there. It should really have its own Exception type.

And the ways of assembly blocking must indeed be mysterious, because in my case the AutoMapper dll probably never even left the bin folder. My copy task in the project is set to only replace the files if they have been changed, and I never cleared the bin folder so a fresh copy shouldn't have occurred either. Absolutely no web, email or zipping involved.

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024