Amazon Ad

Saturday, 20 July 2013

Not able to create connection with app.config in Class Library project.

Hi Folks,

I was struggling to make a connection in my VB.NET windows application project from my Class Library dll which was having the connectionstring information. When i debugged it i found that the default connectionstring was coming instead of my configuration settings.

When i investigated i found the solution. The problem is App.config's setting is not visible to the .exe file. We need a mechanism to tell the exe file to take the connectionstring from the environment.

Which i did it like this

Step 1. Right click on the project (Class Library Project).

Step 2. Click on properties option.

Step 3. Select "Settings" tab.

Step 4. Create a new connection string here. i.e

a. In the name column give your connectionstring name.
b. In the type colyumn select "(connection string)".
c. In the scope column select "Application".

and save the settings.

When you have followed the above steps, It would automatically creat a new connectionstring in the app.config file. Copy the exact connectionstring name and paste it in your code where you are using connectionstring name. The name is usually like YourProjectName.Properties.Settings.ConnectionStringName.

Thats it folks the problem is solved and you can create a secure connectionstring in VB.NET or in ASP.NET.

No comments:

Post a Comment

Comments are welcome, Please join me on my Linked In account

http://in.linkedin.com/pub/ritesh-tandon/21/644/33b

How to implement Captcha v3 in ASP.NET

 I was facing an issue of dom parsing in my website. I finally resolved it by using Google Captcha V3. Step 1: Get your keys from https:...