Solved

Using Web.Config via Appsettings in VB Class Library

Posted on 2011-03-16
6
644 Views
Last Modified: 2012-08-14
I'm triying to access the web config file of my application from within a class libary thats referenced in my asp.net web project.When I highlight s_url the value is empty. I should be able to do this correct? Here is the code and web config snipit.

 Try

            Dim s_url As String = System.Configuration.ConfigurationManager.AppSettings("IPMWS")
            o_ws.Url = s_url
        Catch ex As Exception
            Throw New Exception(ex.Message)

        End Try
****
Web.Config
 <applicationSettings>
        <IPMINet.My.MySettings>
            <setting name="IPMWS" serializeAs="String">
                <value>http://localhost/test_ipmws/service1.asmx</value>
            </setting>
        </IPMINet.My.MySettings>
    </applicationSettings>
0
Comment
Question by:bensonwalker
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35152519
What kind of web project are you using web application project or web site project?
might want to try changing <applicationSettings> to <appSettings>
0
 
LVL 1

Author Comment

by:bensonwalker
ID: 35152719
I guess I don't understand the question. Whats the difference between a web application project or web site project? I created it in Visual Studio 2005 as a Asp.Net Application not a Web Service
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35152796
web site projects were introduced with VS 2005 and were the default template so I think you are probably have a web site project.
<applicationSettings> tag doesn't work with web site projects you have to use <appSettings> tag instead.
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 35154767
That looks like a setting defined as part of the VB specific My.Settings feature, rather than being a standard <appSettings /> value.

Try accessing it as:
Dim s_url As String = My.Settings.IPWMS

Open in new window

0
 
LVL 1

Author Comment

by:bensonwalker
ID: 35156060
Dim s_url As String = My.Settings.IPWMS
Is not recognized at design time when added to the class library. When I created the web reference it created the entry in the web.config file for the url of the web service. It put it in the <applicationSettings> tag not <appsettings>
0
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 250 total points
ID: 35158288
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question