在外部别名'XXX'是不是在/ reference选项指定 [英] The extern alias 'xxx' was not specified in a /reference option
问题描述
我有两个组件,不幸的是定义相同类型相同的命名空间。我试图用一个 外部别名
< /一>,以解决该问题。在Visual Studio IDE中我已经设置了参考我的别名别名属性。这应该改变C#编译器命令行是这样的:
I have two assemblies that unfortunately define the same type in the same namespace. I'm trying to use a an extern alias
to work around the problem. In the Visual Studio IDE I have set the "Aliases" property of the reference to my alias. This is supposed to change the C# compiler command line to be something like this:
/reference:MyAlias=MyAssembly.dll
但它实际上并没有做到这一点。在Visual Studio IDE似乎忽略的参考别名属性设置。所以,当我去,并添加行外部别名MyAlias;
在我的C#code文件的顶部,我得到的别名是不是在/参考指定的错误选项编译。我想不出什么我做错了。任何想法?
But it doesn't actually do that. The Visual Studio IDE seems to just ignore the Aliases property setting on the reference. So when I go and add the line extern alias MyAlias;
at the top of my C# code file I get the error that the alias was not specified in a /reference option to the compiler. I can't figure out what I am doing wrong. Any ideas?
推荐答案
我也有同样的问题,我能够重现问题。
I have the same problem and I was able to reproduce the issue.
原来,参考别名含有具有了xmlns定义喜欢的xmlns输出组件XAML文件项目忽略:地方=CLR的命名空间:TestProject的。
It turns out reference aliases are ignored on projects containing xaml files which has an xmlns definition to the output assembly like xmlns:local='clr-namespace:TestProject'.
如果你觉得这是你的情况下,也请投我的<一个href="https://connect.microsoft.com/VisualStudio/feedback/details/615953/reference-aliases-are-ignored-on-projects-containing-some-xaml-files">bug在微软连接报告。
If you think this is your case as well, please vote up my bug report at Microsoft Connect.
编辑: 有一个在链接建议解决上面这需要手动编辑项目文件。为了使这项工作,我不得不放弃装配的完整路径。添加下面的说明,你的项目文件的末尾:
There is a suggested workaround in the link above which requires editing the project file manually. In order for this to work, I had to give full path of the assembly. Add the following instructions to the end of your project file:
<Target Name="solveAliasProblem" >
<ItemGroup>
<ReferencePath Remove="FullPath.dll"/>
<ReferencePath Include="FullPath.dll">
<Aliases>ourAlias</Aliases>
</ReferencePath>
</ItemGroup>
</Target>
<PropertyGroup>
<CoreCompileDependsOn>solveAliasProblem;$(PrepareResourcesDependsOn)</CoreCompileDependsOn>
</PropertyGroup>
这篇关于在外部别名'XXX'是不是在/ reference选项指定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!