Reading plugins silverlight configuration file

Oct 26, 2009 at 5:37 PM

I've a problem but i don't know if it's related to MEF or Silverlight :)

I've developed a Silverlight application that used MEF to load plugins.

This plugins used WCF services to access data and display them. It should work fine except that the configuration file (servicereference.clientconfig) is never read/access if my plugin is loaded in the application.... So my services does not work

 

Anyone get an ideas ?

 

Thx !

Oct 26, 2009 at 9:48 PM

Nobody got an idea ?

Developer
Oct 27, 2009 at 1:09 AM

Nothing jumps out at me. I would first try to eliminate MEF and construct the services manually to see if this is a Siverlight or WCF configuration issue before digging deeper into the MEF side. Once you have the WCF services working correctly then you can introduce MEF and see if the issue still occurs.

Oct 27, 2009 at 9:12 AM

Hi,

I've tested again and it appears to be related to MEF. Indeed, if you tried to create a application that has 1 plugin that access to the service, if the main application doens't contains the service Endpoint that it used by the plugin, there will be an exception when the catalog is composed because it will not found the endpoint corresponding tp the endpoint....

If I set the config file to be a resource and access this config file from the resource of the plugin, then, I can instanciate the proxy by using the value taken in the resource/config file....

 

I have a sample demo project if you want to take a look.

 

Thanks !

Developer
Oct 28, 2009 at 12:16 AM

The sample code or project will be good in order for me to help see why this isn't working when using MEF. If you can also include the manual test you did that will help me understand what is supposed to be setup for the WCF service to work.

Oct 28, 2009 at 9:51 AM
Edited Oct 28, 2009 at 10:41 AM

Hi,

 

You can find a sample here: http://cid-aa561bcdf13616e7.skydrive.live.com/self.aspx/Public/TestMEF.zip

In the file MainPage.xaml.cs from the project Module 1, you'll see that I need to access to the config file (after putting it in the resources) and then, i call the proxy by setting the binding and endpoint URI.

<font size="2">

TheService.

</font>

Service1Client client = new Service1Client(new BasicHttpBinding(), new EndpointAddress(address.Uri));

But, if I comment this line and uncomment the one which has no parameter (so which access to the config file), it throws an exception when the catalog is composed:

<font size="2">

TheService.

</font>

Service1Client client = new Service1Client();

Indeed, it looks like the main SL application configuration file need to have the endpoint information. But it's not logical: as all my plugins are independants, my main application should not have to be aware of their configuration file content...

 

I hope it's clear :)

Feel free to contact me in private if you need/want more infos: lebrun_thomas@hotmail.com(removeme)

 

Thanks !

Oct 28, 2009 at 10:45 AM

Hi ThomasLebrun,

As far as I know, the configuration file must be neither delivered with plugin DLL (via copying or updating app configuration file) or embedded into the plugin DLL as resource (as you mentioned). Your problem happens not only in SL App but also in Desktop App with such as Entity Framework, which requires the updating of connection string in the app config file whenever this string is changed elsewhere.

Hope it's helpful

Steven