Re: "ASPCompat" attribute

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



you must use the aspcompat feature with sta com objects (all vb6 objects are sta). this is because asp.net is free threaded and does not honor sta requirements.

http://msdn2.microsoft.com/en-us/library/zwk9h2kb.aspx

asp.net web services do not support aspcompat, so you must create your own sta thread and manage calls, or follow:

http://support.microsoft.com/kb/303375

also avoid storing sta objects in session as there have been a lot of bugs with this.

-- bruce (sqlwork.com)

Sergio Martins wrote:
Hi.
I have an ActiveX DLL, developed in Visual Basic 6.0 and I need to use that DLL inside an ASP.NET application, developed in Visual Basic .Net 2003.

My problem is that in my machine I get the error "QueryInterface for interface ... failed" when I try to use same method of the ActiveX DLL. I try the same application in another machine and everything works fine. I found that if I set the "AspCompat=True" attribute in the page the application works fine in all machines.

My questions are:

1. Why the same ASP.NET application in my machine doesn’t work without the "ASPCompat" attribute and works in another machine?

2. There is same way to avoid using the "ASPCompat" attribute and have the ASP.NET application working in any machine?

3. Can anyone point me an article where Microsoft describes step-by-step how to use a Visual Basic 6.0 DLL called from an ASP.NET application? I found the article http://support.microsoft.com/kb/811658/en-us but the focus of this one is the debug and not the development of the solution.

Thanks in advance,
Sérgio Martins
.



Relevant Pages

  • Re: "ASPCompat" attribute
    ... the same scenario (ActiveX DLL and ASP.NET application) works without the ... ASPCompat attribute and in other machines don't work. ... sta requirements. ... Sergio Martins wrote: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASPCompact for Com Object.
    ... there are three types of com objects, single thread apartment model (sta), and multithread apartment model and free threaded. ... if you do not set aspcompat when using sta com objects, two concurrent requests can cause data corruption in the com object because it can not support methods being called from teo thread at the same time. ... ASp.net runs request on MTA ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Using Active Reports v1.1 via the COM Interlop
    ... run as STA (single thread apartment) you should add AspCompat attribute ... AspCompat change your page thread model so it won't run as ... Mobile: +972-58-888377 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Service using Interop wrapper fails..
    ... It appears that our windows app starts up in STA mode, ... Is there any way to force this spawing to use STA? ... > We have a C#.NET app that uses an ActiveX DLL to perform some TCP/IP ... > callback events). ...
    (microsoft.public.dotnet.framework.interop)