The digital adventures of Eric Herlitz

The type ” is ambiguous: it could come from assembly ” or from assembly ”. Please specify the assembly explicitly in the type name.

Posted by trikks on August 26, 2011

Ah the good old error

You most likely seen it looking something like this

The type ‘Prometer.Objects.AnalysisEngineData’ is ambiguous: it could come from assembly ‘C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\aa63ddac\c47315b5\App_Code.8t9ff09n.DLL’ or from assembly ‘C:\Projects\Webbprojects\Prometer\bin\Prometer.DLL’. Please specify the assembly explicitly in the type name.

In short

Now there are quite a few tricks out there that suggest how to solve this. None of them shows to be correct unless you are really lucky. In general this error depend on a structural error in your Visual Studio project. That means this can be solved by either moving the file or by changing the “Build Action” from Compile to Content.

In reasonable depth

This occur when an aspx page tries to reach a class (like an objectdatasource) and tries to (or actually do) compile the class. But since it’s already compiled everything will fail.

Now in the case shown above I had put my class libraries in the App_Code directory and set the “Build Action” to “Compile” on each library. This solution works but will fail if an aspx-page tries to reach a library since it will build it’s own version of the library (stupid). Now I can solve this by leaving my files in the App_Code folder just setting the “Build Action” to “Content” instead. But other things might fail doing that.

The best option is to move the class libraries to a separate directory, in example “/Classes”. If so done remember to set the “Build Action” to “Compile”.

If in App_Code

If in /Classes

So that should be it, please not that there are no work around for this. The structure has to be correct otherwise it simply wont work.
Good luck!

7 Responses to “The type ” is ambiguous: it could come from assembly ” or from assembly ”. Please specify the assembly explicitly in the type name.”

  1. BKahuna said

    Actually, I spoke too fast. If I move my classes out of App_Code they are no longer compiled or seen. The problem is that this is a web site, not a web application. I’d be OK except I’m trying to write a .cs file in a .vb site and therefore I need it to be under app_code so I can specify it in the section of my web.config.

    • trikks said

      Websites is a different deal, I’d start by checking all included binaries in the project and see if any of them collide with the content in the app_code folder.

    • trikks said

      You could try to add this in your web.config file in the system.web section
      <add directoryName=”App_Code”/>

  2. Walter Kohl said

    >>just setting the ”Build Action” to “Content” instead<<

    Thank you! It works but I cn not understand this error. It's stupid, a day before everything works well and on the next day, I have always this error.

    CU Walter

  3. said

    thanks it works when convert it to content not compile

  4. THANK YOU sooo much… I’ve been running into this stupid problem for EVER!! And couldn’t really get anything to work but your suggection to move the classes out of the App_Code Folder worked!! Thank you again..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: