Interop (.NET 1.1) Performance Guidelines

From Guidance Share
Jump to navigationJump to search

- J.D. Meier, Srinath Vasireddy, Ashish Babbar, and Alex Mackman


Contents

  • 1 Design Considerations
  • 2 Code Access Security (CAS)
  • 3 Marshal.ReleaseComObject
  • 4 Marshaling
  • 5 Threading

Design Considerations

  • Design chunky interfaces to avoid round trips.
  • Reduce round trips with a facade.
  • Implement IDisposable if you hold unmanaged resources across client calls.
  • Reduce or avoid the use of late binding and reflection.


Code Access Security (CAS)

  • Consider using SuppressUnmanagedCode for performance-critical trusted scenarios.
  • Consider using TLBIMP /unsafe for performance-critical trusted scenarios.


Marshal.ReleaseComObject

  • Consider calling ReleaseComObject in server applications.
  • Do not force garbage collections with GC.Collect.


Marshaling

  • Explicitly name the target method you call.
  • Use blittable types where possible.
  • Avoid Unicode to ANSI conversions where possible.
  • Use IntPtr for manual marshaling.
  • Use [in] and [out] to avoid unnecessary marshaling.
  • Avoid aggressive pinning of short-lived objects.


Threading

  • Reduce or avoid cross-apartment calls.
  • Use ASPCOMPAT when you call STA objects from ASP.NET.
  • Use MTAThread when you call free-threaded objects.
  • Avoid thread switches by using Neutral apartment COM components.
Retrieved from "http://guidanceshare.com/index.php?title=Interop_(.NET_1.1)_Performance_Guidelines&oldid=5351"
Categories:
  • Interop (.NET 1.1)
  • Guidelines

Navigation menu

Page actions

  • Article
  • Discussion
  • View source
  • History

Page actions

  • Article
  • Discussion
  • More
  • Toolbox
  • In other languages

Personal tools

  • Log in

Navigation

  • Main Page
  • Community portal
  • Current events
  • Recent changes
  • Random page
  • Help
  • Donations

Toolbox

  • What links here
  • Related changes
  • Special pages
  • Printable version
  • Permanent link
  • Page information

 
Powered by MediaWiki
  • This page was last edited on 14 December 2007, at 05:22.
  • Privacy policy
  • About Guidance Share
  • Disclaimers