The extern alias 'xxx' was not specified in a /reference option
Solution 1:
I have the same problem and I was able to reproduce the issue.
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'.
If you think this is your case as well, please vote up my bug report at Microsoft Connect.
EDIT: 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>
Solution 2:
Brian, I had the same problem as you and I figured out how to fix it.
I would do the same thing as you:
- Use the properties window to change the alias for the assembly from 'global' to 'MyAlias'
- At the top of the file where the aliased assembly is used, put extern alias MyAlias. This must be before any using statements.
- Use the alias prefix to use the namespace you want, for example using MyAlias::MyNamespace.
And I would still get the error. After screwing around a bit, I figured out that the way to fix it is to set the referenced dll to a dll that is outside of the solution you are working in. Once I did that, the error message we were both seeing went away, and I was able to continue working on my project.
I hope that helps, happy coding!
Solution 3:
An update: It is a bug. It will be fixed in .Net 4.5.
As seen on the Microsoft Connect bug report.
Solution 4:
Working for me in VS2008 using these steps:
- Use the properties window to change the alias for the assembly from 'global' to 'MyAlias'
- At the top of the file where the aliased assembly is used, put
extern alias MyAlias
. This must be before anyusing
statements. - Use the alias prefix to use the namespace you want, for example
using MyAlias::MyNamespace
.