Type Library Converter tool (TlbImp.exe) version 4.0.30319.1 changes any "false" Default Boolean arguments to "true"
The Type Library Converter tool (TlbImp.exe) version 4.0.30319.1 changes any "false" default arguments to "true". Please see the details below for an understanding.
I created an ATL project named COMInteropTest and added an interface named IMyCOMServer. I added two methods namely: MyCOMServerMethodA() and MyCOMServerMethodB() with default arguments.
// COMInteropTest.idl : IDL source for COMInteropTest//// This file will be processed by the MIDL tool to// produce the type library (COMInteropTest.tlb) and marshalling code. import "oaidl.idl";import "ocidl.idl"; [ object, uuid(B139EA01-6552-43CF-B52F-50642D9D45AB), dual, nonextensible, pointer_default(unique)] interface IMyCOMServer : IDispatch{ [ uuid(02A71855-FB48-419A-895B-63DF2E325706), version(1.0),]library COMInteropTestLib{ importlib("stdole2.tlb"); [ uuid(CC9B6244-FB56-4CCA-B9FA-B71B5ECBC2C6) ] coclass MyCOMServer { [default] interface IMyCOMServer; };}; |
Used Type Library Converter tool from VS 2008 to create the Interop shown below:
Here is what I see under .Net reflector. The default arguments are not changed.
Used Type Library Converter tool from VS 2010 to create the Interop shown below:
Here is what I see under .Net reflector. The default value of “false” is converted to “true”.
This is a code defect with TlbImp.exe version 4.0.30319.1 which has been fixed on the next version of Visual Studio. A possible workaround is to use TlbImp.exe from the Win8 developer preview build where this is fixed.
I installed Visual Studio 2011 Developers preview from www.microsoft.com/download/en/details.aspx?displaylang=en&id=27543 and extracted TLBIMP.exe from \Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools. The version of TLBIMP.exe is 4.030319.17020. I checked to see that it is handling the default Boolean arguments correctly.
Written By
Shamik Misra
Support Escalation Engineer, Microsoft Developer Support