简体   繁体   中英

Alias and namespace conflict in Visual Studio Designer

I have a namespace conflict between two referenced assemblies:

ie, I'm referencing Foo.A.Foo and Foo.Bar, so when I say I want Foo.Bar.Control, VS is trying to find Foo.A.Foo.Bar.Control

I can twiddle the Designer.cs code by adding new global:Foo.Bar.Control(), but as soon as I change anything, VS switches back.

I know there's something about adding aliases directly to the reference, I've tried but haven't managed to find the right combination (inline alias, using alias, reference alias).

Help?

"extern alias" may be what you mean, but I'm not sure what the designer will do with it, unfortunately...

I'm not even sure that's what you're after though - that's normally for two types from different assemblies with the same name.

You can write namespace aliases with a using directive , eg

using FooControl = Foo.Bar.Control;

but again, the designer is going to rewrite your code...

OK, this isn't the answer, but it's what I found for a workaround:

namespace FooBar
{
    class FooBarControlHack : Foo.Bar.Control { }
}

So I can do the following in the Designer.cs :

this.fooBarControl = new FooBar.FoorBarControlHack();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM