<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to get handle or instance on two different Design Files using C#</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/119713/how-to-get-handle-or-instance-on-two-different-design-files-using-c</link><description>Hi i was trying to get handle on two different Design files in C# using Marshal.GetActiveObject by Application class() = new Application but i was able to get handle only on single Design file. 
 My final out come is to synchronize these two different</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to get handle or instance on two different Design Files using C#</title><link>https://communities.bentley.com/thread/369580?ContentTypeID=1</link><pubDate>Sat, 28 May 2016 07:22:50 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:b629f56b-3c9c-4c0b-b15a-d86e64822cb7</guid><dc:creator>Jon Summers</dc:creator><description>&lt;h4&gt;&lt;span style="color:#008000;"&gt;Identify Your Platform&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Please identify the version of MicroStation, or other product such as PowerDraft, that you are using: MicroStation CONNECT or MicroStation V8&lt;em&gt;i&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The APIs supplied with MicroStation&amp;nbsp;CONNECT are different to those supplied with MicroStation&amp;nbsp;V8&lt;em&gt;i&lt;/em&gt;. Consequently, our answers are likely to be different.&lt;/p&gt;
&lt;h4&gt;&lt;span style="color:#008000;"&gt;Code Syntax Highlighting&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;When you post code, use the Forum &lt;em&gt;advanced editor&lt;/em&gt;&amp;#39;s syntax highlighting tool. That&amp;#39;s the icon that resembles a pencil:&amp;nbsp; &lt;img src="/tiny_mce/plugins/syntaxhl/img/highlight.gif" alt="Syntax Highlighter" /&gt;&lt;/p&gt;
&lt;h4&gt;&lt;span style="color:#008000;"&gt;COM&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Although you are writing an app. using C#, you are communicating with MicroStation via a COM &lt;a target="_blank" title="MSDN: InterOp" href="https://msdn.microsoft.com/en-us/library/aa645736%28v=vs.71%29.aspx"&gt;InterOp&lt;/a&gt;.&amp;nbsp; You are therefore constrained by the limitations of COM.&amp;nbsp; One of those limitations is that COM cannot distinguish difference processes of a given executable.&amp;nbsp; That is not a MicroStation issue, but a general problem with COM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get handle or instance on two different Design Files using C#</title><link>https://communities.bentley.com/thread/369579?ContentTypeID=1</link><pubDate>Sat, 28 May 2016 06:43:03 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:4cd2987e-8fca-4ca3-9170-7eb33b09582c</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Pavan Kumar,&lt;/p&gt;
&lt;p&gt;in my opinion you are trying to use GetActiveObject in a way that is in conflict with its specification. The quesion is not specific for MicroStation, but general for any OLE Automatiion development. I found pretty the same at &lt;a target="_blank" href="http://stackoverflow.com/questions/13432057/how-to-use-marshal-getactiveobject-to-get-2-instance-of-of-a-running-process-t"&gt;StackOverflow&lt;/a&gt; (including some ideas).&lt;/p&gt;
&lt;p&gt;My question is why you want to access MicroStation from external process, which is always more complicated and requires some extra effort in some situations, and don&amp;#39;t create MicroStation add-in.&lt;/p&gt;
&lt;p&gt;An regardless you acess MicroStation VBA/COM API from add-in or external process, you can use work file(s) to open and work with more design files. But it&amp;#39;s hard to say if it&amp;#39;s the right way without knowing more what do you want to achieve.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get handle or instance on two different Design Files using C#</title><link>https://communities.bentley.com/thread/369451?ContentTypeID=1</link><pubDate>Fri, 27 May 2016 06:25:28 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:eb50121c-af02-41af-9940-f3fab56eeed4</guid><dc:creator>Pavan Kumar Reddy</dc:creator><description>&lt;p&gt;I have used the following code to get handle on different design files.&lt;br /&gt; &lt;br /&gt; Bentley.Interop.MicroStationDGN.Application app;&lt;br /&gt; &lt;br /&gt; try&lt;br /&gt; {&lt;br /&gt; app = (Bentley.Interop.MicroStationDGN.Application)Marshal.GetActiveObject(&amp;quot;MicroStationDGN.Application&amp;quot;);&lt;br /&gt; }&lt;br /&gt; catch&lt;br /&gt; {&lt;br /&gt; return null;&lt;br /&gt; }&lt;br /&gt; IntPtr processID = new IntPtr(app.ProcessID);&lt;br /&gt; return app;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>