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. ATL / WTL / STL
  4. Help creating VB6 com objects from atl service

Help creating VB6 com objects from atl service

Scheduled Pinned Locked Moved ATL / WTL / STL
c++csharpvisual-studiocom
2 Posts 1 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.
  • N Offline
    N Offline
    nalenb
    wrote on last edited by
    #1

    Hi, I created a new ATL service using vs.net 2003. In the PreMessageLoop function I create a new thread which does some work (after calling the parent PreMessageLoop method), the rest of the standard service code is unchanged. In this thread I create an instance of a CComObject which is in the same atl project using CComObject::CreateInstance(&a);. This CComObject is free threaded and I've defined free threading in stdafx.h. CoInitializeEx is properly called with multithreading. After the instance is created, a method is called on the object (A->Load()). In this method (Load) I create an CComPtr vb; object using CoCreateInstance (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER) which is an instance of a com object from a VB6 dll. When I call a method on this newest object (vb), I get a whole bunch of exception errors (First-chance exception at 0x7c57e592 in MyService.exe: Microsoft C++ exception: long @ 0x0151c7e0.) in the output window (thousands of these errors) and my code appears to be hung (it should complete the method call in about 30 seconds, but goes on for minutes before I kill it). I am checking all the hresults before this and they all succeed. However, if I put my VB6 project in debug mode, my c++ code proceeded just fine, i.e. no errors. It's the same project that created the dll used by ATL and everything is registered properly. Some other methods on this dll work properly (such as fetching the threadid) either way (debug and non-debug). Any ideas? Thanks On a related note, is it not possible to debug services in "service" mode? When I register it as a service it won't run since I think StartServiceCtrlDispatcher fails.

    N 1 Reply Last reply
    0
    • N nalenb

      Hi, I created a new ATL service using vs.net 2003. In the PreMessageLoop function I create a new thread which does some work (after calling the parent PreMessageLoop method), the rest of the standard service code is unchanged. In this thread I create an instance of a CComObject which is in the same atl project using CComObject::CreateInstance(&a);. This CComObject is free threaded and I've defined free threading in stdafx.h. CoInitializeEx is properly called with multithreading. After the instance is created, a method is called on the object (A->Load()). In this method (Load) I create an CComPtr vb; object using CoCreateInstance (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER) which is an instance of a com object from a VB6 dll. When I call a method on this newest object (vb), I get a whole bunch of exception errors (First-chance exception at 0x7c57e592 in MyService.exe: Microsoft C++ exception: long @ 0x0151c7e0.) in the output window (thousands of these errors) and my code appears to be hung (it should complete the method call in about 30 seconds, but goes on for minutes before I kill it). I am checking all the hresults before this and they all succeed. However, if I put my VB6 project in debug mode, my c++ code proceeded just fine, i.e. no errors. It's the same project that created the dll used by ATL and everything is registered properly. Some other methods on this dll work properly (such as fetching the threadid) either way (debug and non-debug). Any ideas? Thanks On a related note, is it not possible to debug services in "service" mode? When I register it as a service it won't run since I think StartServiceCtrlDispatcher fails.

      N Offline
      N Offline
      nalenb
      wrote on last edited by
      #2

      Well, upon further testing my code works just fine when the service is register and started, so I'm guessing the problem comes in when trying to run the service in debug mode in vs.net. Anyone have link on how to debug a service? It seems that just unregistering the service, compiling in debug mode and then running it doesn't work correctly. I haven't fully traced into the ATL code yet though.

      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