Build Warnings Related to COM Reference (Version 1

2019-01-20 10:28发布

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?

标签: c# ole
2条回答
别忘想泡老子
2楼-- · 2019-01-20 11:13

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.

查看更多
Juvenile、少年°
3楼-- · 2019-01-20 11:21

How to remove warning message (wmp.dll)?

Old question but the issue remains:

Even though the warning message can be ignored but its annoying to have it in error list. What worked to remove this warning for both x86 and x64;

I added a reference to a different build of Windows Media Player and no more warning or errors for both CPU architecture.

This worked perfect on Windows 10; can't be sure about other environments.

There was slight modification for the code to fit the 'new' reference. If you don't need the build that brings the warnings specifically you could try this out. Please refer to attached images, Build 12.0.10011.x worked for me.

Build 12.0.14393.x

Build 12.0.10011.x

查看更多
登录 后发表回答