System.Security.SecuritySafeCriticalAttribute fail to load exception

Apr 23, 2010 at 1:44 PM

All,

I cannot find any information which states that MEF depends on .net 3.5 SP1 and we are having an issue i believe is related to SP1.

We currently only required .net 3.5, not SP1 to be installed on our clients.  When we run our app we are getting the following error.

 

Timestamp: 4/22/2010 3:16:35 PM Message: There was an unexpected exception while trying to load the composable parts: Exception Could not load type 'System.Security.SecuritySafeCriticalAttribute' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Inner exception message: Could not load type 'System.Security.SecuritySafeCriticalAttribute' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Stack trace: at Common.Impl.Plugin.PluginManager.SetupComposition() at ServiceHost.Infrastructure.OpenAPIServiceController.RegisterDocumentPlugins() at Common.Impl.Runner.ActionRunnerExecutor.RunAction(String stepName, Action actionToRun) at ServiceHost.Infrastructure.OpenAPIServiceController.OnStart() at ServiceHost.OpenAPIService.StartupSystem() at ServiceHost.OpenAPIService.HandleStartRequest(). Category: Exceptions Priority: -1 EventId: 0 Severity:

Error Title:There was an unexpected exception while trying to load the composable parts: Exception Could not load type 'System.Security.SecuritySafeCriticalAttribute' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Machine: VMCRAZYINSTALL Application Domain: ServiceHost.exe Process Id: 2424 Process Name: .ServiceHost Win32 Thread Id: 3052 Thread Name: Extended Properties:

What we did notice is that the proj file for MEF had the following. 

    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>


Can anyone tell me if they have seen this one before.

Developer
Apr 23, 2010 at 3:41 PM

Yes it is true MEF does depend on the SecuritySafeCriticalAttribute which is only in .Net 3.5 SP1. If your application it is always running in full-trust then you can safely comment out the uses of those attributes, they only come into play when you are running in partial trust environments.