2013-07-24 30 views
0

我最近切换的DotNetNuke的6安装到.NET 4框架,我已经开始收到以下错误:如何捕获.net框架4下未发现的资源程序集异常?

DotNetNuke.Services.Exceptions.PageLoadException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not find file 'Telerik.Web.UI.resources'. 
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) 
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) 
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) 
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) 
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) 
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture) 
at Telerik.Web.LocalizationProvider.EmbeddedResourceLocator.GetString(String resourceKey) 
at Telerik.Web.LocalizationStrings.GetString(String key, Boolean throwErrorIfMissing) 
at Telerik.Web.LocalizationStrings.GetString(String key) 
at Telerik.Web.UI.ComboBoxStrings.get_AllItemsCheckedString() --- End of inner exception stack trace --- 
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
at System.Web.SecurityUtils.MethodInfoInvoke(MethodInfo method, Object target, Object[] args) 
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) 
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) 
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) 
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat) 
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat) 
at Telerik.Web.UI.RadComboBox.DescribeComponent(IScriptDescriptor descriptor) 
at Telerik.Web.UI.RadDataBoundControl.Telerik.Web.IControl.DescribeComponent(IScriptDescriptor descriptor) 
at Telerik.Web.UI.ScriptRegistrar.GetScriptDescriptors(Control control) 
at Telerik.Web.UI.RadDataBoundControl.GetScriptDescriptors() 
at Telerik.Web.UI.RadDataBoundControl.System.Web.UI.IScriptControl.GetScriptDescriptors() 
at System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) 
at Telerik.Web.UI.RadDataBoundControl.RegisterScriptDescriptors() 
at Telerik.Web.UI.RadDataBoundControl.Render(HtmlTextWriter writer) 
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) 
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) 
at System.Web.UI.Control.RenderControl <....snip, rendering call stack> 

我不知道为什么这个错误发生,因为我不能复制它在另一个服务器,甚至是在同一台服务器上。因为我没有找到一个解决方案,我正在努力修补它,所以我看了看在这个岗位提出的解决方法: http://social.msdn.microsoft.com/Forums/vstudio/en-US/32e458a1-7443-4309-a054-8839b33dfd4f/framework-40-dll-loaded-by-a-20-executable-cannot-find-xxxxresourcesdll

因此,解决办法是

catch the FileNotFoundException in HostRuntime.ResolveAssembly and return null. This should prevent the process from crashing.

我可以添加一些代码通过HttpModule到应用程序,但我真的不明白我应该如何修补HostRuntime.ResolveAssembly ...任何想法?


编辑:我一直在mscorlib程序组件陷的框架4,我看到的东西很奇怪:

从ManifestBasedResourceGroveler到SatelliteAssembly装载的调用如下:

try 
    { 
     runtimeAssembly = this._mediator.MainAssembly.InternalGetSatelliteAssembly(satelliteAssemblyName, lookForCulture, this._mediator.SatelliteContractVersion, false, ref stackMark); 
    } 
    catch (FileLoadException ex) 
    { 
     int hResult = ex._HResult; 
     Win32Native.MakeHRFromErrorCode(5); 
    } 
    catch (BadImageFormatException) 
    { 
    } 

所以它捕获异常,但这里是InternalGetSatelliteAssembly

if (runtimeAssembly == this) 
    { 
     throw new FileNotFoundException(string.Format(culture, Environment.GetResourceString("IO.FileNotFound_FileName"), new object[] 
     { 
      assemblyName.Name 
     })); 
    } 
代码

好吧,所以我总是会得到一个FileNotFoundException,不会被捕获......看起来像一个非常奇怪的行为

回答

0

基于堆栈跟踪它看起来像一个Telerik版本问题。你确定正确的组件都装满了吗?

+0

我很确定,我添加了融合日志的视图,没有看到任何奇怪的版本号。有没有一种方法可以确保加载的版本是正确的? – samy

+0

我再次检查了我们的融合日志,我确信所有版本都与框架4相匹配,并且版本号相匹配 – samy