Question

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

Was it helpful?

Solution

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

OTHER TIPS

Have a look at the following link:

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

This might help you.

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top