views:

1349

answers:

3

This is my first question on StackOverflow.com and I'm not sure if this is the correct way to do this. I found a similar question titled: Modifying the Data Source for the Strongly Typed Dataset Connection String. However, the answer provided is not working for me. I'm not able to comment on it because I don't have enough "reputation points" (again, I just signed up), and I didn't want to provide an "answer", because I don't know the correct answer.

My problem is that I need to be able to modify the connection string inside the generated myproject.dll.config file, but doing so has no effect for me at all. My library still uses the default connection string that was setup at design time. I've tried everything I know to try, but still no luck. I've tried working around the issue using multiple different approaches, but still the problem persists. I can't find any help on the internet with my specific problem either. It would be great if somebody could shed some light as to why my modified config file isn't being read.

Useful information:

  • I'm using a Strongly Typed DataSet
  • I don't know the actual connection string at design time.
  • The app.config doesn't allow me to specify a 'User' scoped connection string.
  • I'm tied to a class library (no Windows Forms)

Thank you for any help!

Luc

+1  A: 

By default, class libraries don't parse their own mylibrary.dll.config - they will use the host's config file (app.config or web.config) instead.

What you could do is check out the ConfigurationManager and see the methods for loading specific / other config files from disk (OpenMappedExeConfiguration). That way, you could probably get at your library's config settings and use them.

There are quite a few postings on using this OpenMappedExeConfiguration here on Stackoverflow or elsewhere.

Marc

marc_s
Thanks Marc. I just wanted to comment and say that the client was fine with forcing a static connection string during setup using custom action using OpenMappedEXEConfig. FTR: The dll was being used as an Excel Add-In (therefore, there was no 'hosting' .NET app / config file). Again, thanks a lot!
Luc
BTW: you could actually add a "Excel.exe.config" to your office directory and use that to specify your stuff ! :-) Try it - it worked for me (on some other unmanaged apps I extended using .NET DLLs)
marc_s
A: 

Have a look at the following link:

http://www.codeproject.com/KB/dotnet/EntLibWrapper.aspx

This might help you.

Cheers

A: 

posting removed by creator

Jakob

related questions