我想在ASP.NET Web应用程序中引用System.DirectoryServices
。具体来说,我想在活动目录(https://msdn.microsoft.com/en-us/library/ms180890(v=vs.90).aspx)上关注本教程,但我在添加对System.DirectoryServices.dll的引用时遇到问题。我想我应该将它添加到我的project.json中,但我将各种问题添加到适当的位置。我的project.json如下。
{
"userSecretsId": "aspnet-FormsAuthAd-b19f2b08-0c89-4f46-af20-dc7b20b2226d",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0",
"Microsoft.EntityFrameworkCore.Sqlite.Design": {
"version": "1.0.0",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
}
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"precompile": [ "dotnet bundle" ],
"prepublish": [ "bower install" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tooling": {
"defaultNamespace": "FormsAuthAd"
}
}
我应该在哪里以及如何向project.json添加System.DirectoryServices
依赖项?
答案 0 :(得分:0)
您可以将project.json中的import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.Map;
public class Test {
public static void main(String[] args) throws IOException {
String str = "{\"versions\": {\"ap\": \"Not Set\", \"am\": \"topic-test-publisher-1.0.16\", \"il\": \"topic-test-publisher-1.0.16\", \"row\": \"topic-test-publisher-1.0.49\"}, \"provider\": \"gce\"}";
ObjectMapper objectMapper = new ObjectMapper();
Version v = objectMapper.readValue(str, Version.class);
System.out.println(v.versions.get("am"));
}
public static class Version {
public Map<String, String> versions;
public String provider;
}
}
部分用于您要定位的框架。例如:
frameworkAssemblies
请记住,通过执行此操作,您将在GAC中引用完整.NET Framework的程序集。这意味着您的项目将不再在.NET Core上运行,并且只能在Windows上运行。 "frameworks": {
"net462": {
"frameworkAssemblies": {
"System.DirectoryServices": {
"type": "build",
"version": "4.0.0"
}
}
}
}
尚不支持.NET Core。
答案 1 :(得分:0)
汇编引用将自动添加到project.json文件中
注意:强> 目前,System.DirectoryServices 4.0.0与.NET Core不兼容。
<强> Project.json:强>