468,738 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

ASP.NET 2.0: Global.asax code-behind and web deployment project problem

Hi all,
In order to solve code-behind of global.asax problem, I removed the code
from global.asax, and just leave one line "<%@ Application Language="C#"
Inherits="Global"%>" in this file. Then I created a CS file in App_Code
folder named Global.asax.cs:

public class Global : System.Web.HttpApplication {
void Application_OnError(object sender, EventArgs e) {
// my own complex error handling logic
}
}

When I debug locally, it can jump into this function whenever some error
happens.

Then I added a Web Deployment Project to my solution, and merged all DLLs
into one, I copied all my files to web server. BUT when I run the web
server, I got following error

Compiler Error Message: CS0433: The type 'ASP.global_asax' exists in both
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Tempo rary ASP.NET
Files\root\0059d51c\80906b1d\App_global.asax.gyayx cqz.dll' and
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Tempo rary ASP.NET
Files\root\0059d51c\80906b1d\assembly\dl3\3e64f089 \c486205e_fcd1c601\MyWebProject.DLL'

It seems that Web Deployment Project compiles global.asax as well, so that
there are 2 classes named "Global" existing in assemblies.

Who knows what is the solution to solve this problem? I cleared all
temporary files, it doesn't help at all.

I am mad.....

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Sep 6 '06 #1
4 8769
Hello Hardy,

From your description, I understand you're using the VS 2005 "Web
Deployment Project" add-on project to precompile an ASP.NET 2.0
application. However after the compilation and try running the precompiled
the application, you're getting type loading error against the
global.asax's codebehind class, correct?

As for this issue, based on my experience, it is related to the how the web
application is precompiled (through webdeployment project or not). Have
you configured the precompiled site to be updatable or have you configured
the web deployment project to precompile the application into multiple
assemblies?

As for the global.asax file, based on my local test, if you use "web
deployment project" to precompile the web site, the output compiled
application directory will not include the "global.asax" file in it, this
is because the global.asax is only needed by the ASP.NET runtime and after
precompilation, there will output an "App_global.asax.compiled" file in the
"bin" directory which identify the assembly which contains the class to
serve the request to global.asax. (see below)

=====================
<?xml version="1.0" encoding="utf-8"?>
<preserve resultType="8" virtualPath="/DeployWebApp/global.asax"
hash="f424386" filehash="fffff5d6110aa691" flags="150000"
assembly="DeployWebApp_deploy" type="ASP.global_asax">
<filedeps>
<filedep name="/DeployWebApp/global.asax" />
</filedeps>
</preserve>
=====================

Therefore, there should not exist "global.asax" file in the precompiled
output application's directory. Is this the case in your scenario?

Please feel free to let me know if there is anything unclear or if you have
different settings as I mentioned.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 7 '06 #2
Thanks for your reply Hardy,

Yes, the ASP.NET 2.0 percompilation has many particular settings. And those
generated files like the xxxx.precompiled is necessary , so you need to
copy them together with other assemblies in "bin" directory.

Anyway, I'm glad the suggestion has been helpful. If you need any further
help, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 7 '06 #3
Sorry, my mistake. It still doesn't work.

I try to run a fake ASPX page to trigger an (404) error to let Global.asax
to capture, it worked.

When I loaded my normal ASPX page, I had same error again.

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:9i***************@TK2MSFTNGXA01.phx.gbl...
Hello Hardy,

From your description, I understand you're using the VS 2005 "Web
Deployment Project" add-on project to precompile an ASP.NET 2.0
application. However after the compilation and try running the precompiled
the application, you're getting type loading error against the
global.asax's codebehind class, correct?

As for this issue, based on my experience, it is related to the how the
web
application is precompiled (through webdeployment project or not). Have
you configured the precompiled site to be updatable or have you configured
the web deployment project to precompile the application into multiple
assemblies?

As for the global.asax file, based on my local test, if you use "web
deployment project" to precompile the web site, the output compiled
application directory will not include the "global.asax" file in it, this
is because the global.asax is only needed by the ASP.NET runtime and after
precompilation, there will output an "App_global.asax.compiled" file in
the
"bin" directory which identify the assembly which contains the class to
serve the request to global.asax. (see below)

=====================
<?xml version="1.0" encoding="utf-8"?>
<preserve resultType="8" virtualPath="/DeployWebApp/global.asax"
hash="f424386" filehash="fffff5d6110aa691" flags="150000"
assembly="DeployWebApp_deploy" type="ASP.global_asax">
<filedeps>
<filedep name="/DeployWebApp/global.asax" />
</filedeps>
</preserve>
=====================

Therefore, there should not exist "global.asax" file in the precompiled
output application's directory. Is this the case in your scenario?

Please feel free to let me know if there is anything unclear or if you
have
different settings as I mentioned.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 7 '06 #4
Thanks for your followup Hardy,

I'm sorry to hear that the problem remains. In order to get a clear view,
is it convenient that you create a simplified project with global.asax and
some simple pages which can reproduct the error? If so, I can perform some
local test agaist them. You can touch me through the email in my
signature(by remove "online").

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by WJ | last post: by
12 posts views Thread by John M | last post: by
2 posts views Thread by Nathan Sokalski | last post: by
5 posts views Thread by Piz | last post: by
4 posts views Thread by John A Grandy | last post: by
2 posts views Thread by tshad | last post: by
1 post views Thread by Anonieko | last post: by
1 post views Thread by GaryDean | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.