Hi,
I have a c# program which generates an ArrayList having some set of objects in it. I want to pass this ArrayList (containing a set of objects) to another program. I thought command line argument is the best best way to achieve this... But I am finding very difficult to do so.. Can any one please help me in this regard?
Thanks
Dinesh
Loading
Suthish NairPosted Mar 16, 2011, 2:02 PM
Jaganathan BantheswaranPosted Mar 15, 2011, 4:54 AM
1.Create Windows Class Library project and create the logic which you have mentioned in Program1.exe[ You can not run this project bcoz its dll type so just build it].
2.Create another Windows Forms application which implements the Program2.exe logic.
In Program2.exe project, Add the dll reference of first project into second one and include the namespace [header in C++].
Create an object of Program1.exe like,
Projectname1.ArrayContainer aContainer = new ArrayContainer(your_arraylist_to_be_passed_to_program1.exe);
aContainer.YourProgram1.exeMethodtodoSomeStuff();
DineshPosted Mar 15, 2011, 4:39 AM
Thanks for the answer.But I am still finding little difficult to digest the answer that you have explained.
Example:
I have 2 programs written and a dll having a class "ArrayContainer":
program1.exe and program2.exe.
program1.exe:
-> generates an ArrayList that contains set of objects of certain class in it.
-> Creates an object of type "ArrayContainer" (defined in the dll). This "ArrayContainer" class has a constructor accepting the ArrayList as an argument and assigns that to a Array_List variable defined inside the "ArrayContainer" class.
Program2.exe
-> This program needs the ArrayList generated by the program1.exe for further processing.
Question:
How can I access the object defined in the program1.exe in program2.exe (because, the ArrayList is been stored in the object instance created at program1.exe and as per my understanding, program2.exe requires the object instance defined in program1.exe to access the ArrayList stored in it)?
NOTE:
I am beginner to c#. Apologies if I am asking a very basic question.
Many Thanks,
Dinesh
Jaganathan BantheswaranPosted Mar 14, 2011, 7:02 AM
The another way is,
Create a separate project say ALPRO and Write a code for return your ArrayList in a Class say ArrayListClass.
Add that project dll to another project ssy Sample as reference. [ALPRO dll ]
And create an instance for that ArrayListClass and access the Method which returns the ArrayList.
VulpesPosted Mar 14, 2011, 6:57 AM
So, if your ArrayList contains nothing but strings (or these can be parsed to what you want), then this approach should work for you.