views:

93

answers:

2

I've got 2 applications that both reference a AppTypes.dll assembly. One app is normal winforms app and the other is a web service.

I'm passing an object defined in AppTypes to my web service but I get naming conflicts because apparently the web service also defines those types after adding the service to my project. Is there any way that I can fix it or resolve the confusion that VS is having or is this normal?

+2  A: 

With the web-service proxies, you can choose the namespace when you add the web-reference, or via wsdl.exe /namespace. However, these will be separate types and you can't treat the two as the same. This often causes a lot of confusion...

If you want to share the types, consider using WCF instead of 2.0-style web-services, which allows this - both via the IDE, and via svcutil.exe /reference

Marc Gravell
+1 Thanks Marc.
SnOrfus
A: 

Well, I probably should not be answering this post because I am not sure that I fully understand your question but sometime you can get around namespace conflicts like the one I suspect you may be having by using the “global” directive.

namespace Foo
{
    class Bar
    {
    }
}

namespace Bar
{
    class Foo
    {
        static void DoIt()
        {
             // Foo.Bar x1; // This wont compile.
            global::Foo.Bar x2; // This will compile.            
        }
    }
}

The “global” directive instructs the compiler to go out and resolve “Foo” as a namespace and not as the class allowing you to eliminate naming ambiguities..

I hope I am not completely off topic here, sorry if I am.

Rene