Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2004, 02:47 PM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Another perplexing problem

This is the error message I get when I log in to my web site:

Server Error in '/Production' 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 'Production.Global'.

Source Error:

Line 1: <%@ Application Codebehind="Global.asax.vb" Inherits="Production.Global" %>

Source File: <PATH>\Production\global.asax Line: 1

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


Here are the first few lines of my global.asax.vb code:

Imports System.Web
Imports System.Web.SessionState

Public Class Global
    Inherits System.Web.HttpApplication

#Region " Component Designer Generated Code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub


I have absolutely no idea how to fix it. Any suggestions would be appreciated.


 
Old September 23rd, 2004, 04:08 PM
Authorized User
 
Join Date: Jul 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your class Global must be in the Production namespace
or remove "Production." in your asax

 
Old September 23rd, 2004, 06:50 PM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you saying that this line of code

Public Class Global

should read

Production Class Global?

Quote:
quote:Originally posted by cfouquet
 Your class Global must be in the Production namespace
or remove "Production." in your asax

 
Old September 23rd, 2004, 07:06 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What they mean is this:

Namespace Production

     Public Class Global

HOWEVER! The namespace "Production" is most likely defined as the root namespace in your vb project properties. This is most likely not the problem.

Here are possible culprits:

1) You haven't compiled the codebehind
2) The binaries are not in the bin folder under your app.

Explain more about what your setup/configuration is and we might be able to figure more of it out.
 
Old September 23rd, 2004, 07:19 PM
Authorized User
 
Join Date: Jul 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok,
VB seems to behave differently from c#..

The global.asax.vb define a class called "Global"
The global.asax's Inherit="xxx" must match the fully qualified name
of the class in the global.asax.vb

The IDE seems to 'know' that the Global class fullname is Production.Global even though there is no "Namespace Production"
statement in the vb file

So make sure yourproject name is called "Production"

If you modified the project name outside the IDE,it may be out of synch.

One way to find out for sure is for you to compile your code. Go to the bin directory and use a very good tool called Reflector (http://www.aisto.com/roeder/dotnet/) to look inside the assembly.
You can find your Global class and find out its full name ("Production.Global"). If you find out it is "Test.Global" then you need to change your Inherit statement in the global.asax so it matches the full name.





 
Old September 23rd, 2004, 07:45 PM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

W2K3 Server/IIS6/SQL2K sp3a

My biggest problem is that I'm a code newbie who inherited a web site that I'm now moving to a new server. It worked on W2K/IIS5.

How do you compile the codebehind?

Quote:
quote:Originally posted by planoie
 What they mean is this:

Namespace Production

     Public Class Global

HOWEVER! The namespace "Production" is most likely defined as the root namespace in your vb project properties. This is most likely not the problem.

Here are possible culprits:

1) You haven't compiled the codebehind
2) The binaries are not in the bin folder under your app.

Explain more about what your setup/configuration is and we might be able to figure more of it out.
 
Old September 23rd, 2004, 08:24 PM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I used Reflector as you suggested but when I opened \production\bin\production.dll, I got an error that said "Unable to read beyond the end of the Stream."



Quote:
quote:Originally posted by cfouquet
 ok,
VB seems to behave differently from c#..

The global.asax.vb define a class called "Global"
The global.asax's Inherit="xxx" must match the fully qualified name
of the class in the global.asax.vb

The IDE seems to 'know' that the Global class fullname is Production.Global even though there is no "Namespace Production"
statement in the vb file

So make sure yourproject name is called "Production"

If you modified the project name outside the IDE,it may be out of synch.

One way to find out for sure is for you to compile your code. Go to the bin directory and use a very good tool called Reflector (http://www.aisto.com/roeder/dotnet/) to look inside the assembly.
You can find your Global class and find out its full name ("Production.Global"). If you find out it is "Test.Global" then you need to change your Inherit statement in the global.asax so it matches the full name.





 
Old September 23rd, 2004, 10:27 PM
Authorized User
 
Join Date: Jul 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well, it seems you have bigger pbs than just the global.asax.
find something called production.sln or production.csproj and open it with the IDE and compile it.
I recommend you get some help on site. You just can't put files hoping it is going to work...
One basic tip though. The assemblies need to be in the bin directory right under the virtual root.
Actually, ASP 2.0 will strive to just work by dropping files in. But that's another story...

 
Old September 26th, 2004, 03:55 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by cfouquet
VB seems to behave differently from c#..
...
The IDE seems to 'know' that the Global class fullname is Production.Global even though there is no "Namespace Production"
statement in the vb file
No, they behave the same. The difference is in project configuration and how the resulting code is compiled by Visual Studio.

[u]VB</u>
You can set the root namespace of your project in the project configuration. **This is not the same as setting the project name. If you change the project name, it will not change the root namespace.** Any class in your project will fall under the configured root namespace. In the situation in question, the project *should* be configured with the root namespace "Production". Then the global class that is defined in the global.asax.vb file looks like this:

Public Class Global
   ...
End Class

The resulting assembly should be "Production.dll" and the global class inside it can be referenced by "Production.Global" which is what you see in the "@ Application" directive of the global.asax.

[u]C#</u>
There is no root namespace in a C# project. There is however a default namespace. When you add a new C# item to the project, it will get the "namespace <default namespace>" line of code automatically. This then defines the namespace the class is in.

There is also a configuration setting to set the assembly name of the DLL. This, as well as the default namespace, is by default the same as the name of the project. However, like in VB, if you change the project name you'll get discrepencies. You should strive to keep all of these names, plus the namespace declaration of the classes, the same to avoid these kinds of headaches. The capability exists to create classes in different namespaces, but it breaks consistancy and could lead to confusion later on.

Once the C# assembly is compiled, the class will look exactly the same as its VB counterpart and the global.asax will reference it the same way.

Peter
-------------------------
Work smarter, not harder









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.