8

When I compiled my latest asp.net program and trying to run on the test server, I am getting this error

Line 46:             Dim dependencies() As String
Line 47:             CType(Me,Global.System.Web.UI.Page).AppRelativeVirtualPath = "~/default.aspx"
Line 48:             If (Global.ASP.default_aspx.__initialized = false) Then
Line 49:                 dependencies = New String(0) {}
Line 50:                 dependencies(0) = "~/default.aspx"


Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ocbuild\c0c442ff\f0292c99\App_Web_default.aspx.cdcab7d2.4ubu1wgu.0.vb    Line: 48 

Detailed errors when I expand the compiler output...

Microsoft (R) Visual Basic Compiler version 8.0.50727.3053
for Microsoft (R) .NET Framework version 2.0.50727.3053
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ocbuild\c0c442ff\f0292c99\App_Web_default.aspx.cdcab7d2.4ubu1wgu.0.vb(48) : error BC30560: 'default_aspx' is ambiguous in the namespace 'ASP'.

            If (Global.ASP.default_aspx.__initialized = false) Then
                ~~~~~~~~~~~~~~~~~~~~~~~                            
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ocbuild\c0c442ff\f0292c99\App_Web_default.aspx.cdcab7d2.4ubu1wgu.0.vb(51) : error BC30560: 'default_aspx' is ambiguous in the namespace 'ASP'.

                Global.ASP.default_aspx.__fileDependencies = Me.GetWrappedFileDependencies(dependencies)
                ~~~~~~~~~~~~~~~~~~~~~~~                                                                 
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ocbuild\c0c442ff\f0292c99\App_Web_default.aspx.cdcab7d2.4ubu1wgu.0.vb(52) : error BC30560: 'default_aspx' is ambiguous in the namespace 'ASP'.

                Global.ASP.default_aspx.__initialized = true
                ~~~~~~~~~~~~~~~~~~~~~~~                     
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ocbuild\c0c442ff\f0292c99\App_Web_default.aspx.cdcab7d2.4ubu1wgu.0.vb(76) : error BC30560: 'default_aspx' is ambiguous in the namespace 'ASP'.

        Private Sub __BuildControlTree(ByVal __ctrl As default_aspx)
                                                       ~~~~~~~~~~~~ 
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ocbuild\c0c442ff\f0292c99\App_Web_default.aspx.cdcab7d2.4ubu1wgu.0.vb(100) : error BC30560: 'default_aspx' is ambiguous in the namespace 'ASP'.

            Me.AddWrappedFileDependencies(Global.ASP.default_aspx.__fileDependencies)
                                          ~~~~~~~~~~~~~~~~~~~~~~~                    
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ocbuild\c0c442ff\f0292c99\App_Web_default.aspx.cdcab7d2.4ubu1wgu.1.vb(31) : error BC30560: 'default_aspx' is ambiguous in the namespace 'ASP'.

            Return New ASP.default_aspx
                       ~~~~~~~~~~~~~~~~

I checked a few things and all of them turned out to be okay:

[*] Default is not defined twice anywhere

[*] Everything was working on the last release 1 week back

[*] There are no old files that are still staying with the compiled files. Also I cleared the temporary files many times.

[*] I have tried with other aspx files and all of them is giving ambiguous error (error in different source files...)

[*] The original source works just fine! only the error shows up on the compiled code.

Any ideas or any clues on how to resolve this ambiguity.

Thanks SK

Samuel
  • 1,949
  • 4
  • 18
  • 30

9 Answers9

5

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

Add this on aspx or ascx page ClassName="MyModule"

   <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MyModule.ascx.vb" ClassName="MyModule" %>
Abdul Saboor
  • 4,079
  • 2
  • 33
  • 25
  • Thank you, sir. This was a fast and simple fix. Of my 50+ user controls, only one has had this compiler issue (so far). – ps2goat Dec 31 '13 at 07:49
  • When I add the ClassName attribute to the user controls as directed I get this error "The directive contains duplicate 'classname' attributes". – Tyson Gibby Sep 11 '19 at 19:53
3

Okay here is what I found after spending three days on this problem.

Finally I figured that if I removed all the projects from the solution except one (that was causing problem) I could isolated it to default.skin. The problem seemed to be very erratic because it started going away if I deleted certain lines from this file. However, this was not consistent and the problem came and went at random.

So after losing all hopes of fixing it in the code, I decided to try it another way. I changed the option of aspnet_compiler command from -prefix switch (a dll is created for each folder) to -o (all compiled ui is put in one dll), the problem went away!!!

