|
-
Aug 2nd, 2005, 04:15 PM
#1
Customizing Web.Config
I am trying to add custom nodes to my web.config file and I am running into a few issues. It looks something like this:
VB Code:
<configuration>
<configSections>
<section name="MySection" type="MySectionHandler"/>
</configSections>
<MySection>
<CustomNode>1</CustomNode>
<CustomNode>2</CustomNode>
<CustomNode>3</CustomNode>
<CustomNode>4</CustomNode>
</MySection>
...
</configuration>
Then I have the code for mysectionhandler as follows:
VB Code:
Public Class MySectionHandler
Implements IConfigurationSectionHandler
Public Function Create(ByVal parent As Object, ByVal configContext As Object, ByVal section As System.Xml.XmlNode) As Object Implements System.Configuration.IConfigurationSectionHandler.Create
Return "HELLO"
End Function
End Class
Finally, I have my code that trys to display the values:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = ConfigurationSettings.GetConfig("MySection")
End Sub
I am getting an error on the Configuration.GetConfig line. The error I am getting is:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Exception creating section handler.
It and it highlights the <section name="MySection" type="MySectionHandler"/> line in the Web.Config file.
Anyone seen this before, or can anyone offer any suggestions?
-
Aug 2nd, 2005, 04:34 PM
#2
Re: Customizing Web.Config
Just a guess since this is an ASP.NET question...
Dont you need a space before the escape char?
VB Code:
<section name="MySection" type="MySectionHandler"/>
<section name="MySection" type="MySectionHandler" />
???
Also, is that the complete xml heirachy for your section?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 2nd, 2005, 04:48 PM
#3
Re: Customizing Web.Config
Thanks for the response Rob, but I figured it out. It actually requires the fully qualified name of the object to be created:
<section name="MySection" type="webconfigtest.MySectionHandler,webconfigtest"/>
I changed it and it works.
-
Aug 2nd, 2005, 04:57 PM
#4
Re: Customizing Web.Config
Cool! Always good to learn something new. Thanks. 
Ps, now since you solved it yourself you need to give yourself a Rep. jk
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2005, 02:21 PM
#5
Fanatic Member
Re: Customizing Web.Config
Hi Guys
Sorry for extending this disucssion but I was looking for a similar solution but in a VB.NET application. Based on your sample <section name="MySection" type="webconfigtest.MySectionHandler,webconfigtest"/> it would appear that webconfigtest is a DLL. I am writing an executable, say vbtest.exe, and wanted to include the Section handler within the same application so I set my section entry as
Code:
<section name="MySection" type="MySectionHandler" />
but I get an error while retrieving the section data.
I would like to know if the customer section handler class should necessarily be in a seperate DLL?
Thanks for your help.
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Aug 3rd, 2005, 03:29 PM
#6
Re: Customizing Web.Config
It doesn't require a separate DLL, however it does require the full name of the object. It is probably ProjectName.Classname in the case of the class in your executable.
-
Aug 4th, 2005, 02:18 PM
#7
Fanatic Member
Re: Customizing Web.Config
Thanks Negative0. It works. I tried
VB Code:
<section name="articlesVB" type="VBNetLab.CustomTagHandler, VBNetLab" />
and it worked. So it would appear that the type part should be something like this:
VB Code:
type="Assembyname.ClassName, AssemblyName"
where Assembly name is the name of the executable.
Thanks
Last edited by Mr.No; Aug 22nd, 2005 at 02:36 PM.
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|