【问题标题】:Please specify the assembly explicitly in the type name请在类型名称中明确指定程序集
【发布时间】:2018-12-19 15:31:19
【问题描述】:

我收到了这个错误

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

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

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

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

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

我怎样才能指定两个程序集之一,同时保留我的解决方案?

【问题讨论】:

  • ReportViewerForMvc.ReportViewerWebFor, Facturacion 应该可以。

标签: c# asp.net .net-assembly


【解决方案1】:

你有两个选择:

选项 1:使用命名空间指定全名。

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

选项 2:为其中一个命名空间指定别名。

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

using Facturacion;
using MVC = ReportViewerForMvc;

这里 MVC 是 ReportViewerForMVC DLL 的别名。

那么每当你想使用来自 Facturacion 的类时,它就不会与 ReportViewerMvc.dll 发生冲突。

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

MVC.ClassName // and some other code

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-24
    • 1970-01-01
    • 1970-01-01
    • 2020-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多