Strange Error - CS0012: The type x is defined in an assembly that is not referenced

前端 未结 7 1674
盖世英雄少女心
盖世英雄少女心 2020-12-09 15:28

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

I have a .NET 2.0 web application that references m

7条回答
  •  -上瘾入骨i
    2020-12-09 15:42

    I'm Mike's coworker, and we worked out a solution.

    The type X is defined in his assembly, that is only in the GAC. Even though his ASP.NET web appplication did have a reference, it was failing to load from the GAC only for this UserControl. The rest of the application worked as expected. We confirmed the failed loading by placing a copy of the assembly in the bin directory, and everything worked. We removed the assembly, and the problem came back.

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

    It looks like any time you reference a type in the page (not the code-behind), you need the assembly information defined in the web.config file or in a page directive.

    
               
    
    

提交回复
热议问题