页面Y.ascx不能使用用户控制X.ascx [英] The page Y.ascx cannot use the user control X.ascx

查看:261
本文介绍了页面Y.ascx不能使用用户控制X.ascx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我得到了以下错误在我的Web应用程序。

I recently got the following error in my web application.

该页面'ControlName.ascx'不能使用用户
  控制OtherControl.ascx',因为它是在注册
  web.config中和生活在同一个目录中的页面。

The page 'ControlName.ascx' cannot use the user control 'OtherControl.ascx', because it is registered in web.config and lives in the same directory as the page.

虽然我能够通过移动控制和我很好奇,为什么这会产生错误的页面注册它来修复错误。

Whilst I was able to fix the error by moving the control and registering it in the page I'm curious as to why this raises an error.

这是显然是设计为设计所描述的这里(3/4下来黄色块),但我的问题是为什么呢?你可能会面临什么样的问题,通过注册在的Web.Config 控制并将其放在同一个目录?

This is apparently by design as design as described here (3/4 down in yellow block) but my question is why? What problem might you face by registering the control in the Web.Config and placing it the same directory?

推荐答案

也许这是动态编译的问题。
默认情况下,汇编元素在你的web.config中批量属性为true。事情是这样的:

Maybe it is a matter of dynamic compilation. By default the "batch" attribute of the "compilation" element in your web.config is true. Something like this :

<compilation defaultLanguage="c#" debug="false" batch="true" targetFramework="4.0" />

随着一批=真,每当控制在一个目录下进行编译,服务器在其目录编译所有控件(一切?)。

With batch="true", whenever a control has to be compiled in a directory, the server compiles all controls (everything?) in its directory.

我要说的是web.config文件中声明控件没有编译方式与其他控件一样(在另一个DLL,另一个目录?)所以,混合web.config文件中声明控件和其他控件在同一目录下,一些引用他人会导致重复编译和DLL冲突。

I would say that web.config declared controls are not compiled the same way as other controls (in another dll, another directory ?) So, mixing web.config declared controls and other controls in the same directory, some referencing the others would result in duplicate compilation and dll conflicts.

这篇关于页面Y.ascx不能使用用户控制X.ascx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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