I have created a class library project and made a class and it has built and made the dll.
I have added the reference to this dll to a different project and added the using directive.
I can use 'new' and instanciate a class from the dll. I have even used an array of this class. All is fine when I use the data on one form.
Here is the problem. I am loading data from a file into the class in the dll - and i need it to be available from all forms in may app - how do i make it possible to see my instanciation of the class across different forms. It is currently declared (using new) on the main form of the project.
I have tried instanciating the class in a static class but that is wrong.
Loading
VulpesPosted Apr 17, 2011, 3:03 PM
To initialize the data:
Globals.Data = ......; // obtain data from class in dll
and to access it from any form;
string[] data = Globals.Data;
Richard BrennanPosted Apr 17, 2011, 5:46 PM
VulpesPosted Apr 17, 2011, 5:09 PM
I've corrected it now.
Richard BrennanPosted Apr 17, 2011, 4:55 PM
This line in static class
internal Person[] people;
causes this error
Error 1 'global.people': cannot declare instance members in a static class.
Do u want to c my code?
VulpesPosted Apr 17, 2011, 4:35 PM
internal static class Globals
{
internal static Person[] person;
}
To initialize the data:
Globals.person = ......; // obtain data from class in dll - can do this from anywhere
and to access it from any form;
Person[] _person = Globals.person;
Richard BrennanPosted Apr 17, 2011, 4:27 PM
Error 1 'global.person': cannot declare instance members in a static class C:\Users\Richard\documents\visual studio 2010\Projects\Web Spinner\Web Spinner\Global.cs 9 21 Web Spinner
public
{
static class global public Person[] person;}
Person is the dll class and I need an array of them available for many forms to acces - how can I get that working in a static class