Can't use PrincipalContext in C# [duplicate] - c#

This question already has answers here:
System.DirectoryServices is not recognised in the namespace 'System'
(9 answers)
The type or namespace name 'Device' does not exist in the namespace 'System'
(4 answers)
The type or namespace name 'DirectoryServices' does not exist in the namespace?
(9 answers)
Closed 1 year ago.
I'm trying to create a login page for my project in the company using the Active Directory accounts of my company. I'm trying to use the PrincipalContext() but tried to import it and error won't go away.
Is there any way to use PrincipalContext on c#?
Tutorials and other source code in my company uses vb.net.

It may not be installed on your system. For this
1. Right Click Project.
2. Manage NuGetPackages.
3. Search for System.DirectoryServices.I
4. Install System.DirectoryServices.AccountManagement

Related

Error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (CS0234) [duplicate]

This question already has answers here:
Type or namespace name does not exist [closed]
(17 answers)
The type or namespace name does not exist in the namespace 'System.Web.Mvc'
(23 answers)
Closed 2 years ago.
first time using Visual Studio, I just received a new project and trying to run it. I get the following error Error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) (CS0234).
Any help would be much appreciated,
Thank you
Based on my research, maybe you are using the following similar code, which needs the namespace System.DirectoryServices.AccountManagement.
PrincipalContext context = new PrincipalContext(ContextType.Domain, "Company");
As usual, we have two ways to solve it.
First, as others suggested, you can install nuget-package System.DirectoryServices.AccountManagement.
Second, you can use visual-studio intellisense like the following:

Namespace "Microsoft.SqlServer.MessageBox" Does Not Exist [duplicate]

This question already has answers here:
Microsoft.ExceptionMessageBox not being "found"
(2 answers)
Closed 4 years ago.
I'm trying to use the Microsoft.SqlServer.MessageBox.ExceptionMessageBox class for an application.
After putting using Microsoft.SqlServer.MessageBox; at the top of my program like this documentation stated, I got the following error:
The type or namespace name 'SqlServer' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Trying to add a reference to the required assembly like this cite said didn't help either; the DLL wasn't present, nor was the folder it was supposed to be in.
Question: How do I fix this issue?
You may need to dd a reference to the below assembly.
Microsoft.ExceptionMessageBox.dll
You might have to browse for it.The default installation directory is C:\Program Files\Microsoft SQL Server\##\SDK\Assemblies.

Class library C# [duplicate]

This question already has answers here:
C# using others code
(4 answers)
Closed 5 years ago.
I made a blank solution in C#( without any project ) and I added two Class Library Projects named "PersonLibrary" and "AnotherLibrary". The problem is that when I try to access the PersonLibrary from AnotherLibrary with: "using PersonLibrary;" I get this error: The type or namespace name "PersonLibrary" could not be found.
1
If you go to AnotherLibrary -> References -> Add Reference, you should see an option to add projects in solutions and add PersonLibrary .
Once you add a reference, You can use whatever the available methods.

Using System.Windows.Forms gives me an error message [duplicate]

This question already has answers here:
'Forms' does not exist in the namespace system.windows
(7 answers)
Closed 8 years ago.
"The type or namespace name 'Forms' does not exist in the namespace
'System.Windows' (are you missing an assembly reference?)"
I'm sorry, this is probably a dumb question but I'm totally new to C# and visual studio.
Any suggestions on how to fix this ?
I need this for a plugin in Revit.
Just figured it out. I need to add a reference to my project in the solution tree.
Sorry about that

I can't use system.windows.control namespace [duplicate]

This question already has answers here:
c# Where can find System.Windows.Controls.dll
(3 answers)
Closed 8 years ago.
I'm trying to add a reference to the namespace System.Windows.Controls in a library project, but i can't find it in the list. Does anybody know what is going on? i'm using 4.0. I want to add system.window.controls.dll but the library is not complete, how can i make it complete?
You have to look for this System.Windows.Controls.Data.dll assembly. In this assembly, there is the namespace you are looking for.
In general, a namespace and it's types may be in an assembly with different name than the namespace name.

Categories