Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Warnings Related to COM Reference (Version 1.0 Type Library) and VS 2010

Tags:

c#

ole

I just finished restructuring and upgrading a bunch of C# projects from Visual Studio 2008 to Visual Studio 2010. Additionally, all of the projects were changed to target the .NET 4.0 runtime. Everything builds successfully but, I now get a bunch of warnings related to a COM reference that my application is dependent upon. One of the warnings is below. I get close to 100 warnings similar to the one below everytime I build the solution.

Warning 60  Type library importer encountered a property getter 'ClearTopCardQue' on type 'FuelDirectOLETLB.FuelDirectOLE' without a valid return type.  The importer will attempt to import this property as a method instead. c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets  1558    9   FDServer

I have called the 3rd party vendor that authored the object I am referencing to no avail. They advised me to make sure that I am targeting x86 which I am. They also stated that I should be able to build my projects against any version of the .NET runtime. Personally, I suspect that it has something to do with the fact that I am referencing a version 1 type library in Visual Studio 2010 / .NET Runtime 4.0 whereas before I was building on VS 2008 / .NET Runtime 3.5. I have tried building against all build configurations (i.e. x86, x64, Any Cpu) and tried every version of the runtime back to 2.0. The warnings concern me because I am not sure what they indicate. Can someone make any suggestions/recommendations that might help me locate the cause of these warnings?

like image 279
Grasshopper Avatar asked Apr 03 '13 19:04

Grasshopper


1 Answers

It is a benign warning, nothing to worry about. They just didn't author the IDL for the component properly. Property getters in COM are methods, just like they are in .NET. The method must have the proper signature and attributes to be considered a valid property that can be directly translated to a .NET property.

This is fumbled sometimes. A good example is Windows Media Player. Run this command from the Visual Studio Command Prompt in a temporary directory:

  Tlbimp.exe c:\windows\system32\wmp.dll

And you'll see:

TlbImp : warning TI0000 : Type library importer encountered a property getter 'sessionPlaylistCount' on type 'WMPLib.IWMPNowPlayingHelperDispatch' without a valid return type. The importer will attempt to import this property as a method instead.
Type library imported to WMPLib.dll

Next type:

  Oleview.exe c:\windows\system32\wmp.dll

Which decompiles the type library back to IDL. Select the text in the right pane and copy/paste it into a text editor. Locate "sessionPlaylistCount" and you'll see:

[id(0x00000ba3), propget]
HRESULT sessionPlaylistCount([out] long* pVal);

When you compare it with other properties you'll see the mistake, they forgot the [retval] attribute.

It isn't a problem because Tlbimp.exe will simply make it a method instead of a property. You'd write get_sessionPlaylistCount(out count) to use the broken property. It is inconvenient because the syntax is awkward but not otherwise a problem.

like image 129
Hans Passant Avatar answered Sep 28 '22 23:09

Hans Passant