Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll

Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll

Scheduled Pinned Locked Moved .NET (Core and Framework)
c++wcfxmlhelp
9 Posts 3 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Banar
    wrote on last edited by
    #1

    System.DirectoryServices.dll file has been added successfully to Visual C++ project through References in Solution Explorer

    using namespace System.DirectoryServices;//line 1268
    void CClassName::MethodName(){
    ...
    DirectorySearcher* directorySearcher = new DirectorySearcher();//line 1701
    directorySearcher->ClientTimeout = 60000;//line 1702
    ...
    }

    file.cpp(1268): error C2059: syntax error : '.'
    file.cpp(1701): error C2061: syntax error : identifier 'DirectorySearcher'
    file.cpp(1701): error C2065: 'directorySearcher' : undeclared identifier
    file.cpp(1701): error C2065: 'DirectorySearcher' : undeclared identifier
    file.cpp(1268): error C2143: syntax error : missing ';' before '.'
    file.cpp(1702): error C2228: left of '->Timeout' must have class/struct/union type
    type is ''unknown-type''
    file.cpp(1268): error C2871: 'System' : a namespace with this name does not exist
    file.cpp(1702): error C3861: 'directorySearcher': identifier not found, even with argument-dependent lookup

    By this way I need to set Request Timeout for SOAP WebService

    L 1 Reply Last reply
    0
    • A Alex Banar

      System.DirectoryServices.dll file has been added successfully to Visual C++ project through References in Solution Explorer

      using namespace System.DirectoryServices;//line 1268
      void CClassName::MethodName(){
      ...
      DirectorySearcher* directorySearcher = new DirectorySearcher();//line 1701
      directorySearcher->ClientTimeout = 60000;//line 1702
      ...
      }

      file.cpp(1268): error C2059: syntax error : '.'
      file.cpp(1701): error C2061: syntax error : identifier 'DirectorySearcher'
      file.cpp(1701): error C2065: 'directorySearcher' : undeclared identifier
      file.cpp(1701): error C2065: 'DirectorySearcher' : undeclared identifier
      file.cpp(1268): error C2143: syntax error : missing ';' before '.'
      file.cpp(1702): error C2228: left of '->Timeout' must have class/struct/union type
      type is ''unknown-type''
      file.cpp(1268): error C2871: 'System' : a namespace with this name does not exist
      file.cpp(1702): error C3861: 'directorySearcher': identifier not found, even with argument-dependent lookup

      By this way I need to set Request Timeout for SOAP WebService

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The first error message is telling you that there is something wrong with that using statement, as it does not recognise the use of the period character. The cause is likely to be in the preceding lines which you have not shown. Alternatively you have placed the directive in the wrong part of your source; see using directive - C# Reference | Microsoft Docs[^].

      A 1 Reply Last reply
      0
      • L Lost User

        The first error message is telling you that there is something wrong with that using statement, as it does not recognise the use of the period character. The cause is likely to be in the preceding lines which you have not shown. Alternatively you have placed the directive in the wrong part of your source; see using directive - C# Reference | Microsoft Docs[^].

        A Offline
        A Offline
        Alex Banar
        wrote on last edited by
        #3

        I have another using namespace just before and it is OK: using namespace YarpaB2BService; using namespace System.DirectoryServices; I am working with Visual C++ .NET

        L 1 Reply Last reply
        0
        • A Alex Banar

          I have another using namespace just before and it is OK: using namespace YarpaB2BService; using namespace System.DirectoryServices; I am working with Visual C++ .NET

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I cannot find a definitive statement on this, but try the following:

          using namespace System::DirectoryServices; // double colon instead of period.

          A 1 Reply Last reply
          0
          • L Lost User

            I cannot find a definitive statement on this, but try the following:

            using namespace System::DirectoryServices; // double colon instead of period.

            A Offline
            A Offline
            Alex Banar
            wrote on last edited by
            #5

            Sorry, I have tried it. It's the same errors besides: file.cpp(1268):syntax error : '.' And one new file.cpp(1268): 'DirectoryServices' : a namespace with this name does not exist

            L 1 Reply Last reply
            0
            • A Alex Banar

              Sorry, I have tried it. It's the same errors besides: file.cpp(1268):syntax error : '.' And one new file.cpp(1268): 'DirectoryServices' : a namespace with this name does not exist

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              It cannot be the same syntax error. The message you show complains that you are still using the period instead of the double colon.

              A 1 Reply Last reply
              0
              • L Lost User

                It cannot be the same syntax error. The message you show complains that you are still using the period instead of the double colon.

                A Offline
                A Offline
                Alex Banar
                wrote on last edited by
                #7

                I am using double colon. The error message "file.cpp(1268):syntax error : '.'" has disapiered

                L E 2 Replies Last reply
                0
                • A Alex Banar

                  I am using double colon. The error message "file.cpp(1268):syntax error : '.'" has disapiered

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Alex Banar wrote:

                  I am using semicolon.

                  Why? I already explained twice that you need a double colon (::).

                  1 Reply Last reply
                  0
                  • A Alex Banar

                    I am using double colon. The error message "file.cpp(1268):syntax error : '.'" has disapiered

                    E Offline
                    E Offline
                    Edge Forex
                    wrote on last edited by
                    #9

                    Forex News April 09, 2022 - Edge-Forex[^]

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups