FIX: Type Library Importer (Tlbimp.exe) Fails to Parse Certain Type Libraries

This article was previously published under Q316552
This article has been archived. It is offered "as is" and will no longer be updated.
SYMPTOMS
If you use two coclasses, such as Test and TestClass, and a method or property that is named TestClass, the Type Library Importer (Tlbimp.exe) fails, and you receive the following error message:
TlbImp error: System.TypeLoadException - Type Test.TestClass from assembly TestClass tried to override method TestClass but does not implement or inherit that method.
RESOLUTION
To resolve this problem, obtain the latest service pack for Microsoft .NET Framework. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
318836 INFO: How to Obtain the Latest .NET Framework Service Pack
STATUS
This bug was corrected in .NET Framework (2003|1.1).
MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new .idl file with the following code, and then save the file as Test.idl.
    [uuid(B109B266-FFA6-482a-BF17-8A1F49A83E6E), version(1.0), helpstring("Q316552 1.0 Type Library")]library Test{	importlib("stdole2.tlb");		[uuid(3CD087A6-3693-4c97-A599-EC7C231C59CA), oleautomation]	interface ITest : IUnknown 	{		HRESULT TestClass([in] int i);	}	[uuid(08045E96-5742-486c-8604-925BBEB9AD61), helpstring("Test Class")]	coclass Test 	{		[default] interface ITest;	};	[uuid(13803111-45FA-4368-A540-66030894AE7F), helpstring("TestClass Class")]	coclass TestClass 	{		[default] interface IUnknown;	};};					
  2. Run Microsoft Interface Definition Language (MIDL) against Test.idl to generate the corresponding type library file, as follows:
    midl test.idl					
  3. Run Tlbimp to import this type library, as follows:
    tlbimp test.tlb /out:TestNET.dll /namespace:Test					
    Note that Tlbimp fails with the System.TypeLoadException error message.
kbNETFrame100sp1fix
Properties

Article ID: 316552 - Last Review: 10/24/2013 09:27:47 - Revision: 3.1

  • Microsoft .NET Framework Software Development Kit 1.0 Service Pack 2
  • Microsoft .NET Framework Software Development Kit 1.0 Service Pack 2
  • Microsoft .NET Framework Class Libraries 1.0
  • kbnosurvey kbarchive kbbug kbcominterop kbfix KB316552
Feedback