Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web App Compiling Error - ASP.NET Reference

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.

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

And the actual line of code is as follows :

protected ASP.usercontrols_calendarcell_ascx[] calendarCells;

2 Answers

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

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'.

  1. In the calendarcell.ascx file:

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

  2. In the calendarcell.ascx.cs file:

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

  3. In the page.ascx.cs file:

    using Project.NameSpace;

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

like image 111
Damian Vogel Avatar answered Jan 27 '26 15:01

Damian Vogel


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.

like image 25
Andelkos Avatar answered Jan 27 '26 15:01

Andelkos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!