Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transferring objects between two independed applications (C#)

is it possible to transfer a object from one application to another (in C#)?

I'm working with a CAD API. The initialization of that API takes a few seconds (10 - 15). Would be nice if I could initialize the object only once in App1 and call it up from App2 whenever I need it.

Any ideas? Thanks!

like image 250
iDog Avatar asked Feb 27 '23 06:02

iDog


2 Answers

You can do this by Serializing your object, and using any form of Interprocess Communication to transmit the data, then deserializing it on the other end.

Windows Communication Foundation is specifically suited to this type of scenario, and handles most of the plumbing for you.

like image 195
Reed Copsey Avatar answered Mar 16 '23 00:03

Reed Copsey


While Reed's suggestion is perfectly good one, it may not be the only possibility worth considering. 10-15 seconds initializing is quite a long time. It may be initializing some fairly large, complex data structures that could take quite a while to serialize and deserialize. If so, it might be worth considering another possibility, such as creating an out-of-process COM (or DCOM) server that acts as a front-end for the CAD API, and then let both App1 and App2 work with that server in one place. This would mean marshalling and unmarshalling all the data you send to/receive from the CAD API, but depending on how much data is involved and (particularly) how often you'd need to switch from its being used by App1 vs. App2, it might still have lower overhead.

like image 39
Jerry Coffin Avatar answered Mar 16 '23 00:03

Jerry Coffin