2

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.

MSDASC Data Link Properties editor

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:

enter image description here

Rich Shealer
  • 3,362
  • 1
  • 34
  • 59
  • Are you using an old version of Visual Studio? I can't reproduce warning with Visual Studio 2017 – Simon Mourier Jul 02 '19 at 06:24
  • @SimonMourier Visual Studio 2019 16.0.2, WIndows 10 1809, US configuration. I can also generate it with Visual Studio 2017 15.9.11. The warnings appear in the 'Error List' window. I placed a Zipped version of the bare bones WinForm project that shows the issue on DropBox: https://www.dropbox.com/s/4q2svv55zzur9og/TestMsdasc.zip?dl=0 – Rich Shealer Jul 02 '19 at 12:24
  • .NET applications should use the native ADO.NET components to access SQL Server, and the connection strings for that are not identical to what OLE DB uses (very similar, but not identical). At the very least, remaining compatible with future versions of SQL Server means using the [newest driver](https://learn.microsoft.com/sql/connect/oledb/oledb-driver-for-sql-server) (which may or may not come with its own COM component, but if it does it's worth testing). – Jeroen Mostert Jul 02 '19 at 12:45

1 Answers1

4

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

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298