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. C / C++ / MFC
  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 C / C++ / MFC
c++csharpdotnetwcfxml
9 Posts 5 Posters 0 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++ MFC project through References in Solution Explorer. Microsoft Development Environment 2003 Version 7.1.3088. Microsoft .Net Framework 1.1 Version 1.1.4322

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

    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(1702): error C2227: left of '->ClientTimeout' must point to class/struct/union
    type is ''unknown-type''
    file.cpp(1268): error C2653: 'System' : is not a class or namespace name
    file.cpp(1268): error C2871: 'DirectoryServices' : 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

    V 1 Reply Last reply
    0
    • A Alex Banar

      System.DirectoryServices.dll file has been added successfully to Visual C++ MFC project through References in Solution Explorer. Microsoft Development Environment 2003 Version 7.1.3088. Microsoft .Net Framework 1.1 Version 1.1.4322

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

      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(1702): error C2227: left of '->ClientTimeout' must point to class/struct/union
      type is ''unknown-type''
      file.cpp(1268): error C2653: 'System' : is not a class or namespace name
      file.cpp(1268): error C2871: 'DirectoryServices' : 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

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      The [System.DirectoryServices Namespace | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices?view=dotnet-plat-ext-6.0#:~:text=Provides easy access to Active,Services Interfaces (ADSI) technology.) and its classes belong to the .NET, so they appear to have nothing to do with the native C++ code. You probably need to create a C++/CLI project to use these namespace/classes.

      A 1 Reply Last reply
      0
      • V Victor Nijegorodov

        The [System.DirectoryServices Namespace | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices?view=dotnet-plat-ext-6.0#:~:text=Provides easy access to Active,Services Interfaces (ADSI) technology.) and its classes belong to the .NET, so they appear to have nothing to do with the native C++ code. You probably need to create a C++/CLI project to use these namespace/classes.

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

        It is .Net: Microsoft Development Environment 2003 Version 7.1.3088. Microsoft .Net Framework 1.1 Version 1.1.4322 Visual C++ MFC: When I add to References System.DirectoryServices.dll it refuses to add not 1.1.4322 version of it, only System.DirectoryServices.dll of 1.1.4322 version

        V D 2 Replies Last reply
        0
        • A Alex Banar

          It is .Net: Microsoft Development Environment 2003 Version 7.1.3088. Microsoft .Net Framework 1.1 Version 1.1.4322 Visual C++ MFC: When I add to References System.DirectoryServices.dll it refuses to add not 1.1.4322 version of it, only System.DirectoryServices.dll of 1.1.4322 version

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #4

          .Net is for managed C++/CLI. MFC does nt support "managed" code, only the native one. So you have to create a new C++/CLI project and try to work with this DirectorySearcher class in there.

          A 1 Reply Last reply
          0
          • A Alex Banar

            It is .Net: Microsoft Development Environment 2003 Version 7.1.3088. Microsoft .Net Framework 1.1 Version 1.1.4322 Visual C++ MFC: When I add to References System.DirectoryServices.dll it refuses to add not 1.1.4322 version of it, only System.DirectoryServices.dll of 1.1.4322 version

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            I seriously recommend upgrading Visual Studio to latest and use a version of the .NET Framework that hasn't been dead for the last 10 years.

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
            Dave Kreskowiak

            A 1 Reply Last reply
            0
            • V Victor Nijegorodov

              .Net is for managed C++/CLI. MFC does nt support "managed" code, only the native one. So you have to create a new C++/CLI project and try to work with this DirectorySearcher class in there.

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

              Can you think about the problem to implement the use of DirectorySearcher class? I have System.DirectoryServices.dll suitable exactly for my version of Microsoft .Net Framework 1.1 Version 1.1.4322. Other versions of System.DirectoryServices.dll are refused to be added to the References folder in the project. About to upgrade software that will be suitable to new Visual Studio version - it not so simple. It is huge old software. I has performed conversion today but can not yet to see the result today. There were errors that conversion raised during it

              L 1 Reply Last reply
              0
              • D Dave Kreskowiak

                I seriously recommend upgrading Visual Studio to latest and use a version of the .NET Framework that hasn't been dead for the last 10 years.

                Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                Dave Kreskowiak

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

                About to upgrade software that will be suitable to new Visual Studio version - it not so simple. It is huge old software. I has performed conversion today but can not yet to see the result today. There were errors that conversion raised during it

                1 Reply Last reply
                0
                • A Alex Banar

                  Can you think about the problem to implement the use of DirectorySearcher class? I have System.DirectoryServices.dll suitable exactly for my version of Microsoft .Net Framework 1.1 Version 1.1.4322. Other versions of System.DirectoryServices.dll are refused to be added to the References folder in the project. About to upgrade software that will be suitable to new Visual Studio version - it not so simple. It is huge old software. I has performed conversion today but can not yet to see the result today. There were errors that conversion raised during it

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

                  There are many articles found by .net and mfc - Google Search[^] which explain how to mix MFC and .NET classes.

                  Richard Andrew x64R 1 Reply Last reply
                  0
                  • L Lost User

                    There are many articles found by .net and mfc - Google Search[^] which explain how to mix MFC and .NET classes.

                    Richard Andrew x64R Offline
                    Richard Andrew x64R Offline
                    Richard Andrew x64
                    wrote on last edited by
                    #9

                    Plus, let's not forget the "bible" of native/managed interop, C++/CLI in Action[^] by our friend Nish.

                    The difficult we do right away... ...the impossible takes slightly longer.

                    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