我有一个.Net核心MVC Web应用程序解决方案。我收到运行时错误说:
类型' System.IO.FileNotFoundException'的例外情况发生在ILRetail.eBusiness.WealthFactfind.BusinessLogic.dll但未在用户代码中处理
其他信息:无法加载文件或程序集&ILHetail.eBusiness.Common.CRMServiceBroker,Version = 1.0.6135.15742,Culture = neutral,PublicKeyToken = null'或其中一个依赖项。系统找不到指定的文件。
我已将建筑物拆分为4个不同的项目。包含视图,模型,控制器(即表示层)的Web项目。我有一个业务逻辑和数据项目,代表那些特定的层。我还有一个代理项目与middletier服务进行交互。
我设置的引用遵循相同的模式,即Web引用业务逻辑,业务逻辑引用数据项目,数据引用代理项目。这使得层之间的分离清晰。该解决方案正确编译但它似乎没有将代理项目dll拉入web项目的bin文件夹,即使整个代码都被引用。有一个从Web到业务逻辑到数据项目和代理项目的调用。
即使数据项目不是Web项目的参考,数据项目dll也会被拉入Web bin文件夹。所以一些功能正在发挥作用,但它似乎没有更进一步,并将代理项目dll拉进来。
如果我编译业务逻辑项目,它会将代理项目dll拉入此bin文件夹。如果有意义的话,编译器似乎不会超过2级。因为它将引用对该项目的引用的引用,但不引用对该项目的引用的引用,即A - > B - > C没问题,但不是A - > B - > C - > d
我可以很容易地解决这个问题,使代理项目成为Web项目的参考,但这会打破我的分离,我不应该这样做。
如果它在这里有任何不同,那么代码是使用数据项目中代理项目的功能:
public class CRMServiceBrokerWrapper
{
public static string GetUserInformationFromCRM(string userId)
{
var crmServiceWrapperTyper = typeof(ILRetail.eBusiness.Common.CRMServiceBroker.CRMServiceWrapper); // Trying to create some sort of link so the compiler knows this reference is definitely used!
ICRMServiceWrapper service = new CRMServiceWrapper(ServiceUrl);
return service.GetUserInformation(userId);
}
}
编辑: Project.json按要求:
{
"dependencies": {
"log4net": "1.2.10",
"Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Http.Extensions": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.Session": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "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"
},
"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"
},
"frameworks": {
"net46": {
"dependencies": {
"HtmlUtility": {
"target": "project"
},
"Utility": {
"target": "project"
},
"WealthFactfind.BusinessLogic": {
"target": "project"
},
"WealthFactfind.Model": {
"target": "project"
},
"WebUtility": {
"target": "project"
}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"StyleCopTreatErrorsAsWarnings": false,
"define": [ "CODE_ANALYSIS" ]
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config",
"WebVersion.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}