Configuration Management Application Block woes

J

Jason

Hi,

I'm trying to integrate Microsoft's Configuration Management
Application Block (CMAB), and have run into a bit of trouble. Would
appreciate any input anybody could provide at this point. I simply
keep running into exceptions when trying to integrate the block into
my app. Here's what I've done thus far:

1. Installed the CMAB
2. Started a new C# project.
3. Set a reference to the
Microsoft.ApplicationBlocks.ConfigurationManagement.dll assembly.

All clear so far. Here's where matters have gotten nasty. I simply
want to use the XML File Storage Provider, for the moment, no
encryption, nor signing. I just want to see things working. So here's
what I did next:

4. Created an XML configuration file called ConfigTest.xml:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
<TestConfigSection>
</TestConfigSection>
</configuration>

5. Added an app.config file called gilmore.exe.config file, saving it
to C:\. Within this file I placed the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="applicationConfigurationManagement"
type="System.Configuration.NameValueSectionHandler,System.Configuration,

Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"/>

<section name="TestConfigSection"
type="Microsoft.ApplicationBlocks.ConfigurationManagement.XmlHashtableSectionHandler,
Microsoft.ApplicationBlocks.ConfigurationManagement,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
</configSections>

<applicationConfigurationManagement
defaultSection="TestConfigSection">

<configSection name="TestConfigSection">

<configProvider
assembly="Microsoft.ApplicationBlocks.ConfigurationManagement,

Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"

type="Microsoft.ApplicationBlocks.ConfigurationManagement.Storage.XmlFileStorage"
path="C:\ConfigTest.xml"
refreshOnChange="true"
signed="false"
encrypted="false" />
</configSection>

</applicationConfigurationManagement>

</configuration>

The application built just fine, no errors at all. I created a very
simple form consisting of just a button. I then created an onClick
event for that button, and within the handler code I placed the
following:

ConfigurationManager.Initialize();
Hashtable tbl = new Hashtable();
tbl.Add("testkey", "testvalue");
ConfigurationManager.Write("TestConfigSection",tbl);

However, I keep getting the exception:
====
An unhandled exception of type 'System.NullReferenceException'
occurred in microsoft.applicationblocks.configurationmanagement.dll

Additional information: Object reference not set to an instance of an
object.
=====

Any ideas here??? I'm desperate!

Thanks so much,
Jason
(e-mail address removed) (remove 'hatesspam' to send me an email)
 
P

Paul Sullivan

I just struggled with this today. I have an example identical to yours
that works. When I compare my App.config to your config I see a
difference in one line and I think it is your problem.

<section name="applicationConfigurationManagement"
type="Microsoft.ApplicationBlocks.ConfigurationManagement.ConfigurationManagerSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />

Notice that the "type=" element in yours doesn't refer to anything
having to do with the Microsoft.ApplicationBlock for Configuration.
See if that helps.

Paul V. Sullivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top