Solved

Using Web.Config via Appsettings in VB Class Library

Posted on 2011-03-16
6
647 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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