tags:

views:

452

answers:

5

Often when making changes to a VS2008 ASP.net project we get a message like:

BC30560: 'mymodule_ascx' is ambiguous in the namespace 'ASP'.

This goes away after a recompile or sometimes just waiting 10 seconds and refreshing the page.

Any way to get rid of it?

A: 

I used to have this problem sometimes too. If I remember correctly it was caused by something like the following:

<%@ Page Inherits="_Default" %>

or perhaps

<%@ Page ClassName="_Default" %>

Or something like that. I'm not 100% sure which attribute it was (it's been a while).

But look look for something like _Default in your Page directive and replace them with actual class names in all of your files. For some reason, ASP.Net doesn't always interpret the _Default correctly, yielding temporary ambiguous references.

Nathan
A: 

Another possibility:

http://channel9.msdn.com/forums/TechOff/157050-BC30560-mycontrolascx-is-ambiguous-in-the-namespace-ASP/

Seemed to have some success with changing

src="mycontrol.ascx.cs"

to

CodeBehind="mycontrol.ascx.cs"
Nathan
A: 

Similar to the two previous answers, you'll most probably have a "copy and pasted" copy of an existing page in the same site, and this will then contain the same @Page directives which will lead to a clashing of functions (especially because everything in .Net defaults to Partial Classes.) This little gem has bitten me all-too-often.

Just update the "Inherits" to point to something specific to your page (i.e.: your page name prefixed by an underscore -- as it's more-often-than-not guaranteed to be unique), and ensured that you haven't got two Public Partial Classes named the same in different code-behind files (otherwise Page_Load in _Default [default.aspx], will clash with Page_Load in _Default [copy of default.aspx])

Pat
+1  A: 

I just solved this problem with the assistance following link: http://www.netomatix.com/development/usercontrols2.aspx

In a nutshell, your class is called MyModule. However, if you do not specify the ClassName property in the @Control directive, the compiler may append _ascx to the control's class, which results in MyModule_ascx. Since the page can't find MyModule_ascx, it blows up in your face. You need to explicitly tell it the ClassName...

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MyModule.ascx.vb" ClassName="MyModule" %>
proudgeekdad
This did the trick for me. Thanks!
Anthony
A: 

I've just suffered this. Stuff that worked fine and was untouched for months started randomly failing after some unrelated updates. I'd recompile and the problem would disappear only to reappear somewhere else.

I seem to have resolved it by clearing out the ASP.NET temporary folder, e.g. C:\Windows\Microsoft.NET\Framework\v2.0.xxxxx\Temporary ASP.NET Files. This required an IIS restart to really clean it out.

Update: I tried adding tempDirectory="e:\someotherfolder" to the compilation element of the web.config and that seems to have had some success. Also added batch="false" but not sure if that's had an effect.

mrrrk