当我第一次启动我的网站时,我收到了这个错误
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
我究竟做错了什么?
我正在使用.NET 4并从Visual Studio启动该站点.
我最近唯一改变的是将Simple Injector(通过Nuget)添加到我的项目中.
这是堆栈跟踪
[TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' 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, …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译一个使用ILMerge将多个DLL组合在一起的项目,然后对它们进行签名以部署到CRM。代码已编译,但是ILMerge失败。此过程适用于其他开发人员的计算机,但不适用于我的计算机。
我正在使用Visual Studio 2015,Windows 10并针对.NET 4.5.2。进行构建。
所有项目都使用AnyCPU进行编译。
已将程序集引用“ System.Runtime.Caching”解析为“ C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 .. \ v4.0.30319 \ System.Runtime.Caching.dll”。(使用的框架目录。)
合并过程中发生异常:无法加载DLL'mscorsn.dll':找不到指定的模块。(来自HRESULT的异常:0x8007007E)位于System.Compiler.Writer.MscorsnStrongNameSignatureGeneration(String wszFilePath,String wszKeyContainer,Byte [] pbKeyBlob,Int32 cbKeyBlob,IntPtr ppbSignatureBlob,IntPtr pcbSymBerWerWerBlockSymPerWilBerWilBerWilBerWilBerWilBerWilBerWonderWonderWonderWonder(PRESSION) ,模块模块,布尔型delaySign,字符串keyFileName,字符串keyName),位于System.Compiler.Writer.WritePE(CompilerParameters编译器参数,模块模块),位于ILMerging.ILMerge.Merge(),位于ILMerging.ILMerge.Main(String [] args)
我的构建后事件参数是:
if "$(ConfigurationName)" == "Debug No ILMerge" goto :exit
REM **** Create ILMerge Directory ****
md "$(TargetDir)IlMerge"
REM **** Delete Previous Log ****
del "$(TargetDir)IlMerge\Log.txt"
REM **** Run IlMerge ****
"$(SolutionDir)packages\ILMerge.2.14.1208\tools\ILMerge.exe" /log:"$(TargetDir)IlMerge\Log.txt" /keyfile:"$(ProjectDir)Client.Xrm.Plugins.Key.snk" /targetplatform:v4 /out:"$(TargetDir)IlMerge\$(TargetFileName)" "$(TargetPath)" "$(TargetDir)DLaB.Common.dll" "$(TargetDir)DLaB.Xrm.2015.dll" "$(TargetDir)Client.Xrm.dll" "$(TargetDir)Applications.Web.Security.dll" "$(TargetDir).Domain.dll" "$(TargetDir)Newtonsoft.Json.dll"
:exit
我可以在计算机上手动找到mscorsn.dll,并将其放入本地文件夹。ILMerge会选择它,但是根据我使用的版本(Windows中有4-5个不同的副本),它可能会完全失败或说明无法签署最终的dll。
我尝试将其targetplatform指向具有mscorsn.dll文件的特定.NET文件夹,但无济于事。