des*_*lsj 5 c# visual-studio-2010
我的C#项目引用了两个第三方DLL.这很重要,因为这意味着我无法访问源代码,也无法修改或重新编译这两个DLL.
让我们称他们为dll A和dll B.这是dll A的样子:
namespace ThirdParty.Foo
{
public class Bar
{
...snip...
}
public class Something
{
public Bar MyProperty { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
这就是dll B的样子:
namespace ThirdParty.Foo
{
public class Bar
{
...snip...
}
public class SomethingElse
{
public Bar MyProperty { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,它们具有相同的命名空间,并且它们都定义了具有相同名称的类.我的C#代码需要引用这两个DLL.我使用的参考别名属性能够在两个引用,我也来区分extern alias firstDll,并 extern alias secondDll在我的C#文件的顶部.到现在为止还挺好.
对我来说,似乎显而易见的Something.MyProperty是firstDll.ThirdParty.Foo.Bar的类型和secondDll.ThirdParty.Foo.Bar的类型,SomethingElse.MyProperty但由于某种原因,Visual Studio会混淆并将两个属性的类型解析为同一个Bar类中的firstDll.
有没有办法让我"强制"VisualStudio来解析正确的类型?
编辑:我在Visual Studio中得到的错误是:无法将类型'ThirdParty.Foo.Bar [d:\ MySolution\References\Second.dll]'隐式转换为'ThirpParty.Foo.Bar [d:\ MySolution\References\First.dll]"
| 归档时间: |
|
| 查看次数: |
1570 次 |
| 最近记录: |