Hello,

I have an ASP.NET application that needs to call into a VB6 component
(for which I cannot modify).  This VB6 component reads a ProgId from a
configuration setting and instantiates and calls my .NET CCW object.
The problem is that when the call from the VB6 COM object to the .NET
component is made, the .NET component can no longer access the original
HttpContext.Current.

In order for the HttpContext.Current to work correctly, the returned
method call from VB6 COM trough the CCW needs to be 1) on the same
original thread and 2) has to be in the same AppDomain (?Is that right?)

At first, I didn't think about the thread issue and just noticed that
ASP.NET creates a different AppDomain for each application so my
original ASP.NET application is running in a named AppDomain, something
like /LM/W3SVC/1/Root-asdfasdfasdf.  COM Interop, on the other hand,
apparently always uses the DefaultAppDomain so when the call from VB6
COM is marshaled into the CLR that's where it gets created.

Using Remoting I successfully got my object to be created in the same
original AppDomain, but of course that did not work because Remoted
objects always incur a thread switch (?Is that right?)

I then realized that there were actually two three thread switches going
on: one between the original .NET object and the VB6 COM object, another
when the VB6 COM object calls back into .NET, and the last one between
the call from the Remoted Client to the Remoted Server component.


So my question is this: Is it possible to call from .NET to VB6 and then
back to .NET on a single thread and within the same AppDomain?

Or just as good: Is it possible to make this chain of calls without
losing security context (i.e. somehow passing the current user Id along,
or something)?  (One possibility would perhaps be to impersonate a
Windows user account that is mapped to my Application user?  Wouldn't
Windows pass this impersonated security context along every time it
created a new thread or selected a thread from the STA thread pool?)

Thanks,
Ryan

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to