Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

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

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:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:windowssystem32wmp.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:windowssystem32wmp.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...