Lots of build warnings when COM objects ActiveDs or MSXML2 are referenced

后端 未结 3 1459
我寻月下人不归
我寻月下人不归 2021-01-02 01:34

After moving a project from .NET 1.1 to .NET 2.0, MsBuild emits lots of warnings for some COM objects.

Sample code for test (actual code doesn\'t matter, just used t

3条回答
  •  自闭症患者
    2021-01-02 01:57

    According to a comment in the MDSN article about TLBIMP for 2.0, you can't fix this problem w/o running TLBIMP yourself.

    It was easy to reproduce your problem using VS. I also reproduced it running TLBIMP manually from a VS comment prompt:

       tlbimp c:\WINNT\system32\activeds.tlb /out:interop.activeds.dll
    

    The fix was to use the /silent switch

       tlbimp c:\WINNT\system32\activeds.tlb /silent /out:interop.activeds.dll
    

    As pointed out in the comment in the MSDN article, the COM reference becomes a .net assembly reference to the interop assembly you built yourself.

    I'm not a VS expert, but I made this work by adding a prebuild to project of:

        "$(DevEnvDir)\..\..\SDK\v2.0\bin\tlbimp" c:\WINNT\system32\activeds.tlb
                /namespace:ActiveDs /silent /out:"$(ProjectDir)interop.activeds.dll"
    

    Built it once so I'd have a dll to add a reference with the browse tab. Added a reference to the interop.activeds.dll in my project root and then built again. You may want to do this some other way, like with an external make file via a C++ project. This is more of a POC.

    Note a funny difference in MSBUILD vs VS, $(DevEnvDir) has a trailing backslash but MSBUILD does not.

提交回复
热议问题