1

現在のUmbraco Cloudプロジェクトでは、Hangfireライブラリ (1.6.17) を使用しています。このライブラリにはOWIN依存関係 (1.0.0) があります。

hangfire の起動を呼び出すコードは次のとおりです。

現在のプロジェクトでは、Hangfire ライブラリ (1.6.17) を使用しています。このライブラリには 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 つのローカル マシン、1 つの Azure Web App インスタンスで正常に動作していますが、このコードを Umbraco クラウド ブランチにプッシュすると、次のエラーが発生します。

ファイルまたはアセンブリ 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' またはその依存関係の 1 つを読み込めませんでした。システムは、指定されたファイルを見つけることができません。

問題は、.net 標準を使用しておらず、両方のプロジェクト (Web とコア) が .net フレームワーク 4.6.2 を使用していることです。

その問題の回避策はありますか?

ここに画像の説明を入力

4

0 に答える 0