Microsoft KB Archive/327099

= PRB: Tlbimp.exe Does Not Import Methods in the Module in a Type Library =

Article ID: 327099

Article Last Modified on 10/15/2003

-

APPLIES TO


 * Microsoft .NET Framework 1.0

-



This article was previously published under Q327099



SYMPTOMS
If you have methods that are defined in a module in the library block of an Interface Definition Language (IDL) file, and if you use Tlbimp.exe to import the type library that is generated from this IDL file that is used in Managed world, you discover that Tlbimp does not import the methods in the module.



CAUSE
Methods in the Managed world must be a part of a class because there is no concept of stand-alone methods. Module methods are stand-alone methods. Because there is no stand-alone methods concept in the Managed world, Tlbimp.exe does not import stand-alone methods that are present in the IDL.



RESOLUTION
You can use P/Invoke on the COM DLL to call Module methods.



STATUS
This behavior is by design.



Steps to Reproduce the Behavior
 Create a new .idl file that is named TestModuleMethod.idl .  Copy the following code to TestModuleMethod.idl: [   uuid(12345678-1234-1234-1234-123456789ABC), ] library TestModuleMethod {   [        uuid(12345678-1234-1234-1234-123456789ABD), dllname(&quot;test.dll&quot;), ]   module ModuleMethod {       const long FRAME_COLOR = 0x10; const long WINDOW_COLOR = 0x20; const long BUTTON_COLOR = 0x40; [entry(10)] double pascal Square([in] double x); [entry(&quot;MessageBox&quot;)] int pascal MsgBox([in] BSTR s); } }                     Use Midl.exe on TestModuleMethod.idl to create TestModuleMethod.tlb. midl.exe testModuleMethod.idl   Use Tlbimp.exe on TestModuleMethod.tlb to create the metadata file that is named InteroptestModuleMethod.dll. tlbimp.exe /out:InteroptestModuleMethod.dll testModuleMethod.tlb  Run Ildasm.exe, and then open the metafile that you created in step 4 with Ildasm.

You may find that the methods in the TestModuleMethod do not appear in the InteroptestModuleMethod.dll.</li></ol>

Keywords: kbnofix kbprb kbcominterop KB327099

-

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

© Microsoft Corporation. All rights reserved.