3 สิงหาคม 2550 15:21
Hi - I want to use the ldapconnection functionality in .net 2.0. My script contains:
but I get this msg trying to compile with csc.exe in .net :
test50.cs(1,32): error CS0234: The type or namespace name 'Protocols' does not exist in
the namespace 'System.DirectoryServices' (are you missing an assembly reference?)
I have a fresh install on .net 2.0 on XP SP2. What is going on?
Regards from Eddy in Tasmania.
3 สิงหาคม 2550 15:43
you are probably referencing System.DirectoryServices.dll, which does not contain the System.DirectoryServices.Protocols namespace. You need to reference also System.DirectoryServices.Protocols.dll
6 สิงหาคม 2550 0:10
Thanks for replying Mario. BUT I get the message even after explicitly including
in the code. That's why I don't understand what is going on.
6 สิงหาคม 2550 0:32ผู้ดูแล
What Mario is saying is that you need a reference to the assembly implementing the protocols namespace as well as a USING directive at the start of your program. The USNG directive permits the use of the namespace's types without explicit qualification but you need a reference to an assembly that implements the namespace before the compiler knows what types we are talking about.
If Visual Studio isn't already displaying the Solution Explorer, use "View | Solution Explorer" to display the solution explorer.
In the solution explorer, right click on your project and click on Add reference
In the Add reference dialog, click on the .NET tab then scroll down through the list of components until you find System.DirectoryServices.Protocols
Click on the System.DirectoryServices.protocols component and then click on OK
This will add an assembly reference to your project.
6 สิงหาคม 2550 1:09
Thank you Frank and Mario. I'm actually not using Visual Studio. I am handcoding my c#. All I needed to do when compiling with csc.exe was add a commandline parameter /rystem.DirectoryServices.Protocols.dll that added the reference you mentioned. Thanks for your help.
15 พฤษภาคม 2551 18:33
I would like to reopen this topic and ask if what is being discussed also applies to Visual Studio Express (VSE) 2008 as far as Visual Basic Express. In my VBE 2008 code, I tried to use "Imports System.DirectoryServices.Protocols", but it is not being recognized as a valid namespace. However, it is listed under the Object Browser.
15 พฤษภาคม 2551 20:27ผู้ดูแล
It usually isn't a good idea to re-open topics as your message only gets seen by the subset of the community who have alerts for the thread. Tactially, you'd be better off posting a completely new thread which appears in the "Unanswered Questions" list.
I haven't used the 2008 version of Visual Basic Express but yes everything discussed should apply.
You probably have the Object Browser set to show "All Components" which is why the namespace appears. Change the Object browser to Browse: My Solution and you'll find that the namespace is not shown (which is why the Imports statement doesn't recognise the namespace).
As discussed earlier in this thread, to make the namepsace known to your solution you have to add a reference to your project. Use the Project menu and then the Add Reference command to bring up the Add Reference dialog. Make sure you have the .NET tab selected and scroll down until you find the System.DirectoryServices.Protocols component name. Double click on that name (or select it and click on the OK button) to add a reference to that component into your project.
Once you've done that, you should find that the namespace appears in the Object browser even when browsing "My Solution" and you should find that the Imports statement now recognises the namespace.
1 ธันวาคม 2553 13:15
If its a web application then it will give you an error.
1) Take a web site add the refrence of the assembly which you need it will be compiled and the application will run.
2) If you are using web application then in your web.config add the following code.
<compilation debug="true" targetFramework="4.0" >
<add assembly="System.DirectoryServices, Version=188.8.131.52, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.DirectoryServices.AccountManagement, Version=184.108.40.206, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
21 สิงหาคม 2555 19:19
Please add the reference to System.DirectoryServices.
Under property Set Copy Local as true