0

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.
Community
  • 1
  • 1
Hamster
  • 1
  • 4
  • Check my answer at http://stackoverflow.com/questions/33752947/unable-to-initialize-member-through-constructor-in-wcf/33753414#33753414 It might be helpful. – Janne Matikainen Sep 19 '16 at 12:59
  • Do you include the wcf service project in the client solution? – Ross Bush Sep 19 '16 at 13:35
  • @RossBush yes, all Projects (WebApplication, Service and shared libraries) are in the same sollution – Hamster Sep 19 '16 at 14:12
  • @JanneMatikainen that worked. Thank you! I cannot mark your comment as answer. I'll update my question with your sollution... However, I had to add binding to the client... Working code: BasicHttpBinding binding1 = new BasicHttpBinding(); var cf = new ChannelFactory(binding1,webServiceURL); var channel = cf.CreateChannel(new EndpointAddress(webServiceURL)); return channel; – Hamster Sep 19 '16 at 16:01

0 Answers0