{"id":4366,"date":"2014-03-30T10:08:05","date_gmt":"2014-03-30T10:08:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/allowing-an-object-model-to-talk-to-two-projects-collection-of-common-programming-errors\/"},"modified":"2014-03-30T10:08:05","modified_gmt":"2014-03-30T10:08:05","slug":"allowing-an-object-model-to-talk-to-two-projects-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/allowing-an-object-model-to-talk-to-two-projects-collection-of-common-programming-errors\/","title":{"rendered":"Allowing an object model to talk to two projects-Collection of common programming errors"},"content":{"rendered":"<p>A Windows service is simply a process that normally runs outside the context of a user so it won&#8217;t help you at all.\u00a0 Web services really won&#8217;t help either as they would require that you run a web server and invoke web service methods whenever something of importance happens.\u00a0<\/p>\n<p>For cross-process calls between a managed and unmanaged application your only real choice is a COM server.\u00a0 The object model would need to reside in an outproc COM server that both applications communicate with.\u00a0 The object model could remain in .NET but you&#8217;d need to expose a COM interface.\u00a0 Through the interface you can expose COM events that are raised when important events occur.\u00a0 Complicated but not undoable.\u00a0 There are probably some other alternatives (like MSMQ or something) but most other solutions will not allow for event-style notifications.<\/p>\n<p>If both apps are in managed code then remoting would work as well.\u00a0 One of the applications creates and manages the objects while the other application uses standard .NET logic to listen for events.\u00a0 I&#8217;m not 100% sure how events work over remoting so there might be some issues with it.\u00a0 Before you brush off this option as not applicable keep in mind that you can create a C++\/CLI library that communicates between the managed class library and the unmanaged code.\u00a0 In this case the unmanaged code relies on the C++\/CLI class(es) to handle the notification process.\u00a0 As far as the unmanaged app is concerned it is a C++ class.\u00a0 The C++\/CLI class uses remoting or whatever to talk to the managed class library.<\/p>\n<p>Just for completeness I&#8217;ll also through out the option of using an intermediary system like MSMQ or SQL to actually house the data.\u00a0 In this case both applications use their own libraries to read and write the data.\u00a0 Using SQL 2005 notification infrastructure you can set up notifications for when the data changes.\u00a0 In this particular case you are emulating data sharing when in reality both processes have their own copy of the data so some disconnection will occur.<\/p>\n<p>Michael Taylor &#8211; 12\/1\/06<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Windows service is simply a process that normally runs outside the context of a user so it won&#8217;t help you at all.\u00a0 Web services really won&#8217;t help either as they would require that you run a web server and invoke web service methods whenever something of importance happens.\u00a0 For cross-process calls between a managed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4366","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4366"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4366\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}