This is solved. The sollution can be found here: Unable to initialize member through Constructor in WCF
In additon to that answer, I had to add bindings to the client. Code:
BasicHttpBinding binding1 = new BasicHttpBinding();
var cf = new ChannelFactory<IWebService>(binding1,webServiceURL);
var channel = cf.CreateChannel(new EndpointAddress(webServiceURL));
return channel;
Original Question:
I have an ASP.Net Webapplication which consumes a WCF Service.
Since both applications are using some shared libraries, I configured the Service to "reuse types in referenced assemblies".
However, If I configure the Service like this, I cannot find the Namespace the service is in, so I cannot create an instance of the class.
If I configure the Service not to reuse types in referenced assemblies, I can find the namespace & I can also create an instance. However, the Service uses automatically created objects that are copies of the objects I want to use.
That means, I would have to either :
- Manually change the reference.cs file so it uses the correct objects. Since I will have to update the service in the future, this is not a good way to go. I would have to fix the reference.cs file every time I update the service, since the class is being regenerated.
- Translate my objects to the automatically generated objects whenever I use the service.
That's also not a good idea since I would have to update the translations every time an object changes.
Steps I have taken:
- Updated from Visual Studio 2013 to 2015 since I thought (and still think) it might be a bug within VS
- Configure the service to explicitly only reuse the shared libraries. The result is the same than reusing all libraries.
- Researched stackoverflow : WP7, How to use a service reference after adding it to Visual Studio 2010 If I click "View in object browser", the service seems to be within my top level Namespace.