• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1927
  • Last Modified:

VB.net ConfigurationManager not declared

Hi. In my VB.net Excel Add-in I get the error ConfigurationManager is not declared
I tried using Imports.System.Configuration.ConfigurationManager but that didn't help

         Dim sSQL As String = "Select * From Goals"
            Dim cs As String = ConfigurationManager.ConnectionStrings("task_conn").ConnectionString
0
Murray Brown
Asked:
Murray Brown
2 Solutions
 
Meir RivkinFull stack Software EngineerCommented:
just add Imports System.Configuration

and i your code reference the connectionString property by:

        Dim constring As ConnectionStringSettingsCollection = ConfigurationManager.ConnectionStrings
0
 
LIONKINGCommented:
You can add a reference to System.Configuration, that does the trick for me all the time.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
I still get errors. If I declare  constring as string I get the error  "'ConfigurationManager' is not declared"

1
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LIONKINGCommented:
Did you try adding the reference as I suggested before?
0
 
CodeCruiserCommented:
>I get the error  "'ConfigurationManager' is not declared"

Are you sure the error says ConfigurationManager is not declared?

It looks like the error is saying ConnectionStringSettingsCollection is not defined.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Adding a reference to System.Configuration did the trick
I thought that using Imports System.Configuration would be enough
but it seems that I needed to do both.
I always assumed that if you use Imports you don't have to add a reference.

Thanks for the help
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now