Monday, November 24, 2008

MIDL changing your property name to lowercase?

I had a "FileName" property in my interface...
interface IMyFile : IDispatch {
...
[propget, id(6)] HRESULT FileName([out, retval] BSTR* pVal);
}

and somehow in the TLB this came out as "filename" - all lowercase.

It turned out to be a really weird bug in MIDL. It was triggered because I had a method that takes a parameter called "filename". I had a method like this:
interface IMyFile : IDispatch {
[id(1)] HRESULT OpenFile(BSTR filename, long reserved);
...
[propget, id(6)] HRESULT FileName([out, retval] BSTR* pVal);
}

See, MIDL changes the case of the property (or method?) to match the case of the parameter. The solution was to rename the parameter "filename" to "FileName". This even happens if the matching parameter name appears in an unrelated interface!

1 Comments:

At 3/23/2009 5:07 AM, Anonymous Anonymous said...

Hi, we got the same problem here.
Only additional information i found was here:

BUG: MIDL Changes the Case of Identifier in Generated Type Library
http://support.microsoft.com/kb/q220137/

 

Post a Comment

<< Home