CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Question What can I do to use wtypes without internal errors?

    I have a project that uses legacy code C++ with lots of references to the file wtypes.h. Basically this use the function wsprintf and PALETTEENTRY. If I include this file I get the error C2872 in compile time:

    error C2872: 'IServiceProvider' : ambiguous symbol
    could be '\Vc7\PlatformSDK\Include\ServProv.h(48) : System::IServiceProvider IServiceProvider'
    or 'Stdafx.cpp(0) : System::IServiceProvider'
    How can I use wtypes avoiding this error C2872?
    Last edited by Eliseu_CEL; February 1st, 2006 at 03:20 PM. Reason: better format

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: What can I do to use wtypes without internal errors?

    This problem occures because the unmanaged IServiceProvider conflicts with the System::IServiceProvider. You either don't use namespace System or pack the unmanaged included into a namespace.

    For example:
    Code:
    // header
    namespace unmanaged
    {
    #   include <windows.h>
    }
    Code:
    // source
    
    #include "myheader.h"
    
    unmanaged::GetDlgItem(/*blabla*/);
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Talking Re: What can I do to use wtypes without internal errors?

    Thank you NoHere.

    Actually what I changed, and now everything is working ok, is that.

    Old code:

    Code:
    #pragma once
    
    using namespace System;
    using namespace System::Collections;
    
    #pragma unmanaged
    #include ".\PDAIncludes\conjpto.h" 
    #include ".\PDAIncludes\objeto.h" 
    #include ".\PDAIncludes\lista.h"
    #include ".\PDAIncludes\radar.h" 
    #include ".\PDAIncludes\cvang.h"
    #include ".\PDAIncludes\incursor.h"
    
    #pragma managed
    
    namespace IEAv_PDACPP
    {
    With this I got the Error C2872

    New code now:
    Code:
    #pragma once
    
    
    #pragma unmanaged
    #include ".\PDAIncludes\conjpto.h" 
    #include ".\PDAIncludes\objeto.h" 
    #include ".\PDAIncludes\lista.h"
    #include ".\PDAIncludes\radar.h" 
    #include ".\PDAIncludes\cvang.h"
    #include ".\PDAIncludes\incursor.h"
    
    #pragma managed
    
    using namespace System;
    using namespace System::Collections;
    and then, I don't get the error anymore.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured