请在类型名称中明确指定程序集

Please specify the assembly explicitly in the type name

我遇到了这个错误

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

这来自这行代码,特别是 Inherits 部分

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

问题是,在搜索时,所有答案往往是删除其中一个程序集或类似的东西,而我需要它们。

需要一种指定程序集的方法,例如(我知道这行不通)ReportViewerForMvc.ReportViewerWebFor[Facturacion.DLL] 或 ReportViewerForMvc.ReportViewerWebFor[ReportViewerForMvc.DLL ]

我如何指定两个程序集之一,同时将两者都保留在我的解决方案中?

您有两个选择:

选项 1:指定带有命名空间的全名。

Facturacion.ReportViewerForMvc.ReportViewerWebForm 无论你在哪里使用这个 class.

选项 2:为命名空间之一指定别名。

您可以指定别名,如下例所示

using Facturacion;
using MVC = ReportViewerForMvc;

这里 MVC 是 ReportViewerForMVC DLL 的别名。

那么无论何时你想使用 Facturacion 中的 class,它都不会与 ReportViewerMvc.dll 冲突。

如果您想使用 ReportViewerForMvc 中的任何 class,您可以如下所示使用它:

MVC.ClassName // and some other code

这应该可以解决您的问题。