help with error C2872: 'IServiceProvider' : ambiguous symbol with C++ code

Hi,
I am getting the error
......ServProv.h(93) : error C2872: 'IServiceProvider' : ambiguous symbol

with the following code.

file.cpp

#include "stdafx.h"

using namespace System;
using namespace System::Runtime::Remoting;
#import ".\RemotableObject.tlb"

namespace mynamespace {
    class myclass {     ...     }
    int _tmain(int argc, _TCHAR* argv[])
    {         return 0;     }
}

RemotableObject.tlb is generated from a c# dll.
I am not using IServiceProvider directly in the file

Based on a note in msdn library, I have moved the native header files to the top of the list. Even then I am getting the error.

Help is tremendously appreciated.

thanks
 
GKM



Answer this question

help with error C2872: 'IServiceProvider' : ambiguous symbol with C++ code

  • .Fortune

    Just to close my last post

    The error I had was

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ServProv.h(47) : warning C4935: assembly access specifier modified from 'public'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ServProv.h(92) : error C2872: 'IServiceProvider' : ambiguous symbol
            could be 'c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ServProv.h(47) : System::IServiceProvider IServiceProvider'
            or       'Form1.cpp(0) : System::IServiceProvider'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ServProv.h(99) : fatal error C1903: unable to recover from previous error(s); stopping compilation

    It was so frustrating becuase I hadn't edited either of the two files listed.  This was solved was simply moving the #include <altstr.h> declaration (in a different file to either of the ones mentioned above) from below, to above the 'using namespace' directives

    e.g.

    #pragma once

    #using <mscorlib.dll>

    #include <windows.h>

    #include <atlstr.h>

    using namespace System;

    using namespace System::IO;

    using namespace System::Collections;

    using namespace System::Collections::Specialized;

    Once this was done, everything compiled and ran without a problem (other than the actual logic problems in my code...)


  • Ahmed Kaouri

    I am also getting the same error and have tried looking around the forums with no success.  I had a try with the MSXML2 namespace that some of the articles suggested but that had no effect. I was in the process of posting a new thread as I was unable to find any article with IServiceProvider in it until I checked the articles at the side of what I was writing, and this was here.

    Are only recent articles subject to the search mechanism on the forums, because if so this problem may have been solved 20 times over the years and I'd be none the wiser

    I am only trying to write a fairly simple application dealing with text files, there's no fancy database or spreadsheet application, there's just a single form and an additional module (cpp and h) and when I try and build the project this strange ServProv.h file has appeared from nowhere and is giving me grief.

    I am currently using VC++ in Visual Studio .NET 2003 on an Win XP Pro PC that's only a couple of months old...


  • help with error C2872: 'IServiceProvider' : ambiguous symbol with C++ code