1

我最近将 DotNetNuke 6 安装切换到 .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

所以解决方法是

在 HostRuntime.ResolveAssembly 中捕获 FileNotFoundException 并返回 null。这应该可以防止进程崩溃。

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


编辑:我一直在为框架 4 挖掘 mscorlib 程序集,我看到一些非常奇怪的东西:

从 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 ......这对我来说看起来是一个非常奇怪的行为

4

1 回答 1

0

根据堆栈跟踪,它看起来像是 Telerik 版本问题。你确定正确的程序集都被加载了吗?

于 2013-07-24T17:04:56.843 回答