Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
COM+ component not reliable
Message
 
À
17/05/2004 17:53:56
John Fitzgerald
Kenneths Hair Salons & Day Spas,Inc.
Columbus, Ohio, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00904729
Message ID:
00905002
Vues:
18
Hi john,

Did you set ASPCOMPAT to true in the header of the page?

From Rick Strahls Whitepaper: (http://www.west-wind.com/presentations/VfpDotNetInterop/aspcominterop.asp)

Once the object has been added to your project you can access it pretty much like any other .NET object. For ASP.NET pages you'll have to do a couple of additional things to get it to run properly. Since I'm using VS.NET the actual ASP.NET page contains nothing more than the page header, while all the logic goes into a codebehind class which is a file with the .cs extension. The main thing on the ASPX page header is the PAGE directive:

<%@ Page ASPCOMPAT=true language="c#" Codebehind="ComInterop.aspx.cs" AutoEventWireup="false" Inherits="ASPInterOp.ComInterop" %>


There's another very important directive in the PAGE tag above! The ASPCOMPAT=true attribute tells the ASP.NET page that it is hosting COM components that don't conform to the ASP.NET threading model. Visual FoxPro (and Visual Basic 6) COM objects are Single Threaded Apartment (STA) objects, while .NET natively runs ASP.NET requests on MultiThreaded Appartment (MTA) threads. This requires the .NET framework to make some changes into how requests are handled by essentially switching the request into STA compatible mode. Although you can run without ASPCOMPAT=true and it appears that the COM object is operating correctly, there are subtle problems that occur such as object state not releasing between calls and objects leaking incorrect values from other instances which are caused by VFP components trying to run in the MTA environment. In short, make sure you set ASPCOMPAT=true whenever calling VFP components from ASP.Net.



ASPCOMPAT also provides compatibility to classic the ASP COM object environment by providing the appropriate Context objects that were supported to retrieve the ASP intrinsic objects in classic ASP. In particular the ObjectContext object provider which uses the COM+ IApplicationContext object interface is provided to COM objects which would otherwise not be available.



hth,
Frank Camp
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform