Reputation: 3524
I have a C# desktop application that references the COM object Microsoft OLE DB Service Component 1.0 Type Library
. This is the dialog that allows the user to build and test a connection string. The code has worked as expected for several years.
I find that when a "Rebuild" is performed that there are 18 unenumerated warnings that appear. I believe this means the warnings are created when the Type Library is imported.
They are all forms of:
Processing COM reference "MSDASC" from path "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll". The type library importer could not convert the signature for the member 'tagDBPROPIDSET.rgPropertyIDs'.
Processing COM reference "MSDASC" from path "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll". At least one of the arguments for 'DataLinks.RemoteCreateDBInstanceEx' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
Striping this down, I find that just adding the reference to an empty WinForms project will generate the warnings. No code accessing the MSDASC library is required.
As a workaround, I copied the Interop.MSDASC.dll
from the OBJ tree that was generated during the rebuild, and copied it to the project folder. I removed the reference to MSDASC
and added one to the Interop.MSDASC.dll
in my project.
Now when I rebuild I do not see the warnings. I deleted the Interop.MSDASC.dll
from the OBJ tree and it does get recreated.
Did this just mask my problem? Is there a better way to use the dialog and suppress or answer the warnings?
Update: This happens in VS 2017 & 2019, but I believe it happened in previous versions as well.
Added image of Error List window:
Upvotes: 4
Views: 1992
Reputation: 139095
They are indeed tlbimp
warning. You can check that if you run
TlbImp.exe "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll"
from VS developer command prompt (or from a path like C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools
, adapt to your machine).
You should see the exact same warnings.
If you don't use the members listed in the warning, you're pretty much safe.
Otherwise, you can remove all COM reference warning if you edit the .csproj
and add the ResolveComReferenceSilent
key to the first PropertyGroup
element, like this:
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<PropertyGroup>
...
<ResolveComReferenceSilent>True</ResolveComReferenceSilent>
...
</PropertyGroup>
The last solution is to use tlbimp.exe
manually and reference its output. There is an example here: Suppress tlbimp warnings in visual studio
Upvotes: 7