Strange Error - CS0012: Type x is defined in an assembly not referenced

The type 'x' is defined in an assembly that is not referenced. You must add a reference to the assembly 'abc123'.

I have a .NET 2.0 web application that references my assembly 'abc123'. The assembly exists in the GAC, and I checked that it is the correct (same) version. The rest of the application has no problems except one .aspx page. There is a repeater on the page in question, which displays the user control as one of its โ€œfieldsโ€. After binding the list of type y to the repeater, I give the user control of type x (property y), as shown here:

<uc1:usercontrol id="ucusercontrol " runat="server" myPublicUserControlProperty='<%#Eval("CollectionOfX") %>'/> 

In the custom item property set, I bind a list of type x to the gridview in the user control.

It is strange to note that this report works fine on my development computer, but not on any servers after deployment. My computer is Windows XP, IIS6, VS2005. Servers are Windows Server 2003, IIS6.

I hope I explained it quite well. Thanks in advance for any information you can provide.

+28
wpf user-controls assemblies repeater
Nov 12 '08 at 16:09
source share
6 answers

I am a Mike colleague and we have developed a solution.

Type X is defined in its assembly, that is, only in the GAC. Although there was a link in his ASP.NET web application, it did not load from the GAC just for that UserControl. The rest of the application worked properly. We confirmed a failed boot by placing a copy of the assembly in the bin directory, and everything worked. We removed the assembly and the problem returned.

Our solution was to manually add the entry in web.config to the build section to point ASP.NET to the GAC.

It seems that whenever you refer to the page type (and not the code), you need the assembly information defined in the web.config file or in the page directive.

 <assemblies> <add assembly="MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=[MyPublicKeyToken]"/> </assemblies> 
+27
Nov 12 '08 at 19:32
source share

Fusion Log Viewer has always been a big help in resolving these issues.

+3
Nov 12 '08 at 16:27
source share

There is also an error that can occur with similar symptoms, described here .

The workaround is to delete everything in the C: \ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files \ directory and apparently appears in debug mode.

+3
Feb 12 '09 at 1:47
source share

I found that if type x is actually a class in your App_Code , fouling and re-saving often force the web application to recompile and fix the problem.

+1
Mar 02 '12 at 11:01
source share

I had the same error, but I had a public constructor in my class that was used as a parameter, an object from another project.

I solved the problem by making this constructor internal.

0
Feb 16 2018-11-11T00:
source share

This is most often due to cached assemblies. One way to solve this problem is to make a "strong link" in the proj or config file. Post this blog post

0
Mar 07 '11 at 2:00
source share



All Articles