Frustrating Assembly Bug

G

Guest

Hi,

I recently moved the Global.asax.cs from the project root to the App_Code
folder and now I'm getting an error message

The type 'Hineynu3.Global' is ambiguous: it could come from assembly
'C:\Inetpub\wwwroot\Hineynu3\bin\Hineynu3.DLL' or from assembly
'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\hineynu3\004e4978\f1eea5ba\App_Code.3cn2kgbp.DLL'. Please specify the
assembly explicitly in the type name.


I've tried the following and nothing works:

1) I closed VS 2005, stopped the IIS service, deleted the Temporary ASP.NET
files, deleted the dll from /bin, started IIS, started VS 2005 and recompiled
the project.

2) When I remove Global.asax from the project's root I don't get this error
but the event handlers in Global.asax.cs are never called.

3) I changed Global.asax from

<%@ Application Codebehind="App_Code/Global.asax.cs"
Inherits="Hineynu3.Global" Language="C#" %>

to

<%@ Application Codebehind="App_Code/Global.asax.cs"
Inherits="global::Hineynu3.Global" Language="C#" %>

but I get a message saying it is unable to load the global class.

I have not renamed the assembly. Does anyone have any suggestions?
 
B

bruce barker

delete the temp folder:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\hineynu3\

-- bruce (sqlwork.com)
 
G

Guest

in the ASP.NET 2.0 Web Site project model, anything in the special APP_CODE
folder gets compiled automatically. As Bruce pointed out, this can often
result in double compilation and the resultant error you saw.
If you switch to the Web Application Project model, you will almost never
experience this problem. It's a standard feature as of Service Pack 1.
Peter
 
G

Guest

Hi Bruce and Peter,

Thank you for your responses! I have tried deleting the Temporary ASP.NET
Files folder and that didn't work either. As far as I know, it is using the
Web Application Project model. I have the ability to choose which files in
the folder to include/exclude in the project and the App_Code folder in
included (with a special icon). Maybe it is compiling Global.asax.cs in the
App_Code folder but not wiring the event handlers correctly? Here's the
class heirarchy in Global.asax.cs:


namespace Hineynu3
{
public class Global : System.Web.HttpApplication
{

protected void Application_AuthenticateRequest(Object sender,
EventArgs e)
{
// never called
}
}
}

--
Sincerely,

Mark Fox
 
G

Guest

Peter,

Is it necessary to include the Global.asax file in the project if the
Global.asax.cs file is in the App_Code folder? If I exclude the file, the
events in Global.asax.cs are not being raised even though it is compiled. If
I include the file, I get the ambiguous type error no matter how many times I
delete the Temporary ASP.NET Files folder and recompile. What could it be
choking on?

--
Sincerely,

Mark Fox
 
W

Walter Wang [MSFT]

Hi Mark,

Please don't use App_Code in Web Application Project:


#Migrating a VS 2005 Web Site Project to VS 2005 Web Application Project
http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx
VERY, VERY IMPORTANT: Because ASP.NET 2.0 tries to dynamically compile any
classes it finds under the /App_Code directory of an application at
runtime, you explictly *DO NOT* want to store classes that you compile as
part of your VS 2005 Web Application Project under an "app_code" folder. If
you do this, then the class will get compiled twice -- once as part of the
VS 2005 Web Application Project assembly, and then again at runtime by
ASP.NET. The result will most likely be a "could not load type" runtime
exception -- caused because you have duplicate type names in your
application. Instead, you should store your class files in any other
directory of your project other than one named "app_code". This will be
handled automatically by the "Convert to Web Applicaiton" command. This
command will rename the folder Old_App_Code.


Hope this helps.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

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/subscriptions/support/default.aspx.
==================================================

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

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,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top