It seems that the problem is due to some bug in the aspnet_compiler. It got triggered in this version somehow that I could not figure out.

I am thinking of moving to more stable asp.net 3.5SP1 (or maybe wait for asp.net 4.0) any suggestions?

Samuel
  • 1,949
  • 4
  • 18
  • 30
2

I ran into this issue in consuming project when changing name/namespace of a library that consuming project referenced.

Issue is consuming project Bin folder has copy of DLL with each name/namespace name.

Deleting the consuming project Bin folder and rebuilding solved.

Brent
  • 1,378
  • 2
  • 16
  • 30
0

I solved this problem by putting the namespace above the class

Namespace yournamespace

Public Class yourclass name

end class

end Namespace
Jbryson
  • 2,875
  • 1
  • 31
  • 53
Ridwan
  • 61
  • 7
0

You need to make sure that the user control is also copied across with the page to your test server.

0

We had the same problem on out test servers. We found a duplicate of our application dll in the bin file. It's name was slightly different (missing a single "." in it) than the original dll but it contained the same types. We removed it and everything started working again.

Mertus
  • 1,145
  • 11
  • 17
0

After I checked the same items as Samuel:

[*] Default is not defined twice anywhere
[*] Everything was working on other computer 1 week back
[*] There are no old files that are still staying with the compiled files. Also I cleared the temporary files many times.
[*] I have tried with other aspx files and all of them is giving ambiguous error (error in different source files...)
[*] The original source works just fine! only the error shows up on the compiled code.
(...)

I just let my code as originaly in VS-2015 and in CMD window I executed:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_compiler -v / -p "C:\inetpub\wwwroot\projectFolder"

And every thing was running Ok without any error.

Subsequents compilations in VS-2015 environment were also Ok.

Armali
  • 18,255
  • 14
  • 57
  • 171
0

I was facing this error. I solved is this way: When create the "publish" folder to deploy the project to production environment, the visual studio compiler add this 2 files in "bin" folder:

  • App_global.asax.compiled
  • App_global.asax.dll

I just deleted, I my page works fine again. Hope this help someone too.

0

I've found that mixing Namespaces can really confuse things.

The best way to clean it up is to remove all the namespace declarations in your web project, and make sure that they're consistent in dependent projects. Don't forget to check the project properties, and the generated .designer.vb files.

Also, it sounds like you have a top-level directory named ASP - that's probably not helping things either. I'd get rid of that directory entirely, and see if that helps the problem. I did report this as a bug to MS a while back, and even provided them with a reproducible example, but never heard anything back from them.

chris
  • 36,094
  • 53
  • 157
  • 237
  • Hi! Thanks for answering, I am not sure what you mean removing the namespace declaration in the web project. Would appreciate little more clarification. The projects I am using are "web application project" and is written in C# (not sure why the aspnet_compiler error message is in vb.net!!!, maybe because they are compiled) Also I do not have any ASP folder. This seems to be the default namespace asp.net uses when it compiles. – Samuel May 22 '09 at 21:45
  • Well, the code sample above is vb, not c#, so it seems like you've got some bigger issues to resolve. But you'll find that sometimes each class definition is wrapped in a Namespace declaration - open up each vb and designer.vb (or cs/designer.cs) and remove ALL the Namespace declarations, and try rebuilding the app. – chris May 22 '09 at 22:15
  • I guess you mean that if the c# file is something like namespace mycompany.myfolder { public class myclass{ ... } } we should remove the namespace declaration? If so how can we put the classes in the namespace then? The solution has hundreds of files and many namespaces. Also everything was working in the last release about 2 weeks back... could not figure out what changed after that to cause this... – Samuel May 23 '09 at 04:34
  • Well, you could work back thru the changes from the last 2 weeks and see what's caused it (you DO use source control, right?) Or just clean up the namespace declarations in the web app - if you copied one page to another, or cut-n-pasted some code, that can cause the problem. You should be able to search the entire project for "Namespace" and just look for something that looks out of place. – chris May 23 '09 at 20:30
  • I know this is an old thread, but 'the best way...' answers are not always the best answers. Namespaces are a way to keep code organized and should have no issue compiling if used properly. In my case (same issue as the op), the compiler thought another user control had the same namespace and classname as an asp control, which was not the case. I'm not sure why it got confused, but @Abdul Saboor's answer is better and works (for .NET 4). – ps2goat Dec 31 '13 at 07:52