WCF service reference namespace differs from original
Posted
by Thorarin
on Stack Overflow
See other posts from Stack Overflow
or by Thorarin
Published on 2009-07-29T13:38:20Z
Indexed on
2010/05/31
9:12 UTC
Read the original article
Hit count: 284
I'm having a problem regarding namespaces used by my service references. I have a number of WCF services, say with the namespace MyCompany.Services.MyProduct
(the actual namespaces are longer).
As part of the product, I'm also providing a sample C# .NET website. This web application uses the namespace MyCompany.MyProduct
.
During initial development, the service was added as a project reference to the website and uses directly. I used a factory pattern that returns an object instance that implements MyCompany.Services.MyProduct.IMyService
. So far, so good.
Now I want to change this to use an actual service reference. After adding the reference and typing MyCompany.Services.MyProduct
in the namespace textbox, it generates classes in the namespace MyCompany.MyProduct.MyCompany.Services.MyProduct. BAD! I don't want to have to change using
directives in several places just because I'm using a proxy class. So I tried prepending the namespace with global::
, but that is not accepted.
Note that I hadn't even deleted the original assembly references yet, and "reuse types" is enabled, but no reusing was done, apparently. However, I don't want to keep the assembly references around in my sample website for it to work anyway.
The only solution I've come up with so far is setting the default namespace for my web application to MyCompany
(because it cannot be empty), and adding the service reference as Services.MyProduct
. Suppose that a customer wants to use my sample website as a starting point, and they change the default namespace to OtherCompany.Whatever
, this will obviously break my workaround.
Is there a good solution to this problem?
To summarize: I want to generate a service reference proxy in the original namespace, without referencing the assembly.
Note: I have seen this question, but there was no solution provided that is acceptable for my use case.
Edit: As John Saunders suggested, I've submitted some feedback to Microsoft about this:
Feedback item @ Microsoft Connect
© Stack Overflow or respective owner