Custom Config Settings for CAB smart parts

Topics: CAB & Smart Client Software Factory
May 4, 2007 at 11:23 PM
Greetings all. Have been working on a CAB app and am having trouble with custom config sections etc. for individual smart parts. I can't seem to figure out how to get work item to pull custom config that works fine in standard WinForms and Web Apps. I've got custom config sections and a custom handler that works fine outside of the CAB paradigm but my work item won't grab custom settings from an app.config.

Can anyone lend some input on where I need to place config settings to have my app grab them at run time.

May 4, 2007 at 11:29 PM
Never first, ask questions later. Found CABER's informational post here. I wasn't issuing the getConfig method call correctly in code.
May 10, 2007 at 10:20 PM
Edited May 10, 2007 at 10:21 PM
So I'm still at a road block on this issue. I have a business module project that I want to have its own config file with information on service providers, data providers, etc. I've written a custom config handler to handle the my config sections and every thing runs fine in a test WinForms app.

Now, I have a "common" assembly that all projects know about ironically called "Common" that has a static factory class in it. It's job is to hand me the default service provider when I ask for it a la:

IMyCustomService _service;
_service = (IMyCustomService)ServiceProviderFactory.GetProvider("MyCustomService");

Now all is well and good in the config world except for the last line of the following code:

//Get the calling assembly codebase property into a URI so we know which module called us
//and we can get rid of the file prefix
Uri fullPath = new Uri(System.Reflection.Assembly.GetCallingAssembly().CodeBase + ".config");
//Get the local machine path to the assembly file
string finalPath = fullPath.LocalPath;
//Create a map to the desired config file and set its path
ConfigurationFileMap map = new ConfigurationFileMap(finalPath);
//Now open the config file we want to use...this gets us the business module config file
System.Configuration.Configuration config = ConfigurationManager.OpenMappedMachineConfiguration(map);
ProviderConfigSection pcs = (ProviderConfigSection)config.GetSection("myCompany/ProviderConfig");

On that last line, I get an error message as follows:
An error occurred creating the configuration section handler for myCompany/ProviderConfig: Could not load type 'MyCompany.MyApp.Common.Configuration.ProviderConfigHandler' from assembly 'MyCompany.MyApp.Common'. (C:\\mycompany\\myapp\\bin\\debug\\ui\\MyCompany.MyApp.ProgramMember.UI.DLL.config line 5)

Apparently it's not even looking in the correct assembly for my type. All projects build to the same bin and the common assembly is referenced in my Business module project (I'm using it elsewhere in the presenter).

Anybody got any System.Configuration mojo for this one?