accesing a forms property from a different namespace

I have a windows application that falls under the namespace MyApplication for instance. I've created a class library, which falls under the namespace MyClassLibrary that needs to access a public property of a form in MyApplication when it is passed into a class in MyClassLibrary. But MyClassLibrary doesn't recognize MyApplication namespace because I can't import it's namespace because it is an application therefore it's output is an .exe file and not a .dll... How can I access the property in MyApplication from MyClassLibrary?
Who is Participating?
nouloukConnect With a Mentor Commented:
in your app:
string message=MyClassLibrary.myfunction("Hello");

The string is setting depending on what the function returns. This is a typical language object oriented.
A library is made to work alone.
The best way to do what you want is to define a public property in your library, set or modify the property with your app and when the property changes, do the job with your library.
You can do the same with a function if you need a result:
in MyClassLibrary:
public string myfunction(string test)
return test;
in your app:
string message=MyClassLibrary.myfunction("Hello");

Hope this helps.

You can access the property of MyApplication from MyClassLibrary by either passing it to one of the methods in the myClassLibrary or u can make local variables in MyClassLibrary by passing the properties in MyApplication in to the MyClassLibrary Constructor.

In MyApplication,

public string YourLocalProperty;
MyClassLibrary newObject = new MyClassLibrary(YourLocalProperty);

In MyClassLibrary,
public MyClassLibrary(string propertyFromMyApp)
string myProperty = propertyFromMYApp;
// now use it anywhere

Or you can also create objects which will contain the values and pass it to the myclasslibrary (but the myclasslibrary should also include that class)

Hope this will be useful.
Good Luck.
dotnet22Author Commented:
One thing I forgot to mention is that not only do I need to access it, I need to change the value in the calling application...

I think access property of winform from class library project is not the proper way. Bring your property to another DLL, just like object-oriented.
All Courses

From novice to tech pro — start learning today.