locked
Visual C++ compile error C2871 - <namespace> : a namespace with this name does not exist RRS feed

  • Question

  • I am trying to create a ManagedWrapper dll that can be called from an MFC application that will not be compiled using /clr switch. In a header of my test MFC, I have declared the following:

    #import "ManagedProxy.tlb"
    using namespace ManagedProxy;
    

    When I try to compile the test MFC application, I get error C2871: 'ManagedProxy' : a namespace with this name does not exist. I am sure this has worked as recently as yesterday. If I specify a wrong tlb file name, I get compile error C1083, which indicates to me that the tlb file is being loaded correctly.

    Why is Visual Studio now complaining and why did it work before?

    TIA.

    Tuesday, July 5, 2011 5:14 PM

Answers

All replies

  • I would examine the contents of the generated ManagedProxy.tlh file and confirm the existence and name of the namespace definition.
    Tuesday, July 5, 2011 8:08 PM
  • I would examine the contents of the generated ManagedProxy.tlh file and confirm the existence and name of the namespace definition.

    The following stack overflow recommend for make use rename_namespace

    #import "ManagedProxy.tlb" rename_namespace("ManagedProxy")
    

    http://stackoverflow.com/questions/6585293/visual-c-compile-error-c2871-namespace-a-namespace-with-this-name-does-no

    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    • Proposed as answer by Jesse Jiang Wednesday, July 13, 2011 8:47 AM
    • Marked as answer by Jesse Jiang Thursday, July 21, 2011 6:24 AM
    Wednesday, July 6, 2011 7:35 AM
  • Hello,

     

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, July 18, 2011 7:44 AM