Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

ToolWindow: Problem in reading App.config of a dll.

$
0
0

Hi,

I have a problem in Reading ConncectionString Section of App.Config of my dll.

I have gone through all the discussions related to "Config files for dlls" one here and gone for it as it is neccessary for my requirement.

My config file is as shown below

<?xml version="1.0" encoding="utf-8" ?><configuration><connectionStrings><add name="MyConn1" connectionString="ConncectionString1" providerName="System.Data.SqlClient"/><add name="MyConn2" connectionString="ConncectionString2" providerName="System.Data.SqlClient"/></connectionStrings></configuration>

and i am reading connection strings using following code (This code is part of a class in same dll).

var appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExecutingAssembly().Location);
string con=appConfig.ConnectionStrings.ConnectionStrings["MyConn1"].ToString();

It is working fine when i am testing this dll by adding it to an executable project. But it (appConfig.ConnectionStrings.ConnectionStrings["MyConn1"].ToString()) is giving null reference exception when it is  hosted to a Toolwindow (Menu command initiates this tool window).

Debugging info:

Extension location: .....\AppData\Local\Microsoft\VisualStudio\11.0Exp\Extensions\MyCompany\MyCommand\1.0

appConfig object (in above sample code): .....\AppData\Local\Microsoft\VisualStudio\11.0Exp\Extensions\MyCompany\MyCommand\1.0\Mydll.Config





Viewing all articles
Browse latest Browse all 4410


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>