Avatar of famcare
famcare

asked on 

The Type '...' is Ambiguous

I have recently added a new .aspx page to my Web project, it's in C#, uses a DataSet from an XSD file to grab data from Sql Server.  Project builds, runs, with no errors, until I try to access the new page, when I get the following error:
The type 'cs2dev.App_Code.DAL.DataSets.ProgressIndicatorsTableAdapters.OutcomeIndicatorTableAdapter' is ambiguous: it could come from assembly 'C:\Users\dtaylor\AppData\Local\Temp\Temporary ASP.NET Files\root\0c62f7de\15f094b3\App_Code.taf73im9.DLL' or from assembly 'C:\Users\dtaylor\Documents\Visual Studio 2010\Projects\cs2dev\cs2dev\bin\cs2dev.DLL'. Please specify the assembly explicitly in the type name.
The project has several other pages making similar calls to XSD files in this way, but only this one is encountering this ambiguity.  Any suggestions would be appreciated.  

And, yes, I have tried deleting cs2dev.dll, and I have tried deleting the contents of Temporary ASP.NET Files.  Neither of these fixed the error.  
ASP.NETC#

Avatar of undefined
Last Comment
famcare
Avatar of Gorkem Yuksel
Gorkem Yuksel
Flag of Canada image

Hi Famcare,

This is happening because you have 2 functions or methods with the same name in 2 different classes.  If you have set the USING xxxx; at the top of your code for both DLL's (classes),  it will create a conflict when compiling, since the system will not know which class to execute the function from.

Here is a quick example of what I mean:

Class file 1:
public class Class1
{
      public void DoSomething() {    }
}

Class file 2:
public class Class2
{
      public void DoSomething(){   }
}

Main Program:
Using Class1;
Using Class2;

public void ImDoingSomething()
{
     // The system will not know if you are calling the function from Class1 or Class2
    // and will cause the ambiguous error.
      DoSomething();
}


I hope this helps.

Cheers,

G.
Avatar of famcare
famcare

ASKER

Thank you, gyuksel.  Unfortunately, I don't think that's the case here - I'm not using USING, and the error is referring to a class name, not a function name.  What's more, it's an autogenerated class created by the DataSource.  I am referencing it directly, and using a qualified path name when I do:

            DataSets.ProgressIndicatorsTableAdapters.OutcomeIndicatorTableAdapter adapter = new DataSets.ProgressIndicatorsTableAdapters.OutcomeIndicatorTableAdapter();
            adapter.ClearLinks();

Also, this is not a compiler error - the code is compiling fine.  This happens when I try to access the page in the browser.

From what I can tell, the error is occurring because a similar class definition is showing up in my Temporary ASP.NET Files folder every time it compiles.  I've tried deleting it, but it keeps reappearing.  Any ideas as to how I can prevent this?
Avatar of ToddBeaulieu
ToddBeaulieu
Flag of United States of America image

Since your question is still open, I figured I'd at least try to help. Somehow you seem to be referencing two similar assemblies.

You can't specify the path that an assembly is loaded by web.config. The current folder is searched, then subfolders and then the GAC. Take a look at the references in that file.

In the project itself, you CAN specify the location of the assembly. I suspect you have THAT reference pointing somewhere explicitly and then somehow both are being copied into the bin folder.

Do you have multiple projects in the solution? If one of the projects is referencing the other copy, it will be brought along. Have you looked at the bin (output) after a clean/rebuild to see exactly what's in there? Are the refences set to 'copy local' or not?

Good luck.
Avatar of famcare
famcare

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for famcare's comment http:/Q_27196720.html#36191321

for the following reason:

a
Avatar of famcare
famcare

ASKER

q
ASKER CERTIFIED SOLUTION
Avatar of famcare
famcare

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of famcare
famcare

ASKER

objecting to close request
Avatar of famcare
famcare

ASKER

... so I can close it myself.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo