Could not load type error with Asp.Net 2.0

W

werdna.sivad

I built an ASP site using the new Visual Studio 2005. The site uses a
simple master page. On my local machine everything runs just fine.
When I publish the site and FTP it to the server, it doesn't run. I
get the following error message.

Server Error in '/test2' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'MasterPage'.

Source Error:


Line 1: <%@ master language="C#" autoeventwireup="true"
inherits="MasterPage" %>
Line 2:
Line 3: <html>


Source File: /test2/MasterPage.master Line: 1


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.42

Anybody know what's going on? I am getting pretty frustrated. I have
no idea what is wrong, and nobody on the web seems to know either. And
yes, .net 2.0 is installed, as indicated in the error message.
 
G

Guest

The name you have chosen conflicts with the name of MasterPage control, try
renaming your MasterPage.Master to something else like PageTemplate or
something like that.
 
W

werdna.sivad

I build a whole new project and tried naming the masterfile
"Interface.master" instead. Same problem, here is the new error
message. I also noticed that when I created the master page file, the
default name that VS2005 tried to use was "MasterPage.master" If there
was something wrong with that filename, why would they plug it in there
for you at first?

Any other suggestions?

Server Error in '/test2' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'Interface'.

Source Error:


Line 1: <%@ master language="C#" autoeventwireup="true"
inherits="Interface" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


Source File: /test2/Interface.master Line: 1
 
J

Juan T. Llibre

You can use "MasterPage.master". That name isn't a problem.

Are you, at least, building the master page or rebuilding
the application after you create your new .master file ?

Where are you placing "MasterPage.master.cs" ?
( and/or "Interface.master.cs", in this case... )
 
S

Scott Allen

Line 1: <%@ master language="C#" autoeventwireup="true"
inherits="MasterPage" %>
Line 2:
Line 3: <html>

If you are using the inherits attribute, you probably have a CodeFile
with the class MasterPage that you inherit from. What happened to the
CodeFile attribute?
 
J

Juan T. Llibre

And that page directive should read :

<%@ Master Language="C#" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
 
W

werdna.sivad

I am not doing anything fancy. All I'm doing is using the wizard
inside VS2005. I am very very familiar with ASP 1.1 and classic ASP,
but this is my first experiment with 2.0. I am not editing the code or
doing anything manually. I'm just trying to build it and get it on the
server.

This is what I do:

1) Create new web site project.
2) Delete "default.aspx"
3) Create a master page.
4) Add "default.aspx" and assign it to the master page.
5) Build the site by selecting Build/Build Web Site - it returns no
errors.
6) Publish the site with Build/Publish - I publish it to my local
machine, so the files end up in PrecompiledWeb\mytestsite
7) FTP the entire file structure to the web server.

And that's it. When I go to the site, I get that error message. Any
questions?
 
J

Juan T. Llibre

The Page directive should be :

<%@ Master Language="C#" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

The error you posted was :
Line 1: <%@ master language="C#" autoeventwireup="true" inherits="MasterPage" %>

Notice that you did *not* have the "CodeFile" attribute set.
Did you fix that ?
 
W

werdna.sivad

It's hard to have a .cs file when you are working with a precompiled
site. The CS is not supposed to exist, that's the whole point of
asp.net. That directive DOES exist when you go look at the code. But
I'm having problems with the compiled site on distribution.
 
J

Juan T. Llibre

re:
It's hard to have a .cs file when you are working with a precompiled
site.

I didn't ask you to upload the .cs file.

However, the correct page directive must exist, so that the compiler
knows where the code-behind file for your master page file is located.

If the compiler can't find the code-behind file for your master page,
the result is *exactly* the error you've posted.

re:
That directive DOES exist when you go look at the code.

Bear with me and answer my question.

The error you posted was :
Line 1: <%@ master language="C#" autoeventwireup="true" inherits="MasterPage" %>

Notice that you did *not* have the "CodeFile" attribute set.

Your "MasterPage.master" file should have the page directive :

<%@ Master Language="C#" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

Did you fix that ?
 
%

%u

This seems to be a common problem accross all versions from what I have found on
the web. In my case, as long as the folder name that you built the application
in and folder name that you upload it to are the same, it should work. The local
folder name is the same as the project name and is created by VS. To check this
out, change the name of your local folder and you should get the same error.
Please reply if you have figured out how to resolve the problem in a better way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top