Web应用程序编译错误 - ASP.NET参考

时间:2022-05-18 16:34:21

My current web app works fine locally and on live, what i am currently playing around with is compiling my Web App with the Visual Studio Option "Add Web Deployment Project" so all the code behind is compiled into DLL's.

我当前的网络应用程序在本地和现场工作正常,我目前正在玩的是使用Visual Studio选项“添加Web部署项目”编译我的Web应用程序,因此所有后面的代码都被编译成DLL。

There's is one particular build error i can not get rid off

有一个特定的构建错误我无法摆脱

Error 50 The type or namespace name 'usercontrols_calendarcell_ascx' does not exist in the namespace 'ASP' (are you missing an assembly reference?) c:\page.ascx.cs 30 1 test_deploy

错误50名称空间'ASP'中不存在类型或命名空间名称'usercontrols_calendarcell_ascx'(您是否缺少程序集引用?)c:\ page.ascx.cs 30 1 test_deploy

And the actual line of code is as follows :

实际的代码行如下:

protected ASP.usercontrols_calendarcell_ascx[] calendarCells;

5 个解决方案

#1


The problem comes from the fact that the namespace ASP is a 'pseudo' namespace, which can't be referenced when compiling.

问题来自于命名空间ASP是一个“伪”命名空间,在编译时无法引用。

The solution I found was to actually integrate the current namespace into the usercontrol definition. I adapted the names of the elements to your naming conventions, but I don't know anything about the namespace you used. Therefore I just named it 'Project.NameSpace'.

我发现的解决方案是将当前名称空间实际集成到usercontrol定义中。我根据您的命名约定调整了元素的名称,但我对您使用的命名空间一无所知。因此我将其命名为“Project.NameSpace”。

  1. In the calendarcell.ascx file:

    在calendarcell.ascx文件中:

    <%@ Control Language="C#" AutoEventWireup="true" Codefile="calendarcell.ascx.cs" Inherits="Project.NameSpace.usercontrols_calendarcell" %>

    <%@ Control Language =“C#”AutoEventWireup =“true”Codefile =“calendarcell.ascx.cs”Inherits =“Project.NameSpace.usercontrols_calendarcell”%>

  2. In the calendarcell.ascx.cs file:

    在calendarcell.ascx.cs文件中:

    namespace Project.NameSpace
    {
    public partial class usercontrols_calendarcell : System.Web.UI.UserControl
    {

    namespace Project.NameSpace {public partial class usercontrols_calendarcell:System.Web.UI.UserControl {

  3. In the page.ascx.cs file:

    在page.ascx.cs文件中:

    using Project.NameSpace;

Hope this helps. In my case it did the trick perfectly.

希望这可以帮助。在我的情况下,它完美地完成了这个技巧

#2


You can expose Control properties used on page to some interface (e.g. ICalendarCell) and place it in App_Code. Implement interface to your control and use interface in .cs file instead.

您可以将页面上使用的控件属性公开给某个接口(例如ICalendarCell)并将其放在App_Code中。实现控件的接口,改为使用.cs文件中的接口。

#3


I am guessing here, but it looks like your calendarcell user control is not compiling properly.

我在这里猜测,但看起来你的calendarcell用户控件没有正确编译。

When this happens your deployment project is probably using an old dll that does not contains that class.

发生这种情况时,您的部署项目可能正在使用不包含该类的旧dll。

Try to compile you project, and when you are able to do that with no errors compile the deployment project.

尝试编译你的项目,当你能够做到这一点没有错误编译部署项目。

#4


You need to make sure that you compile page.ascx.designer.cs as well.

您还需要确保编译page.ascx.designer.cs。

#5


Do you have it correctly referenced in in the aspx page?

你是否在aspx页面中正确引用了它?

I mean this part

我的意思是这部分

(Should be a similar tag in your aspx page and the SRC should refer to where the calendar control is.

(应该是您的aspx页面中的类似标记,SRC应该引用日历控件的位置。

#1


The problem comes from the fact that the namespace ASP is a 'pseudo' namespace, which can't be referenced when compiling.

问题来自于命名空间ASP是一个“伪”命名空间,在编译时无法引用。

The solution I found was to actually integrate the current namespace into the usercontrol definition. I adapted the names of the elements to your naming conventions, but I don't know anything about the namespace you used. Therefore I just named it 'Project.NameSpace'.

我发现的解决方案是将当前名称空间实际集成到usercontrol定义中。我根据您的命名约定调整了元素的名称,但我对您使用的命名空间一无所知。因此我将其命名为“Project.NameSpace”。

  1. In the calendarcell.ascx file:

    在calendarcell.ascx文件中:

    <%@ Control Language="C#" AutoEventWireup="true" Codefile="calendarcell.ascx.cs" Inherits="Project.NameSpace.usercontrols_calendarcell" %>

    <%@ Control Language =“C#”AutoEventWireup =“true”Codefile =“calendarcell.ascx.cs”Inherits =“Project.NameSpace.usercontrols_calendarcell”%>

  2. In the calendarcell.ascx.cs file:

    在calendarcell.ascx.cs文件中:

    namespace Project.NameSpace
    {
    public partial class usercontrols_calendarcell : System.Web.UI.UserControl
    {

    namespace Project.NameSpace {public partial class usercontrols_calendarcell:System.Web.UI.UserControl {

  3. In the page.ascx.cs file:

    在page.ascx.cs文件中:

    using Project.NameSpace;

Hope this helps. In my case it did the trick perfectly.

希望这可以帮助。在我的情况下,它完美地完成了这个技巧

#2


You can expose Control properties used on page to some interface (e.g. ICalendarCell) and place it in App_Code. Implement interface to your control and use interface in .cs file instead.

您可以将页面上使用的控件属性公开给某个接口(例如ICalendarCell)并将其放在App_Code中。实现控件的接口,改为使用.cs文件中的接口。

#3


I am guessing here, but it looks like your calendarcell user control is not compiling properly.

我在这里猜测,但看起来你的calendarcell用户控件没有正确编译。

When this happens your deployment project is probably using an old dll that does not contains that class.

发生这种情况时,您的部署项目可能正在使用不包含该类的旧dll。

Try to compile you project, and when you are able to do that with no errors compile the deployment project.

尝试编译你的项目,当你能够做到这一点没有错误编译部署项目。

#4


You need to make sure that you compile page.ascx.designer.cs as well.

您还需要确保编译page.ascx.designer.cs。

#5


Do you have it correctly referenced in in the aspx page?

你是否在aspx页面中正确引用了它?

I mean this part

我的意思是这部分

(Should be a similar tag in your aspx page and the SRC should refer to where the calendar control is.

(应该是您的aspx页面中的类似标记,SRC应该引用日历控件的位置。