Search code examples
c#asp.net.net-assembly

Please specify the assembly explicitly in the type name


I'm getting this error

    "The type 'ReportViewerForMvc.ReportViewerWebForm' is ambiguous: it could come from assembly   
 'G:\Visual Studio\Projects\SantaMaria\Facturacion\bin\Facturacion.DLL' or from assembly 
  'G:\Visual Studio\Projects\SantaMaria\Facturacion\bin\ReportViewerForMvc.DLL'. Please 
  specify the assembly explicitly in the type name."

This comes from this line of code, specifically the Inherits part

<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="ReportViewerWebForm.aspx.cs" Inherits="ReportViewerForMvc.ReportViewerWebForm" %>

The thing is, while searching, all the answers tend to be to delete one of the assemblys, or things like that, and i need both of them.

What a need is a way to specify the assembly, like (i know this doesn't work) ReportViewerForMvc.ReportViewerWebFor[Facturacion.DLL] or ReportViewerForMvc.ReportViewerWebFor[ReportViewerForMvc.DLL]

How can i specify one of the two assemblys, while keeping both on my solution?


Solution

  • You have two options:

    Option 1: Specify full name with namespace.

    Facturacion.ReportViewerForMvc.ReportViewerWebForm wherever you are using this class.

    Option 2: Specify alias for one of the namespace.

    You can specify alias as shown in below example

    using Facturacion;
    using MVC = ReportViewerForMvc;
    

    Here MVC is alias for ReportViewerForMVC DLL.

    Then whenever you want to use class from Facturacion, it will not collide with ReportViewerMvc.dll.

    If you want to use any class from ReportViewerForMvc you can use it like shown below:

    MVC.ClassName // and some other code
    

    This should solve your issue.