This has been sitting in my Drafts folder for a little while, but I'll go ahead and send it since it just in case anyone is interested because it contains the solution to my previous question.
Patrick, thanks for pointing to AspCompat. I'm actually using a WebService so I couldn't just include the attribute at the top of my page. Instead, I implemented a custom HttpHandler which implements IHttpAsyncHanlder and calls AspCompatBeginProcessRequest directly. Before: 1. JavaScript in browser 1.1 -> ASP.NET Web Service (SID: NETWORK SERVICE, PID: 1) 1.1.1 -> VB COM (SID: IUSR, PID: 2) 1.1.1.1 -> .NET CCW 1 (SID: NETWORK SERVICE, PID: 3, different AppDomain) 1.1.1.2 -> .NET CCW 2 (SID: NETWORK SERVICE, PID: 4, different AppDomain) 1.1.1.2.1 -> VB COM (SID: IUSR, PID: 5) After implementing IHttpAsyncHanlder and calling AspCompatBeginProcessRequest directly: 1. JavaScript in browser 1.1 -> ASP.NET Web Service (SID: NETWORK SERVICE, PID: 1) 1.1.1 -> VB COM (SID: IUSR, PID: 1) 1.1.1.1 -> .NET CCW 1 (SID: NETWORK SERVICE, PID: 1, same AppDomain) 1.1.1.2 -> .NET CCW 2 (SID: NETWORK SERVICE, PID: 1, same AppDomain) 1.1.1.2.1 -> VB COM (SID: IUSR, PID: 1) After that I was still getting a problem, however, with database calls from inside the VB component. The NETWORK SERVICE impersonation was not being passed from .NET to COM and since IUSR connects across the network as a null session, the database calls were failing. I fixed this by changing <identity impersonate="false" /> in my web.config. So now I get what I want: 1. JavaScript in browser 1.1 -> ASP.NET Web Service (SID: NETWORK SERVICE, PID: 1) 1.1.1 -> VB COM (SID: NETWORK SERVICE, PID: 1) 1.1.1.1 -> .NET CCW 1 (SID: NETWORK SERVICE, PID: 1, same AppDomain) 1.1.1.2 -> .NET CCW 2 (SID: NETWORK SERVICE, PID: 1, same AppDomain) 1.1.1.2.1 -> VB COM (SID: NETWORK SERVICE, PID: 1) -Ryan -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Patrick Steele Sent: Saturday, October 21, 2006 10:54 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] ASP.NET calling into VB COM loses applicatoin-user context I'm not sure this will be of much help but are you using the AspCompat attribute on the ASP.NET Page? -- Patrick Steele http://weblogs.asp.net/psteele -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Ryan Parlee Sent: Friday, October 20, 2006 6:58 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] ASP.NET calling into VB COM loses applicatoin-user context 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? =================================== This list is hosted by DevelopMentorR http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com