Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# COM application instance issue

C# COM application instance issue

Scheduled Pinned Locked Moved C#
helpcsharpcomquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    r6yamaha
    wrote on last edited by
    #1

    Hi All, I am writing a C# application and have exposed COM interfaces. This is all working. My problem is that if I start the application from the command line and then use VB to do a createobject it seems to start another instance of the application. What I want is to get a handle to the already running instance. I have looked around for some time and have not found a solution to this. Can someone please shed some light on this? Thanks, Loren

    B 1 Reply Last reply
    0
    • R r6yamaha

      Hi All, I am writing a C# application and have exposed COM interfaces. This is all working. My problem is that if I start the application from the command line and then use VB to do a createobject it seems to start another instance of the application. What I want is to get a handle to the already running instance. I have looked around for some time and have not found a solution to this. Can someone please shed some light on this? Thanks, Loren

      B Offline
      B Offline
      Brady Kelly
      wrote on last edited by
      #2

      Do you have to start it from the command line? Why can't you use CreateObject and the new instance? VB also has a GetObject function, but your COM object has to be in the Running Object Table, and I don't know what that implies for a C# application. You could also look at Enterprise Services, i.e. COM+.

      R 1 Reply Last reply
      0
      • B Brady Kelly

        Do you have to start it from the command line? Why can't you use CreateObject and the new instance? VB also has a GetObject function, but your COM object has to be in the Running Object Table, and I don't know what that implies for a C# application. You could also look at Enterprise Services, i.e. COM+.

        R Offline
        R Offline
        r6yamaha
        wrote on last edited by
        #3

        I have an application(C#) that is running on a piece of hardware. I then have a remote user that needs to connect to this application and control it through a COM interface. I have exposed the necessary interfaces and registered it with regasm. My problem is that when the user tries to connect to it with createobject it creates another instance. If they try and use getobject it returns an error saying "runtime error 423. File name or class name not found..." Loren

        B 1 Reply Last reply
        0
        • R r6yamaha

          I have an application(C#) that is running on a piece of hardware. I then have a remote user that needs to connect to this application and control it through a COM interface. I have exposed the necessary interfaces and registered it with regasm. My problem is that when the user tries to connect to it with createobject it creates another instance. If they try and use getobject it returns an error saying "runtime error 423. File name or class name not found..." Loren

          B Offline
          B Offline
          Brady Kelly
          wrote on last edited by
          #4

          Loren, I'm afraid I don't have time right now to further investigate COM+, but if you can, what I would recommend is factoring the object required by your remote client into a separate library. Then both your C# application and the remote COM client consume the library through COM+, and there you should be able to limit the instancing of your object. I'll try and find out more, but I'm sure you can as well.

          R 1 Reply Last reply
          0
          • B Brady Kelly

            Loren, I'm afraid I don't have time right now to further investigate COM+, but if you can, what I would recommend is factoring the object required by your remote client into a separate library. Then both your C# application and the remote COM client consume the library through COM+, and there you should be able to limit the instancing of your object. I'll try and find out more, but I'm sure you can as well.

            R Offline
            R Offline
            r6yamaha
            wrote on last edited by
            #5

            Thanks Brad...I'll do some more investigating. Currently I am using CoRegisterClassObject(ref myGuid, myApp, ComAPI.CLSCTX_LOCAL_SERVER, ComAPI.REGCLS_MULTIPLEUSE, out myReg) which should have worked but is creating a new instance which generates a new windows form. Loren

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups