为什么ASP.NET自动生成.designer code有不正确的类型? [英] Why does ASP.NET auto-generated .designer code have the incorrect type?

查看:114
本文介绍了为什么ASP.NET自动生成.designer code有不正确的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一劈到DotNetNuke的事件模块。我已经得到了源设置和它内置A-OK无需进行修改。然而,当我改变EventMonth.ascx文件时,Visual Studio更新与它相关的.designer.vb文件...并且宣布了错误类型的两个对象!它看起来是这样的:

I'm working on a hack to the DotNetNuke Events module. I've got the source set up and it built A-OK without modifications. However, when I change the EventMonth.ascx file, Visual Studio updates the .designer.vb file associated with it... and declares two objects with the wrong type! It looks like this:

Protected WithEvents EventIcons As Global.System.Web.UI.UserControl

和应该是这样的:

Protected WithEvents EventIcons As Global.DotNetNuke.Modules.Events.EventIcons

显然,这是行不通的...编译器(正确)抛出,其中EventIcons在code使用的错误。是什么原因造成的?我可以很容易地手工修复,但那么当然它只是稍后再突破。我不认为这是一个事实,即控件的ID是一样的类名,因为同样的事情发生的同一控制的另一个实例,但使用不同的名称。

Obviously, this is not going to work... the compiler (rightly) throws an error where EventIcons is used in the code. What causes this? I could easily fix it manually, but then of course it will just break again later. I don't think it is the fact that the control's ID is the same as the class name, because the same thing happens with another instance of the same control, but with a different name.

更新:好吧......我相信这一切是因为引用的用户控件无法在设计时被发现。但它显然在工作运行时:

Update: OK... I believe this is happening because the referenced user control cannot be found at design-time. But it obviously works at run-time:

<%@ Register TagPrefix="evt" TagName="Icons" Src="~/DesktopModules/Events/EventIcons.ascx" %>

这使得逻辑意义......但我想接下来的问题是在设计时有哪些呢〜决心?我想我可以改变这简单的EventIcons.ascx,它会产生code OK。但它会在运行时的工作? :|

This makes logical sense... but I guess the question then becomes "what does ~ resolve to at design-time?" I guess I can change this to simply "EventIcons.ascx" and it will generate code OK. But will it work at runtime? :|

推荐答案

由于该项目没有在应用程序根目录开始,你必须告诉项目中实际应用的根是它将能够解决之前正确。进入项目的属性的网络选项卡,并确保使用本地IIS Web服务器下的服务器头选择。设置项目的URL到URL您的特定项目(即<一href=\"http://localhost/DotNetNuke_2/DesktopModules/Events\">http://localhost/DotNetNuke_2/DesktopModules/Events).然后,检查覆盖应用程序根URL,并设置到应用程序的根URL(即的http://本地主机/的DotNetNuke%5F2 )。此将允许Web应用程序项目,知道如何找到这些控件。

Because the project doesn't start at the application root, you have to tell the project where the real application root is before it will be able to resolve the ~ correctly. Go into the Web tab of the project's properties, and make sure that "Use Local IIS Web server" is selected under the "Servers" header. Set the Project URL to the URL to your specific project (i.e. http://localhost/DotNetNuke_2/DesktopModules/Events). Then, check the Override application root URL and set that to the application's root URL (i.e. http://localhost/DotNetNuke%5F2). This will allow the web application project to know how to find those controls.

的Src 属性是相对的控制,因此它应该工作正常,只是将其设置为EventIcons.ascx,而从应用程序的根指定它。

The Src attribute is relative to the control, so it should work fine to just set it to "EventIcons.ascx" rather that specifying it from the root of the application.

这篇关于为什么ASP.NET自动生成.designer code有不正确的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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