locked
Please help. I am having problems with some Microsoft Code. RRS feed

  • Question

  • Help, what am I doing wrong? I am trying to compile some Microsoft code and I get some errors. Here is a very small snippet of the code and the compile errors.

     

    using System;

    using Microsoft.Win32;

    exefile.cpp(9) : error C2873: 'System' : symbol cannot be used in a using-declaration

    exefile.cpp(10) : error C211>c:\users\dawn43: syntax error : missing ';' before '.'

    exefile.cpp(10) : error C2873: 'Microsoft' : symbol cannot be used in a using-declaration

    exefile.cpp(10) : error C2059: syntax error : '.'

     

    Thanks.

    Sunday, September 19, 2010 11:32 PM

Answers

  •  

    Hi,

     

    If you want, you can use namespace Win32 in CLI/C++ project, so please make sure that you create a CLI/C++ project, and then there some sample in win32 namespace website.

     

    Have a nice day!

    Jesse


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Grant Bonnell Monday, September 27, 2010 10:10 PM
    Monday, September 27, 2010 1:17 AM

All replies

  • I don't do c++/CLI, so this is somewhat guesswork.  Are you trying to use .NET libraries from an unmanaged (native) file?  Do you have any necessary headers included?

     

    Monday, September 20, 2010 1:21 AM
  • Your code looks like C#. In C++/CLI do like this:
     
    using namespace System;
    using namespace Microsoft::Win32;
     

    David Wilkinson | Visual C++ MVP
    Monday, September 20, 2010 10:12 AM
  •  

    Hi,

     

    I'm very interested your issue, did you solve your problem?

    If so please share the solution with us and mark the right answer.

    If not please let me know.

     

    Have a nice day!

    Jesse


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, September 24, 2010 3:11 AM
  • Your code looks like C#. In C++/CLI do like this:
     
    using namespace System;
    using namespace Microsoft::Win32;
     

    David Wilkinson | Visual C++ MVP

    I am sorry I included C# code by mistake, I actually used the C++ code. I probally did something stupid. These are the first two lines of code.  Should i have included something before this?
    Sunday, September 26, 2010 10:59 PM
  •  

    Hi,

     

    If you want, you can use namespace Win32 in CLI/C++ project, so please make sure that you create a CLI/C++ project, and then there some sample in win32 namespace website.

     

    Have a nice day!

    Jesse


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Grant Bonnell Monday, September 27, 2010 10:10 PM
    Monday, September 27, 2010 1:17 AM