SettingsProvider issue [VB.NET 2005]

S

Sid Price

I have a class that inherits from SettingsProvider to allow my application
to do some special processing that is needed on some of the settings. The
class, "VMSettingsProvider", is in a class library in a namespace "VM".
My class provides all the required methods as described in the documentation
and it compiles correctly.
To test this I have added a setting using the designer for the application
and set the provider to "VM.VMSettingsProvider", again the code generated by
the designer compiles just fine.
The problem is that when I start my application and the "Initialize" method
of my class is called it has "nothing" as the application name passed to it,
when the base class "Initialize" is called an exception (Invalid Operation -
the Value can not be null) occurs.
Do I need to do more than the steps I have described for this to work? Any
pointers to the correct approach would be much appreciated.
Sid.
 
S

Sid Price

I have found a work-around for this issue, although I am not sure why it is
necessary. The "Initialize" method I wrote looked like this:

Public Overrides Sub Initialize(ByVal name As String, ByVal config As
System.Collections.Specialized.NameValueCollection)

MyBase.Initialize(name , config)

End Sub

When I changed it to:
Public Overrides Sub Initialize(ByVal name As String, ByVal config As
System.Collections.Specialized.NameValueCollection)

MyBase.Initialize(Me.ApplicationName, config)

End Sub

the exception went away and the class library now works.
Why is this required? I would have expected the passed "name" parameter to
contain the application name.
Sid.
 

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