How can I access the settings from the referenced assembly?

I have some values ​​(mostly constants) defined in an assembly (class library) A. I would like to use these settings in assembly B. Is there a way to do this other than that assembly A has some sort of wrapper classes around these parameters or not?

+2


source to share


4 answers


I think you can just put the values ​​into a static class in Assembly A so that you can access them from assembly B.



0


source


If the settings are read from the config file, I think you should copy them to the applications config file.



Alternatively, you can simply reference the static settings class from your assembly. It should be in the default namespace of your choice.

0


source


Remember that when you compile an assembly, the compiler is basically looking for and replacing constants. This means that if assembly A has a constant called "Foo" and assembly B, which is constant when assembly B is compiled, that string "Foo" will be compiled into assembly B. So if the constant in assembly A gets updated to " Bar ", these changes will not be reflected in build B unless recompiled.

0


source


How about using AppDomain.CurrentDomain.SetData and GetData?

then when your application fires any event in the control assembly like Close (), you synchronize the data with the build settings.

0


source







All Articles