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

Alex B 1 Reputation point

System.DirectoryServices.dll file has been added successfully to Visual C++ MFC .NET 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

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,632 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Alex B 1 Reputation point

    Thank you,
    It is Visual C++ MFC software. I understand that MFC project can not come
    together with Common Language RunTime option (/clr).

  2. Alex B 1 Reputation point

    I have performed what is explained in the article.
    Still I get the error: file.cpp: fatal error C1190: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option
    /clr option in my Visual Studio can be set only by the level of code method and i did it. Compile as mannaged: Assembly Support (/clr).

  3. Alex B 1 Reputation point

    First of all thank you for your help.
    You was right - the code I published is only for managed /clr environment.
    I have tried today again to create /clr environment with minimum changes in project properties.
    I has began from change: Compile as Managed - Assembly Supprt(/clr) and continued until I did not get any negative comment.
    And has added some additions according to example of similar code structure from online book(From this book I got main explaination about code to use for setting timeot).
    It passes compilation. The result will be known tommorrow when we will perform the test.
    I have tried to perform conversion to modern environment but there were a huge number of errors after it.
    Our software is very big and complicated

    0 comments No comments