Title: COM Dos and Donts Krishna Kumar Parthasarathy Sulabh Shrivastava Support Engineer Developer Support
1COM Dos and DontsKrishna Kumar
ParthasarathySulabh ShrivastavaSupport
EngineerDeveloper Support COMMicrosoft
Corporation
2Best PracticesWhat to do
- Unattended Execution and Retain in Memory
should be enabled for all Visual Basic
components - Object marked as both threading model should be a
thread-safe component - Design your test environment so that it is close
to your production environment - Use object pooling if components are expensive to
create
3Best Practices (2)What to do
- Make sure Identity is set to THIS USER in
production environment - COM talking to Oracle database should follow the
information in KB article Q193893http//support.
microsoft.com/support/kb/articles/q193/8/93.asp - Close and release your ADO objects as soon as
possible
(Note that the URL above should be entered as one
line it is wrapped here for readability.)
4Best Practices (3)What to do
- Use XML or disconnected recordset to send data
back to client - If multiple DTCs involved make sure there is
proper RPC connectivity between all DTCs in both
directions - If a firewall is involved, make sure that proper
ports are opened in both directions - Run Web sites as Medium or High Isolation level
5Best Practices (4)What to do
- Estimate the stress for the COM component in
production and run a similar level of stress in
test environment - When installing application in cluster make sure
DTC IP belongs to public IP and not to private
one - If you want to use same CLSID and IID for the
component, enable binary compatibility for VB
components
6Best Practices (5)What to do
- To enhance scalability of COM application,
divide into time-dependent and time-independent
services - Creating and managing transaction is expensive
use transaction in an efficient way - Authenticate as close to the user as you can for
efficiency and performance
7Best Practices (6)What to do
- When creating a DSN, use object constructor
strings specified on the component instead of
creating a file DSN - Make sure any objects created inside COM have
been properly released
8Practices to AvoidWhat to avoid
- Avoid storing objects in Shared Property Manager
- Avoid storing STA objects in Application or
Session scope in Web applications - Avoid marshaling ADO Connection object
- Microsoft does not recommend storing state in
COM components
9Practices to Avoid (2)What to avoid
- Microsoft does not recommend using long running
code in ClassInitialize of VB components - Avoid calling GetObjectContext from
ClassInitialize of VB components - Avoid writing a huge blocking call in STA
components
10Practices to Avoid (3)What to avoid
- Microsoft does not recommend using callbacks from
COM components - Avoid displaying UI on a server-side component
- Avoid using non-threadsafe ODBC or OLEDB providers
11References
- COM Articles on MSDN
- http//msdn.microsoft.com/library/techart/complus
.htm - http//msdn.microsoft.com/library/techart/complus
4vb.htm - Knowledge Base article
- http//support.microsoft.com/support/kb/articles/
q252/3/18.asp - COM Reference in MSDN
(Note that the URLs above should be entered as
one line they are wrapped here for readability.)
12(No Transcript)