Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Instantiating Managed COM component Intermittently Returns 0x80070057


Symptoms

Consider the scenario where you are creating an instance of a .NET component exposed to COM using .NET / COM Interop, and you are doing this in a multi-threaded application. Intermittently it fails to create the instance of the component and the error is:

HRESULT: 0x80070057 (ERROR_INVALID_PARAMETER)

You might see the error message 'One or more arguments are incorrect' or if you are creating this component from Visual Basic 6 you might see 'Invalid Procedure Call or Argument'.

↑ Back to the top


Cause

This is an issue specific to the versions 2.0, 3.0 and 3.5 of the .NET Framework. A race condition exists during AppDomain initialization when there are multiple threads trying to create an instance of the .NET component from unmanaged code.

↑ Back to the top


Resolution

Upgrade to the .NET Framework 4.0 where this issue has been fixed. Alternatively, you can try to work around the issue by making an initial call in to managed code from the unmanaged application before spinning up threads that will create the .NET component. This should initialize the .NET Runtime such that it does not hit this race condition.

↑ Back to the top


Keywords: kbcominterop, kb

↑ Back to the top

Article Info
Article ID : 2897975
Revision : 1
Created on : 1/7/2017
Published on : 11/24/2013
Exists online : False
Views : 783