Dipesh Bhatt
Dipesh Bhatt

Reputation: 825

Specifing Alias for dll

I have given an alias name to a dll which I am referencing from Visual studio by going to the property of that dll and specifing the alias and using the same in my code file.

extern alias toolkitalias;
using toolkitalias::System.Windows;
using toolkitalias::System.Windows.Controls;

But still it gives error saying The extern alias 'toolkitalias' was not specified in a /reference option"

Am I missing something. Please help

Upvotes: 3

Views: 3919

Answers (2)

Dipesh Bhatt
Dipesh Bhatt

Reputation: 825

I have done some research and what I found is giving alias to a dll from Visual studio doesnt work as expected and is reported as a bug.

http://connect.microsoft.com/VisualStudio/feedback/details/615953/reference-aliases-are-ignored-on-projects-containing-some-xaml-files.

Also the above solution only works in case code behind files and not in case of xaml. For xaml, what Marc suggested is correct with alias name given from visual studio property window as global,toolkitalias.

Hope it helps.

Upvotes: 3

Marc Gravell
Marc Gravell

Reputation: 1063005

You need to tell it the alias against the reference; in Solution Explorer, find the reference (under "References"), and look in the Properties window. There is an "Aliases" property that defaults to "global". Either change it to your new alias, or append (comma delimited) the alias. So you might change it to either "toolkitalias", or "global,toolkitalias".

Upvotes: 4

Related Questions