Passing Data Between Assemblies

M

Mythran

I have 2 assemblies (for example). Assembly A references assembly B. If I
have a value in assembly A that I want to be used in assembly B, how can I
store it so that assembly B can access it without actually "passing" the
value to assembly B?

I've seen the Threading.Thread.CurrentThread.SetNamedDataSlot method and was
wondering if that could be "safely" used to store information that would be
passed normally to just about every public method in my class (such as a
connection string).

Reason why I am not storing the Connection String inside the App.config is
it is automatically generated based on user-input. So, I would hate to have
to pass this information into the business logic layer and then into the
data access layer every time I want to access the database. I do not want
to store this information on disk or registry because it may contain
passwords which we do not want stored anywhere else but memory...

Look, I'm babbling! Anywho, thanks for the help y'all :)

Mythran
 
O

Ollie Riches

If the assemblies are in the same process (appdomain) then you can could
have a private static variable on a class and this can then be assigned at
runtime and shared between the assemblies via a class property.

If you need more information on static keyword in .Net check out:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfStaticPG.asp
http://msdn.microsoft.com/library/d...y/en-us/csref/html/vclrfCSharpKeywords_PG.asp


--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
 

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