How to get handle or instance on two different Design Files using C#

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 design files through Get extents and origin point and co-ordinates.

  • I have used the following code to get handle on different design files.

    Bentley.Interop.MicroStationDGN.Application app;

    try
    {
    app = (Bentley.Interop.MicroStationDGN.Application)Marshal.GetActiveObject("MicroStationDGN.Application");
    }
    catch
    {
    return null;
    }
    IntPtr processID = new IntPtr(app.ProcessID);
    return app;

  • Hi Pavan Kumar,

    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 StackOverflow (including some ideas).

    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't create MicroStation add-in.

    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's hard to say if it's the right way without knowing more what do you want to achieve.

    With regards,

     Jan

  • Identify Your Platform

    Please identify the version of MicroStation, or other product such as PowerDraft, that you are using: MicroStation CONNECT or MicroStation V8i.

    The APIs supplied with MicroStation CONNECT are different to those supplied with MicroStation V8i. Consequently, our answers are likely to be different.

    Code Syntax Highlighting

    When you post code, use the Forum advanced editor's syntax highlighting tool. That's the icon that resembles a pencil:  Syntax Highlighter

    COM

    Although you are writing an app. using C#, you are communicating with MicroStation via a COM InterOp.  You are therefore constrained by the limitations of COM.  One of those limitations is that COM cannot distinguish difference processes of a given executable.  That is not a MicroStation issue, but a general problem with COM.

     
    Regards, Jon Summers
    LA Solutions