ASP.net用户控件和AppDomain中TypeResolve [英] ASP.net UserControl and AppDomain TypeResolve

查看:148
本文介绍了ASP.net用户控件和AppDomain中TypeResolve的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的VirtualPathProvider以包括不可在编译时用户控件。
一切正常,除了提及,实际上包含该控件的DLL。

I'm using a VirtualPathProvider to include usercontrols that are not available at compile-time. Everything is working correctly except for the reference to the dll that actually contains the control.

在有控制的页面被称为无法找到控制类型,除非我把DLL的bin文件夹。

When the page that has the control is called it can't find the control type unless I put the dll on the bin folder.

错误:
分析器错误
说明:该请求提供服务所需资源的分析过程中出现错误。请检查下列特定分析错误详细信息并适当地修改源文件。

Error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

分析器错误信息:未能加载类型
  App.Modules.ModuleA.Controls.Entity1Item。

Parser Error Message: Could not load type 'App.Modules.ModuleA.Controls.Entity1Item'.

源错误:

1号线:其中,%@控制语言=C#AutoEventWireup =真
  codeBehind =Entity1Item.ascx.cs
  继承=App.Modules.ModuleA.Controls.Entity1Item%>

Line 1: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Entity1Item.ascx.cs" Inherits="App.Modules.ModuleA.Controls.Entity1Item" %>

我试图处理所有显著的AppDomain事件(AssemblyResolve,TypeResolve和ReflectionOnlyAssemblyResolve),但没有得到所谓的我喜欢的类型。

I tried to handle all significant AppDomain events (AssemblyResolve, TypeResolve and ReflectionOnlyAssemblyResolve) but none get called for my type.

我的TypeResolve文档中看到,每当执行Type.GetType和类型没有找到这个叫。看起来像ASCX没有触发事件时,它需要的类型......为什么?

I saw in the TypeResolve documentation that this is called whenever a Type.GetType is executed and the type isn't found. Seem like the ASCX isn't triggering the event when it needs its type... why?

谢谢!
亚历克斯

Thanks! Alex

推荐答案

这是AssemblyResolve事件应该解决这个问题,但你需要的类型名称,例如指定的程序集名称。

An AssemblyResolve event should solve this, but you need to specify the assembly name in the type name, e.g.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Entity1Item.ascx.cs"
    Inherits="App.Modules.ModuleA.Controls.Entity1Item, YourDynamicAssemblyName" %>

在AssemblyResolve事件会那么火,要求您装入YourDynamicAssemblyName。

The AssemblyResolve event will then fire asking you to load 'YourDynamicAssemblyName'.

这篇关于ASP.net用户控件和AppDomain中TypeResolve的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