After converting a Asp.net website to web application, I receive 'Type MyNameSpace.MyMaster is not defined' error on pages that use the MasterType directive.
eg In the aspx file
<%@ MasterType VirtualPath="~/MyMaster.master" %>
In the designer.vb file the following code is generated and has the error described above:
Public Shadows ReadOnly Property Master() As MyNameSpace.MyMaster
Get
Return CType(MyBase.Master, MyNameSpace.MyMaster)
End Get
End Property
If I remove the namespace the error goes away but this code is regenerated every time I make a change to the aspx page.
If I use TypeName without the namespace(eg Typename="MyMaster") instead of VirtualPath in the directive, the code is generated without the namespace reference and therefore no error. However this fails at runtime instead. Including the namespace behaves in the same way as using the VirtualPath.
I am pretty sure this has something to do with the conversion process as new web application projects do not have this problem.
Any ideas what is going on here?
UPDATE:
Problem Solved!
In the conversion process I had added a Namespace with the same name as my root Namespace to a class. Simply removed that to fix the problem.
You could namespace your masterpage class. Namespaces are created by default in web app projects.
namespace TestNS
{
public partial class TestMP : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Read this to find out about any other gotchas:
http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With