Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I'm relatively new to C#. I have created a global instance of a class MYCLASS in a project called PROJ001.exe and can successfully access the same instance from various forms within this project. I now have to call other processes from PROJ001.exe (eg PROJ002.exe, PROJ003.exe PROJ004.exe etc...). How can I access the same instance of the MYCLASS object that was created in PROJ001.exe from PROJ002.exe ?

regards
Pat
Posted

Inter process communication is a really complex topic, not really suited to beginners. As you're a beginner, you're clearly making stuff up as you code for fun, forget about this, it's really not a great avenue to go down, people in the real world almost never do this any how.

If anyone who is programming in the real world needs to do this, anonymous pipes are a good way to go. http://msdn.microsoft.com/en-us/library/bb546102.aspx[^]
 
Share this answer
 
Using Remoting and Inter-Process Communication. You can also use WCF or even go as far as rolling your own with sockets. If one of the executables loads/runs the others, then you can also load in app domains, there are a multitude of ways to do this, the best way really depends on what you are wanting to do, rather than how. IPC may be like taking a sledge hammer to a picture nail, but without more information about what you are wanting to accomplish its hard to say what to use in your situation.
 
Share this answer
 
Comments
PClarkeirl 2-Jun-13 9:21am    
Hi Ron,
Thanks for your comments. Let me give you a little more background into what I am trying to achieve. I have created a class library which contains a driver program and an instance of a class containing data relevant to the transaction I am processing. Each transaction is made up of multiple rules and I would like to be able to separate the rules into separate executables with each executable having access to the same instance of the class containing the transaction data. The reason why I need separate executables is explained below:

Within the Pharma and medical device industries there is a huge emphasis placed on software validation. This is partly because of FDA regulation and partly because of the potential of introducing errors into a process by deviating from validated processes. From a software perspective this means that before software can be used in a production environment ,it must be fully tested and validated against test scripts. This can be a long process. Once validated then the resulting exe is "licenced" for use.

If at a later stage , new logic was to be added or one piece of functionality needed to be changed , then this would means that "the one and only" executable would have to be recompiled. From an audit point of view the executable has been updated and therefore all the prior validation is no longer valid. Everything would need to be revalidated because you have no way of guaranteeing that logic has not changed. If on the other hand the new logic or altered logic was held in it's own exe then only that piece of logic would need to be re-validated.

This is why I was looking at each piece of logic or rule being an executable. That's the background and what's driven me to look at separate executables for each rules and thus the sharing of data between these executables and the data available in the calling driver program. Any advise of suggested alternatives would be welcome

regards
Pat

regards
Pat
Ron Beyer 2-Jun-13 10:10am    
The words "transactions" and "rules" to me has the flavor and sound of a database. Why not create a database that the applications all use, one inserts records into the database, the other one takes them out and processes them. That way you also have redundancy if the process were to crash for some reason, auditing, etc. When a transaction is finished you can mark it as complete and move on to the next, leaving it in the database to view later. You can use free SQLite for this and it sounds relatively easy.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900