Asp.net 5(vNext)如何将活动目录与System.DirectoryServices一起使用 [英] Asp.net 5 (vNext) How to use active directory with System.DirectoryServices
问题描述
我正在使用VS 2015和Asp.net 5,但遇到了问题.
I m playing with VS 2015 and Asp.net 5 but I have an issue.
我无法在Asp.net 5中使用System.DirectoryServices.
I am not able to use System.DirectoryServices in Asp.net 5.
同时使用System.DirectoryServices和DirectoryEntry test = new DirectoryEntry();线没有用红色下划线作为错误,但是当我尝试构建解决方案时,我得到了这样的错误
Both using System.DirectoryServices and DirectoryEntry test = new DirectoryEntry(); lines are not underlined with red as an error but when I try to build solution I get error such
错误CS0234在名称空间系统"中不存在类型或名称空间名称"DirectoryServices"(是否缺少程序集引用?)ConsoleApp.ASP.NET Core 5.0 Program.cs 2
Error CS0234 The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?) ConsoleApp.ASP.NET Core 5.0 Program.cs 2
我的默认project.json就像
My default project.json was like
{
"version": "1.0.0-*",
"dependencies": {
},
"commands": {
"run": "run"
},
"frameworks": {
"aspnet50": { },
"aspnetcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-22231"
}
}
}
}
我将其更改为
{
"version": "1.0.0-*",
"dependencies": {
},
"commands": {
"run": "run"
},
"frameworks": {
"aspnet50": {
"frameworkAssemblies": {
"System.DirectoryServices": ""
}
},
"aspnetcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-22231"
}
}
}
}
我的program.cs是
My program.cs is
using System;
using System.DirectoryServices;
namespace ConsoleApp
{
public class Program
{
public void Main(string[] args)
{
Console.WriteLine("Hello World");
DirectoryEntry test = new DirectoryEntry();
Console.ReadLine();
}
}
}
谢谢.
推荐答案
当前ASP.net Core并不支持所有程序集.您的project.json文件同时启用了ASP.net core和ASP.net50.
Currently Not all assemblies are supported for ASP.net Core. Your project.json file has both enable ASP.net core and ASP.net50.
如果从框架中删除aspnetcore50,则您的代码将起作用.
If you remove aspnetcore50 from frameworks then your code will work.
{
"version": "1.0.0-*",
"dependencies": {
},
"commands": {
"run": "run"
},
"frameworks": {
"aspnet50": {
"frameworkAssemblies": {
"System.DirectoryServices": ""
}
}
}
这篇关于Asp.net 5(vNext)如何将活动目录与System.DirectoryServices一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!