Microsoft KB Archive/327782

= FIX: Performance Degrades When You Call Methods of a ServicedComponent =

Article ID: 327782

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.0 Service Pack 1
 * Microsoft .NET Framework 1.0 Service Pack 2

-



This article was previously published under Q327782



SYMPTOMS
When you make a call from a remote .NET AppDomain to a Microsoft .NET component that is configured in COM+, you may experience performance slowdown in the AppDomain that initiated the call. This problem occurs only when you invoke methods on a ServicedComponent that is hosted by a COM+ server application.



CAUSE
When a managed application dispatches method calls to a ServicedComponent that is hosted in a COM+ server application, the .NET Framework must marshal method parameters. To improve performance, the internal marshaling layer uses a cached MemoryStream object to marshal and unmarshal the parameters. However, the marshaler always uses the full MemoryStream buffer for every call, instead of passing only the minimum required data.

Because the marshaled stream can become larger than necessary, applications that use large parameters at one time may experience performance degradation for calls that use small parameters later.



RESOLUTION
A supported fix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Apply it only to computers that are experiencing this specific problem. This fix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next .NET Framework service pack that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

  Date          Time    Version        Size      File name --  10-Aug-2002   09:51   1.0.3705.302   208,896   System.EnterpriseServices.dll 09-Aug-2002  23:23   1.0.3705.302    47,104   System.EnterpriseServices.Thunk.dll

This fix is designed specifically to be installed on a system that already has the Microsoft .NET Framework Service Pack 1 installed. If you must have this fix on a system that has Microsoft .NET Framework Service Pack 2 installed, click the article number below to view the article in the Microsoft Knowledge Base:

328545 INFO: Post-Service Pack 2 .NET Framework Hotfix Rollup Package 2



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
The following is minimal information relevant to demonstrating the problem that is discussed in this article. For additional information about how to create ServicedComponents, click the article number below to view the article in the Microsoft Knowledge Base:

306296 HOW TO: Create a Serviced .NET Component in Visual C# .NET

To reproduce the problem, follow these steps:   Use the following code to create a COM+ component: using System; using System.Reflection; using System.Runtime.CompilerServices; using System.EnterpriseServices;

[assembly: AssemblyVersion(&quot;1.0.0.0&quot;)] [assembly: AssemblyKeyFile(&quot;ComPlusTest.snk&quot;)]

[assembly: ApplicationName(&quot;ComPlusTest&quot;)] [assembly: ApplicationActivation(ActivationOption.Server)]

public class CServer : ServicedComponent {  [AutoComplete] public String Exec(byte [] param) {   return &quot;done&quot;; } }                     Use the following code to create a client application: using System;

public class CClient {  public static void Main {     CServer pObj = new CServer; byte [] pLarge = new byte [2000]; byte [] pSmall = new byte [10];

// method call with large param pObj.Exec(pLarge);

// method call with small param // takes just as long as the earlier call pObj.Exec(pSmall);

pObj.Dispose; } }                   

Because of this bug, the second call to CServer.Exec takes as long as the first call, although the parameter is smaller.

Keywords: kbbug kbfix kbqfe kbnetframe100presp3fix kbhotfixserver KB327782

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.