我遇到了非常简单的问题。
我想加载本地.NET 4类库(dll)项目,以用作我的新ASP.NET Web API项目中的资源(第一次尝试asp.net)
我熟悉Winforms应用程序,现在尝试创建一个ASP.NET Web API,以便能够从PHP / linux服务器访问我的一个帮助程序DLL。我不确定这是否是一个好方法,但我试图阻止在PHP代码中重新实现DLL的逻辑。
现在的问题是我无法将DLL或库类项目添加到Web API项目的资源中。
在尝试解决我尝试过的问题时:
错误CS0246找不到类型或命名空间名称“ClassLibrary1”(您是否缺少using指令或程序集引用?)WebApplication1.DNX Core 5.0
对我而言,它似乎正试图从nuget或其他东西中获取资源。
我希望有人可以轻易指出我的错误,这样我就可以继续处理实际工作了。 (或者我只是错过使用Web API概念?)
project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
},
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibraryTest2": "1.0.0-*"
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
答案 0 :(得分:1)
无需删除dnxcore50部分。
只需从dnx451中删除"ClassLibraryTest2": "1.0.0-*"
,然后在全局依赖项列表中添加依赖项。它将应用于dnx451和dnxcore50。
project.json看起来像这样:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"ClassLibraryTest2": "1.0.0-*"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
},
"frameworks": {
"dnx451": {
"dependencies": {
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}