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.
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.