We intermittently get this error on our .net 4 web forms web site. Recycling the app pool seems typically resolves it.
The only references i can find to it seem to be related to either using Umbraco, or the Dynamic language Runtime. Neither of which applies to us.
The only useful link I have found is this: http://support.frozenmountain.com/entries/23667761-Compatibility-issue-using-ASP-Net-4-0-Extensions-and-ScriptManager
Any other solutions, other than adding the unnecesary reference?
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) at System.Web.UI.AssemblyCache.GetAjaxFrameworkAssemblyAttribute(Assembly assembly) at System.Web.UI.ScriptManager.get_DefaultAjaxFrameworkAssembly() at System.Web.UI.ScriptManager..ctor() at ASP.masterpages_safarinow_master.__BuildControlMasterScriptManager() at ASP.masterpages_safarinow_master.__BuildControlfrmMain() at ASP.masterpages_safarinow_master.__BuildControlmasterBodyTag() at ASP.masterpages_safarinow_master.__BuildControlTree(masterpages_safarinow_master __ctrl) at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) at System.Web.UI.Page.ApplyMasterPage() at System.Web.UI.Page.PerformPreInit() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Although you said that you're not using the DLR, that's the only place this file exists. The error message strongly suggests that you're using an older version of IronPython (or IronRuby or some other DLR-based thing) which was built for .NET 2.0-3.5. Somewhere, there are files with names like "Microsoft.Dynamic.dll", "Microsoft.Scripting.Core.dll", and "Microsoft.Scripting.dll". Whatever is using this should be updated with a version of the DLR which was built specifically for .NET 4.0.
Related
I'm using Swashbuckle.AspNetCore package to document my API. I had it working for weeks until I started JSON serialization of some classes. Now I get an error in the Swagger UI :
"Failed to load API definition" - Fetch error Internal Server Error /swagger/v1/swagger.json
My log files show the following error:
System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed'. The located assembly's manifest
definition does not match the assembly reference. (Exception from
HRESULT: 0x80131040)
I updated to Newtonsoft.Json v12.0.1.
Does the Swagger NuGet package depend on a previous version of Newtonsoft?
I tried updating my entire solution to use Newtonsoft.Json v12.0.1.
I also searched for any possible dependencies Swagger may have with Newtonsoft, but I did not see anything explicit.
2019-03-26 17:17:34.573 -04:00 [Information] Request starting HTTP/1.1 GET http://localhost:8080/swagger/index.html
2019-03-26 17:17:34.680 -04:00 [Information] Request finished in 108.7888ms 200 text/html
2019-03-26 17:17:34.876 -04:00 [Information] Request starting HTTP/1.1 GET http://localhost:8080/swagger/v1/swagger.json
2019-03-26 17:17:34.898 -04:00 [Information] Request starting HTTP/1.1 GET http://localhost:8080/swagger/favicon-32x32.png
2019-03-26 17:17:34.916 -04:00 [Information] Sending file. Request path: '"/favicon-32x32.png"'. Physical path: '"N/A"'
2019-03-26 17:17:34.917 -04:00 [Information] Request finished in 18.8478ms 200 image/png
2019-03-26 17:17:35.032 -04:00 [Error] Connection ID ""16573246634629012016"", Request ID ""80001a32-0001-e600-b63f-84710c7967bb"": An unhandled exception was thrown by the application.
System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)
at System.Reflection.CustomAttribute.IsDefined(RuntimePropertyInfo property, RuntimeType caType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.GetSerializableMembers(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
at Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistry.CreateSchema(Type type, Queue`1 referencedTypes)
at Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistry.GetOrRegister(Type type)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateResponse(ApiResponseType apiResponseType, ISchemaRegistry schemaRegistry)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateResponses(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItems(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
2019-03-26 17:17:35.058 -04:00 [Information] Request finished in 182.3632ms 500
I expect the swagger page to list my HTTP methods as usual.
On clean a Windows 10 64 machine, I have installed Visual Studio 2017 RC (along with ALL components) and no projects are building at all. They are all failing with this error:
Child node "2" exited prematurely. Shutting down. Diagnostic
information may be found in files in the temporary files directory
named MSBuild_*.failure.txt.
When i investigate the log file it mentions it says:
UNHANDLED EXCEPTIONS FROM PROCESS 7300:
===================== 07/01/2017 19:30:19 System.IO.FileNotFoundException: The system cannot find the file
specified. (Exception from HRESULT: 0x80070002) at
Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance() at
Microsoft.Build.Evaluation.ToolsetConfigurationReader.ReadApplicationConfiguration()
at
Microsoft.Build.Evaluation.ToolsetConfigurationReader.get_ConfigurationSection()
at
Microsoft.Build.Evaluation.ToolsetConfigurationReader.<get_ToolsVersions>d__8.MoveNext()
at
Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2
toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1
initialProperties, Boolean accumulateProperties) at
Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2
toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1
initialProperties, Boolean accumulateProperties, String&
msBuildOverrideTasksPath, String& defaultOverrideToolsVersion) at
Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2
toolsets, ToolsetRegistryReader registryReader,
ToolsetConfigurationReader configurationReader, PropertyDictionary`1
environmentProperties, PropertyDictionary`1 globalProperties,
ToolsetDefinitionLocations locations) at
Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader
registryReader, ToolsetConfigurationReader configReader) at
Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2
globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers,
ToolsetDefinitionLocations toolsetDefinitionLocations, Int32
maxNodeCount, Boolean onlyLogCriticalEvents) at
Microsoft.Build.Evaluation.ProjectCollection.get_GlobalProjectCollection()
at
Microsoft.Build.Execution.OutOfProcNode.HandleNodeConfiguration(NodeConfiguration
configuration) at
Microsoft.Build.Execution.OutOfProcNode.HandlePacket(INodePacket
packet) at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean
enableReuse, Exception& shutdownException) at
Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches
commandLineSwitches) at
Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLineSwitches
switchesFromAutoResponseFile, CommandLineSwitches
switchesNotFromAutoResponseFile, String& projectFile, String[]&
targets, String& toolsVersion, Dictionary`2& globalProperties,
ILogger[]& loggers, LoggerVerbosity& verbosity, List`1&
distributedLoggerRecords, Boolean& needToValidateProject, String&
schemaFile, Int32& cpuCount, Boolean& enableNodeReuse, TextWriter&
preprocessWriter, Boolean& debugger, Boolean& detailedSummary, Boolean
recursing) at Microsoft.Build.CommandLine.MSBuildApp.Execute(String
commandLine) at Microsoft.Build.CommandLine.MSBuildApp.Main()
=================== 07/01/2017 19:30:19 System.IO.FileNotFoundException: The system cannot find the file
specified. (Exception from HRESULT: 0x80070002) at
Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance() at
Microsoft.Build.Evaluation.ToolsetConfigurationReader.ReadApplicationConfiguration()
at
Microsoft.Build.Evaluation.ToolsetConfigurationReader.get_ConfigurationSection()
at
Microsoft.Build.Evaluation.ToolsetConfigurationReader.<get_ToolsVersions>d__8.MoveNext()
at
Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2
toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1
initialProperties, Boolean accumulateProperties) at
Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2
toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1
initialProperties, Boolean accumulateProperties, String&
msBuildOverrideTasksPath, String& defaultOverrideToolsVersion) at
Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2
toolsets, ToolsetRegistryReader registryReader,
ToolsetConfigurationReader configurationReader, PropertyDictionary`1
environmentProperties, PropertyDictionary`1 globalProperties,
ToolsetDefinitionLocations locations) at
Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader
registryReader, ToolsetConfigurationReader configReader) at
Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2
globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers,
ToolsetDefinitionLocations toolsetDefinitionLocations, Int32
maxNodeCount, Boolean onlyLogCriticalEvents) at
Microsoft.Build.Evaluation.ProjectCollection.get_GlobalProjectCollection()
at
Microsoft.Build.Execution.OutOfProcNode.HandleNodeConfiguration(NodeConfiguration
configuration) at
Microsoft.Build.Execution.OutOfProcNode.HandlePacket(INodePacket
packet) at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean
enableReuse, Exception& shutdownException) at
Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches
commandLineSwitches) at
Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLineSwitches
switchesFromAutoResponseFile, CommandLineSwitches
switchesNotFromAutoResponseFile, String& projectFile, String[]&
targets, String& toolsVersion, Dictionary`2& globalProperties,
ILogger[]& loggers, LoggerVerbosity& verbosity, List`1&
distributedLoggerRecords, Boolean& needToValidateProject, String&
schemaFile, Int32& cpuCount, Boolean& enableNodeReuse, TextWriter&
preprocessWriter, Boolean& debugger, Boolean& detailedSummary, Boolean
recursing) at Microsoft.Build.CommandLine.MSBuildApp.Execute(String
commandLine) at Microsoft.Build.CommandLine.MSBuildApp.Main()
===================
I have repaired the installation and done a full uninstall/install that doesnt make a difference.
Tried turning logging on under Tools -> Options to diagnostic but it doesnt show me which file it is refering to in the error message in the log file.
This works with existing projects and new projects. Any ideas?
NOTE: I did originally install VS on a non default non system drive but removed this and re did it to the default installation.
I try migration ImageResizer v3 to v4. After upgrade I can not call ImageResizer and not even support page. Support page error is:
[TypeLoadException: Der Typ "ImageResizer.Util.BundleAttribute" in der Assembly "ImageResizer, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" konnte nicht geladen werden.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +191
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +162
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +148
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +604
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +144
System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) +111
System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit) +17
System.Reflection.CustomAttributeExtensions.GetCustomAttribute(Assembly element) +60
ImageResizer.Plugins.Basic.DiagnosticPageHandler.GenerateOutput(HttpContext context, Config c) +943
ImageResizer.Plugins.Basic.DiagnosticPageHandler.ProcessRequest(HttpContext context) +168
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +904
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +98
How can I fix that? I uninstalled modules and reinstalled but with no luck:
ImageResizer.4.0.5
ImageResizer.Plugins.TinyCache.4.0.5
You have left in 1 or more plugins from ImageResizer v3. You can't use a a v3 plugin with v4 ImageResizer.dll.
I deployed my ASP.NET MVC 4 web app to a Windows Server 2003 (IIS 6). But it will not start.
Originally I had developed the project for .NET 4.5, but had to rebuild it for .NET4 when I found out that .NET 4.5 is not supported on Windows Server 2003.
This meant removing all the third party references (with NuGet), changing the build target in project properties to .NET4, then adding the references back.
The references were to Ninject, EF and Automapper.
When I try to load a page I get the following error:
Could not load type 'System.Reflection.AssemblyMetadataAttribute' from
assembly 'mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'. Description: An unhandled exception
occurred during the execution of the current web request. Please
review the stack trace for more information about the error and where
it originated in the code.
Exception Details: System.TypeLoadException: Could not load type
'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Could not load type
'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken,
IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs,
Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module,
Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext,
RuntimeTypeHandle[] methodInstantiationContext) +180
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,
Type[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord
caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly,
RuntimeModule decoratedModule, MetadataToken decoratedToken,
RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[]
attributes, IList derivedAttributes, RuntimeType& attributeType,
IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean&
isVarArg) +115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule
decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount,
RuntimeType attributeFilterType, Boolean mustBeInheritable, IList
derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +426
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly
assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Type
attributeType, Boolean inherit) +64
WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly
assembly) +113
WebActivator.ActivationManager.RunActivationMethods() +216
WebActivator.ActivationManager.RunPreStartMethods() +28
WebActivator.ActivationManager.Run() +55
[InvalidOperationException: The pre-application start initialization
method Run on type WebActivator.ActivationManager threw an exception
with the following error message: Could not load type
'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1
methods) +423
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters,
PolicyLevel policyLevel, Exception appDomainCreationException) +677
[HttpException (0x80004005): The pre-application start initialization
method Run on type WebActivator.ActivationManager threw an exception
with the following error message: Could not load type
'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9164848
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
+258
Any ideas?
EDIT: Website developed using VS2012
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly mscorlib
Yes, this technically can go wrong when you execute code on .NET 4.0 instead of .NET 4.5. The attribute was moved from System.Core.dll to mscorlib.dll in .NET 4.5. While that sounds like a rather nasty breaking change in a framework version that is supposed to be 100% compatible, a [TypeForwardedTo] attribute is supposed to make this difference unobservable.
This morning I had an unusual issue with my Silverlight 4 app. I have been a big fan of IoC frameworks, so decided I will use Unity for my project. But as soon as I added the assembly to my project, I got this following error.
System.Windows.Markup.XamlParseException occurred
Message=Could not load type 'System.Security.AllowPartiallyTrustedCallersAttribute' from assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
StackTrace: at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at MS.Internal.XamlSchemaContext.ProcessXmlnsDefinitions(Assembly assembly, String assemblyName)
at MS.Internal.XamlSchemaContext.EnsureManagedAssemblyAttributesLoaded()
InnerException:
Now if I remove the dll my app works absolutely fine. I have been scratching my head since morning and not having much luck with StackOverflow search or Google.
Any help is much appreciated.
Cheers---Jag
Please verify that you're actually referencing the Silverlight assembly rather than the desktop one. The AllowPartiallyTrustedCallersAttribute class isn't in the Silverlight version.
Are you using Unity 2.0? If so, the DLL is named "Microsoft.Practices.Unity.Silverlight.dll". Is that the DLL you've added? If the ".Silverlight" isn't in the file name, then you're referencing the desktop dll instead.
This article might provide some useful information. It basically says that:
"the limitation when using Unity in a
partial trust environment is that you
cannot register and use mappings using
the RegisterType methods where the
target class is internal (C#), Friend
(Visual Basic .NET), private (C#), or
Private (Visual Basic .NET)."
Doing a clean build followed by a full rebuild fixed this issue for me.