Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parser Error: An error occurred during the parsing of a resource requi 1

Status
Not open for further replies.

johnfrederick

Programmer
Sep 30, 2002
34
US
I’m using a book:ASP.NET Unleashed by Stephen Walther and having trouble with the examples not working. It looks like nothing in Chapters 3-9 will compile for the same reason. The following is an example. As I imported the aspx files, I asked for class modules to be created for each one. They look ok with namespace statements for all the controls. I have debug=True set, but the following is all that comes out. Help! Help!

.aspx file:

<%@ Page CodeBehind=&quot;Cancel.aspx.vb&quot; Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;ASPDOTNETUNLEASHED.Cancel&quot; %>
<html>
<head>
<title>Cancel.aspx</title></head>
<body>
<h1>Action Canceled!</h1>
</body>
</html>

Error Message:

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

Source Error:
Line 1: <%@ Page CodeBehind=&quot;Cancel.aspx.vb&quot; Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;ASPDOTNETUNLEASHED.Cancel&quot; %>Line 2: <html>Line 3: <head>

Source File: c:\inetpub\ Line: 1

Version Information
 
That error means that the application has not been compiled. Compile (or &quot;Build the Solution&quot;) the application and try again.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Thanks for assisting, link9. The error occurs when I build or rebuild. If I View in Browser, it first tries to compile and I get the error.
 
In the class file that VS created for you, is the name of the class 'Cancel'? And the name of your project, it is 'ASPDOTNETUNLEASHED'? If those two are the same, then I'd just start over, and not create the class files this time when it asks you if you want to.

It sure would be nice if these books would promote the highly superior design pattern of code-behind. But I guess that would simply be too much to ask for. I bet the book makes overuse of the session object, too, doesn't it (storing datasets, etc... in session between postbacks).

On a separate note, maybe you can return your book, and get one published by WROX. ;-)
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Thanks for your help, link9. You're clearly onto something. I reimported without asking for a class file. I got a message that there were errors in the compilation, but it went on to run, apparently correctly. Without a class file, the first directive line is: <%@ Page %>. The following is an example of the class file generated(with &quot;Inherits&quot; lines for each of the controls):

Start standard code behind file *******************************************************

Public Class Cancel
Inherits System.Web.UI.Page

#Region &quot; Web Form Designer Generated Code &quot;

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class

*****************************************************
End standard code behind file

Note that the examples in Chapters 1,2 had these same class files and worked ok. With your help, I can move on, but I'd like to understand. It looks like I may run into other problems without the class file.
 
What about your project name... What is it?

I'll explain all the different parts of that tag that threw the error -- the page directive:

Language=&quot;vb&quot; <-- pretty self explanatory

Inherits=&quot;ASPDOTNETUNLEASHED.Cancel&quot; <-- this is really the most important one. It establishes namespace and class name. This line says that your root namespace for the project should be 'ASPDOTNETUNLEASHED' (probably your project name), and that the class name is 'Cancel'

CodeBehind=&quot;Cancel.aspx.vb&quot; <-- the name of the file where it can find the class you just told it that it inherits

AutoEventWireup=&quot;false&quot; <-- This says that simply naming a method a particular way will not automatically wire the event up properly. This is a good thing. It means you have to manually wire the event yourself.

Now off the top of my head, I can only think of a few things to check:

(1) the name of your project. Is it 'ASPDOTNETUNLEASHED', as your inherits statement says that it should be
(2) if so, then your root namespace name may have gotten changed somehow. To check this, right click your project name, and ask for properties. On the General portion (which should load by default), there's a root namespace textbox. It should read 'ASPDOTNETUNLEASHED'.

If it does, then I'm flat out of ideas, and can't think of another reason why it would not be working properly.

On another side note, keep that root namespace box in mind. For most web projects, I like it, but when you start building your own class libraries, you need to wipe that box out, and set up your own namespace hierarcy. For instance, if I write some custom controls in separate projects/assemblies, then on those projects, I would wipe the root namespace, and established my own, so when I want to use them, I might just say:

using paulControls.customControls;

and then I have them right there. Project name is not in that statement. Just my own hierarchy names. Just FYI.

Hope you get it worked out.

-paul
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
I think this item can be closed. I don't understand it, but I'm back in business. I did Chapters 1,2 and when I got to 3, I imported the example code for Chaps. 3-10. When I compiled the entire project, three Chapter 6 vb code blocks for components gave compile errors. From then on, on every compile I got a message saying: Compile errors, continue? I always responded yes and for aspx files with class modules, the result was the Parser error failure. Without the class module, the aspx files would go on to compile. I deleted the three vb modules in Chapter 6 and then got clean compiles for the project. Now, all the unrelated aspx files compile correctly with class modules. If compile errors can cause compile failures in completely unrelated, correct, pages, it would seem that debugging a large project could be very difficult.
Anyway, thanks to link9 for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top