Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody!

I am developing a .NET application with 3D graphic window for assembling 3D models (lets call it "GAPP"). I am also developing a .NET addin to a CAM application - lets call it "CAPP" (a second running process), which will need to have access to "application object" of "GAPP", because CAPP wants to use the same 3D graphic window of "GAPP" as a presenter of models created by CAPP. The "GAPP" must be independent from any external "CAM addin", and the "CAPP" can reference anything.

I am searching for the best architecture to do this task.

the common scenario will be:
the user starts GAPP, work with it and then he decides to start the CAM sw with the CAPP add-in. I dont want to restart the GAPP or have more running GAPPs.

But I dont know if this is even possible in .NET.

In COM, you have a GetObject("name") method which returns you a running COM object.

Do you have any suggestions for my problem?

Thank you!
Posted
Updated 6-Feb-13 0:50am
v2

1 solution

I would seriously question your general architecture. Isn't it much better to run it all in one process? This way, you could still execute what should be executed in parallel in different thread and synchronize them using .NET thread synchronization primitives.

First of all, please note that it does not compromise modularity of the solutions or can even improve them. Separate assemblies referencing each other and loaded by the same process make better modules than separate processes, which are well isolated. As to the synchronization of separate processes, this is quite possible, if you program these processes to participate in such collaboration. This approach has apparent drawbacks though:

  1. Synchronization creates bigger overhead in system memory usage and execution time.
  2. Synchronization objects work as different object in address spaces of a separate processes, as those address spaces are isolated. To use of identical synchronization objects in different processes requires naming of them. And it requires creation system-unique names (atoms). This is a separate hassle: you will need to guarantee uniqueness of the names and probably handle the cases when uniqueness is failed, because, due to some coincidence, some other unrelated process already created the identical atom. This way, the apparently simple approach where the assembly share some hard-coded atom names defined in some shared assembly may fail. It's pretty difficult to avoid such clashes with 100% guarantee.
  3. Support of the solutions based on such approach is more difficult.
  4. Debugging of the solution based on multiple processes is considerably more difficult than with a single-process multi-threaded solution.


Unfortunately, I am not familiar with detail of your architecture and your ultimate goals. So, I cannot advise a final solution.

Therefore, I still can imagine that the multi-process solution may be required by whatever reasons. You still can do synchronization in .NET projects. For example, let's consider the use of mutex, something which you would use in most typical cases. Please see:
http://en.wikipedia.org/wiki/Mutex[^],
http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx[^].

A light-weight unnamed mutex will not work across different process. (Going back to threads: the synchronization would require even more simple and robust device than a mutex: a lock statement, http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx[^].)

You will need to use Mutex constructors with a string parameter used to pass name. You try to create new or already existing instance of Mutex by name. An instance can already exist if some other process created one under the same name. After creation and instance, you can learn if it is new or not, from out parameter (please see two last references to the constructor help pages below). So, you will need to use on or more of the following constructors:
http://msdn.microsoft.com/en-us/library/f55ddskf.aspx[^],
http://msdn.microsoft.com/en-us/library/bwe34f1k.aspx[^],
http://msdn.microsoft.com/en-us/library/9zf2f5bz.aspx[^].

—SA
 
Share this answer
 
v2

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