在我们当前的 Umbraco Cloud 项目中,我们使用 Hangfire 库(1.6.17) - lib具有 OWIN 依赖关系( 1.0.0)。
以下是调用hangfire启动的代码:
在我们当前的项目中,我们使用的是Hangfire库(1.6.17) - lib具有OWIN依赖性(1.0.0)。
以下是调用hangfire启动的代码:
using Microsoft.Owin;
using Owin;
using Umbraco.Web;
using Hangfire;
using Hangfire.Dashboard;
using Hangfire.Annotations;
using Umbraco.Core.Models;
using Umbraco.Core;
using System.Web;
[assembly: OwinStartup(typeof(XX.Web.Core.Startup))]
namespace XX.Web.Core
{
public class Startup : UmbracoDefaultOwinStartup
{
public override void Configuration(IAppBuilder app)
{
//ensure the default options are configured
base.Configuration(app);
var cs = Umbraco.Core.ApplicationContext.Current.DatabaseContext.ConnectionString;
GlobalConfiguration.Configuration.UseSqlServerStorage(cs);
app.UseHangfireDashboard("/umbraco/backoffice/hangfire", new DashboardOptions
{
Authorization = new[] { new UmbracoUserAuthorisedFilter() },
AppPath = "/Umbraco"
});
app.UseHangfireServer();
}
}
public class UmbracoUserAuthorisedFilter : IDashboardAuthorizationFilter
{
public bool Authorize([NotNull] DashboardContext context)
{
// In case you need an OWIN context, use the next line,
// `OwinContext` class is the part of the `Microsoft.Owin` package.
//var context = new OwinContext(owinEnvironment);
// Allow all authenticated users to see the Dashboard (potentially dangerous).
//return context.Authentication.User.Identity.IsAuthenticated;
//this if you want to lock down to admins only
var userService = ApplicationContext.Current.Services.UserService;
var user = userService.GetByUsername(HttpContext.Current.User.Identity.Name);
return user.IsAdmin();
//this if you just want to make sure user is logged into backoffice
//return UmbracoContext.Current.Security.CurrentUser != null;
}
}
}
这是能够使用该库的默认hangfire启动代码。代码在2台本地计算机上运行良好,一台Azure Web App实例,但是当我将此代码推送到Umbraco Cloud分支时,我收到以下错误:
无法加载文件或汇编' netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51'或其中一个依赖项。系统找不到指定的文件。
问题是:我们没有使用.net标准,两个项目(网络和核心)都使用.net框架4.6.2
该问题是否有解决方法?