问题
I am getting this error "could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."
whenever i include quartz.net's dlls in my web site's bin directory and reference it in code. I am sure it has to do with the wrong .net framework.
my asp.net site is using target framework 4.0 i am using the .net 4 quartz.net files
and my IIS app pool (classic .net pool) is set to run .net 4.0 frework.
I am not sure where to start but what I know for sure is remove Quartz and I am looking good again (minus the scheduling)
回答1:
This was a problem introduced in the final version because Quartz.Net was compiled against the 4.5 framework. Take a look at this thread where the issue was reported. A fixed version of the dll is available.
回答2:
ExtensionAttribute class is required to use extension methods in C#. In .NET Framework 4.0 this class is in assembly System.Core.dll, but in .NET Framework 4.5 class was moved to mscorlib.dll. I guess that problem is, that Quartz.dll (or some other assembly) was compiled on computer with .NET Framework 4.5 installed thus expecting ExtensionAttribute in mscorlib.dll, which is not there on computers with only .NET Framework 4.0.
I believe that recompiling Quartz on computer without .NET Framework 4.5 should solve the problem. Also installing .NET Framework 4.5 on server with IIS should help, but I wouldn't recommend it since it is still beta.
回答3:
Have you tried adding the reference to mscorlib assembly and set Copy Local to true?
Reading here :
This issue has to do with how ILMerge.exe is run. Type forwarding (in this case of the ExtensionAttribute type) is considered a non-breaking change, in the sense that it is transparent, in the supported scenarios, to the runtime, as well as our compilers. Compilers or compiler-like tools (which ILMerge is one of) are expected to support type forwarding, just like they are expected to support other features of the runtime. Furthermore, the supported way of running compilers is by explicitly and completely referencing the reference assemblies of the appropriate Multi-Targetting pack.
来源:https://stackoverflow.com/questions/10139017/assembly-crashing-my-asp-net-4-0