SORU
6 Aralık 2012, PERŞEMBE


Yük türü 'Sistem değil.Çalışma zamanı.CompilerServices.' Meclis 'mscorlib ExtensionAttribute

İlk defa bir web sitesi başlatırken bu hatayı alıyorum

Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Neyi yanlış yapıyorum?

Kullanıyorum .NET 4 ve Visual Studio sitesini başlıyor.

Son zamanlarda değiştirdim tek şey projeme Basit Enjektör (Nuget) ekleyin.

İşte yığın izleme

Stack Trace:


[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, 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)  132
   WebActivator.ActivationManager.RunActivationMethods()  216
   WebActivator.ActivationManager.RunPreStartMethods()  43
   WebActivator.ActivationManager.Run()  69

[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.Runtime.CompilerServices.ExtensionAttribute' 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.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context)  9090876
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)  97
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)  258

Tüm görünümler ilk satırı ön plana çıkar ve üzerine geldiğinizde bu hatayı alırsınız

The pre-application start initialisation method Run on type WebActivator.ActivationManager threw an exception with the following error message Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

CEVAP
6 Aralık 2012, PERŞEMBE


'Sistem.türü yüklenemedi Çalışma zamanı.CompilerServices.ExtensionAttribute kurulu mscorlib

Evet, teknik olarak bu kodu çalıştırdığınızda ters gidebilir .NET 4.0 yerine .NET 4.5. Öznitelik system.core.dll gelen mscorlib.dll taşındı .NET 4.5. % 100 olması gerekiyordu çerçeve versiyonu oldukça kötü bir son dakika değişikliği gibi görünse de, [TypeForwardedTo] uyumlu bir öznitelik bu fark alınamıyordu yapmak gerekiyordu.

Murphy, bu gibi iyi niyetli her değiştirmek kimsenin aklına gelmeyen en az bir hata modu vardır. Bu İLMerge içine birkaç derlemeleri birleştirmek için kullanılan ve o aracı yanlış kullanıldığında yanlış görünüyor. Bu kırılma açıklayan iyi bir geri bildirim Madde 12**. Hatayı açıklayan blog post bir bağlantı kurar. Uzun bir makale değil, ama ben doğru yorumlarsanız o zaman yanlış İLMerge komut satırı seçeneği, bu soruna neden olur:

  /targetplatform:"v4,c:\windows\Microsoft.NET\Framework\v4.0.30319"

Yanlış olan. Daha sonra program kurar makinesinde 4.5 yüklediğinizde bu dizinde derlemeler 4.5 4.0 yenilendi ve artık 4.0 hedef için uygundur. Bu derlemeler gerçekten artık orada olmamalı ama uyumluluğu nedenlerle tutuldu. Ne yazık ki C /CLİ #yönergesini kullanarak hala bu derlemeler, düzeltmek için zor değişir. Uygun başvuru derlemeleri 4.0 referans meclisleri, başka bir yerde saklı

  /targetplatform:"v4,C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"

Ya da, 64 bit Windows:

  /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"

Olası geçici çözümler 4.0 için geri inşa makinede düşmeye, yükleyin .NET hedef makinede 4.5 ve sağlanan kaynak kod projesi, İLMerge komutu tamir yeniden inşa etmek için nihai çözüm.


Bu arıza modu için özel İLMerge değil, çok yaygın bir durumdur sadece not. Bu 4.5 derlemeler 4.0 hedefleyen bir projede derlemeler referans olarak kullanılan herhangi bir diğer senaryo da aynı şekilde başarısız yükümlüdür. Diğer sorular bakılırsa, başka bir yaygın hata modu VS geçerli bir lisans kullanmadan Kur sunucularını kurmak. Ve çoklu hedefleme paketleri bakan free download.

C:\Program dosyaları alt referans derlemeler kullanarak kaya gibi sert bir gerekliliktir. Başlangıç .NET 4.0, zaten önemli yanlışlıkla eklenen bir sınıf veya yöntem bir bağımlılığı alarak önlemek için 4.01, 4.02 ve 4.03 serbest bırakır. Ama kesinlikle gerekli 4.5 yayımlanan şimdi.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • 3DS Max Tutorials

    3DS Max Tuto

    4 AĞUSTOS 2013
  • Gigawipf

    Gigawipf

    18 ŞUBAT 2010
  • Shaollin Animes

    Shaollin Ani

    19 HAZİRAN 2013