How change application setting in class library project programmatically?

R

Ronald S. Cook

In my solution, I have a client (Windows app) and a class library. The
class library project has a connection string setting that I would like to
be able to change (from the client project ultimately).

However, when I try to change the setting programmatically, it says it can't
because it's read-only. This is not the case when I want to change a
setting in the client project.

Any idea what's up? If it matters, the class library has a .dbml file since
we're using LINQ to SQL (but I don't think that has an impact).

Basically, I want the client to be able to switch which database it's
pointing to.

Thanks for any input,
Ron
 
I

Ignacio Machin ( .NET/ C# MVP )

In my solution, I have a client (Windows app) and a class library.  The
class library project has a connection string setting that I would like to
be able to change (from the client project ultimately).

However, when I try to change the setting programmatically, it says it can't
because it's read-only.  This is not the case when I want to change a
setting in the client project.

Any idea what's up?  If it matters, the class library has a .dbml file since
we're using LINQ to SQL (but I don't think that has an impact).

Basically, I want the client to be able to switch which database it's
pointing to.

Thanks for any input,
Ron

Hi,

You can declare the connectionstring in the config of the win app and
you can access it from the dll.
 
I

Ignacio Machin ( .NET/ C# MVP )

In my solution, I have a client (Windows app) and a class library.  The
class library project has a connection string setting that I would like to
be able to change (from the client project ultimately).

However, when I try to change the setting programmatically, it says it can't
because it's read-only.  This is not the case when I want to change a
setting in the client project.

Any idea what's up?  If it matters, the class library has a .dbml file since
we're using LINQ to SQL (but I don't think that has an impact).

Basically, I want the client to be able to switch which database it's
pointing to.

Thanks for any input,
Ron

Additionally, you could create a "Init" method for the library where
you can pass the parameters that you need.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top