Solved

Using Web.Config via Appsettings in VB Class Library

Posted on 2011-03-16
6
639 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now