Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error being raised With COM+
Message
 
To
10/07/2001 11:17:59
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00528556
Message ID:
00529643
Views:
17
We just finished a large project building COM+ components with VFP6 SP5 and got a lots of C5 in the beginning, here is most of the causes we found causing the C5.

- Garbage collection, you need a strong garbage collection method to cleanup any object ref you may still have in memory. Any Sql Connection handles MUST also be closed in your GC.

- Declare all variables with LOCAL before using them, if you dont and then CreateObject() and store the obj ref in an undeclared var you will have C5.

- DO NOT change type of var when sending vars by ref in the component, code like this will cause a C5:
*--Client code
LOCAL lcRet, loComp
loComp = CreateobjectEx("MyComponent.MyClass", MyServer)
loComp.GetSomeValue(@lcRet)

*--Component Code: 
DEFINE CLASS MyClass As Session 
  Function GetSomeValue( rcVal ) 
     rcVal = "This is My return Value"
  EndFunc
ENDDEFINE
- Have a global ON Error active, if your code has an error in a function outside the class, On error will be used and not the class error method. If you don't have an active on error, VFP will stop processing and return an error to the client bypassing all you GC Methods.

- Always NULL Objects after you are finished using them.
- Close RecordSets Before Nulling them.
- Keep object life as short as possible on the client.
- Always call SetComplete() Or SetAbort() on Public functions. Doing this will make your components "stateless".
- Avoid at all time using WITH... ENDWITH in your error handling
- Make sure your error handling is 100% safe (Bug free).

After we followed these guidelines, we never see C5 on our components.

Hope this help because we had to find these solutions the hard way!.
Previous
Reply
Map
View

Click here to load this message in the networking platform