我有一个荒谬的情况(不要怪我,它是第三方软件),我需要有两个引用(Erp.Contracts.BO.Quote 和 Erp.Contracts.BO.SalesOrder),但类型是 Erp.Tablesets。 QuoteQtyRow 在两个程序集中都定义了!
如何在代码中使用它们?
void Absurdity()
{
Erp.Tablesets.QuoteQtyRow qqr_Quote = null; //<-- my intention is to use the one from the quote assembly here.
Erp.Tablesets.QuoteQtyRow qqr_SO = null; //<-- my intention is to use the one from the sales order assembly here.
}
编译器抛出错误。即:“'Erp.Tablesets.QuoteQtyRow' 类型存在于两个程序集中。”
编辑:限制:
我没有使用此答案中提供的外部别名的灵活性Class with same name in two assembly (intentionally)。我受到第三方软件提供的环境的限制。我本质上需要一种方法来区分方法的主体。
我知道我可以通过使用 dynamic 关键字完全避免这个问题,但我正在寻找一种可能的强类型解决方案。
可能没有解决方案,但我想在我放弃这个问题之前耗尽我所有的资源。