Design Question - Processing .NET App Config at DLL Level

I have an existing platform based on .NET 3.5 that expands with custom plugins. In the final plug-ins, a common interface is implemented, and the main framework calls them through reflection. The frame works fine, and everything is fine, however ...

Now I have a requirement that requires a plugin that communicates with the WCF service. At face value it is simple, add the service link to the plugin, call the client proxy code and release. However...

Due to the fact that the .NET configuration works, the WCF service client configuration must be located in the app.config of the executable application. In this case, it is a plug-in application. The problem is that it breaks down the "model" of the plugin, since the general invoker application should now have a specific plugin configuration inside it.

So, the question is, does anyone know of an alternative mechanism for processing the client configuration of a WCF service without putting it in the configuration of the kernel hub application?

After a little hunting, there are mechanisms that allow the DLL to use its own configuration file . The problem here is that I do not have access to the underscore code for creating the service proxy, and therefore it does not seem to be able to redirect the configs.

+6
source share
2 answers

Answering my own question:

It seems I found a solution to the problem here:

http://weblogs.asp.net/cibrax/archive/2007/10/19/loading-the-wcf-configuration-from-different-files-on-the-client-side.aspx

In short, this allows you to specify a custom configuration file that contains the WCF configuration, since it is generated by Visual Studio - this means that the configuration can be easily saved.

By running a few quick tests, it seems that it works as it should (with some changes here and there (see comments on the page).

0
source

The WCF client endpoint can also be configured programmatically .

Here is an example that shows how to call the WCF service without the need for a configuration file:

var myBinding = new BasicHttpBinding(); var myEndpoint = new EndpointAddress("http://localhost/myservice"); var client = new MyServiceClient(myBinding, myEndpoint); try { client.MyServiceOperation(); client.Close(); } catch { if (client != null) { client.Abort(); } } 

Related Resources:

+1
source

Source: https://habr.com/ru/post/890544/


All Articles