0
votes

First, I created a WCF service (netTcpBinding) hosted by a server application and all work fine (tested with a client application).

Then, I imported the same service class in a prism module (IModule). In the module, I create an instance of the ServiceHost by using the service class type:

public ServiceHost Host = new ServiceHost(typeof(MyService));

In the initialization step, I open the connection:

try
{
    host.Open();
}
catch (Exception ex)
{
    log.Error(ex, "SAP service starting is failed.");
    throw;
}

When I attempt to connect with a client application to the WCF service, no error is occurred: Address, binding and contract are found in the configuration file, the instance of the ServiceHost is correctly created and gets the status "opened", the socket connection is opened. From the client application, I am able to perform a call to a method of the service (no error occured to the socket opened by the server) but the service doesn't receive the call: a break point at the top of the called method is not hit during a debug session of the WCF service.

When I add a service behavior (httpGetUrl and httpGetEnabled to true) in the configuration file to get the WSDL information, the link does NOT occur any error but the page stays blank and its title keeps as information "Loading ..." (no WSDL generated).

If I move the service class and the creation of the service host to the prism executable project (.exe) which initializes the modules, the WCF service works fine !

By adding the diagnostic tools in the configuration file of the service () and by calling the "test" method, I can see the last logs:

enter image description here

enter image description here

enter image description here

Any idea ? Can we create a service host in a library project working like a prism module ? Is there any contraindications ?

1
in which configuration file do you add the service configuration? the module or the exe? what happens if you put the host in the module and the service configuration in the exe? - Haukinger
The configuration is in the ".exe.config" file and the host is in the module. - profou
have you tried putting it in the ".dll.config" file? - Haukinger
Yes, it was done but no result. - profou

1 Answers

0
votes

I've found ! But nothing linked to prism or unity.

The application set an notify icon in the right bottom of the screen. This notify icon has a context menu to finish the application. The notify icon is associated to the thread of the application.

Later, I added TopShelf to start the service. It seems that the adding of the context menu occurs a problem. I have no exception but well the problem described above. The removing of the context menu solves the issue.

There is no contraindications to define a WCF service host in a prism module. That works perfectly.