C# 发布时出错,该错误在一两秒钟后消失,但发布仍然失败

C# 发布时出错,该错误在一两秒钟后消失,但发布仍然失败,c#,asp.net-mvc,visual-studio,hangfire,C#,Asp.net Mvc,Visual Studio,Hangfire,我有一个简单的ASP.NETMVC应用程序,我正在测试Hangfire库以运行一些后台任务。我按照Hangfire网站上的文档开始,一切正常,直到我试图发布应用程序。 我在发布应用程序“error CS0765:Partial methods with the Definiting declaration or removed conditional methods cannot used in expression trees”(仅具有定义声明或移除的条件方法不能在表达式树中使用)时遇到此错误

我有一个简单的ASP.NETMVC应用程序,我正在测试Hangfire库以运行一些后台任务。我按照Hangfire网站上的文档开始,一切正常,直到我试图发布应用程序。 我在发布应用程序“error CS0765:Partial methods with the Definiting declaration or removed conditional methods cannot used in expression trees”(仅具有定义声明或移除的条件方法不能在表达式树中使用)时遇到此错误,它指向my startup.cs中的hello world行

public class Startup
   {
       private IEnumerable<IDisposable> GetHangfireServers()
       {
           GlobalConfiguration.Configuration
               .UseSqlServerStorage("carouselTest", new SqlServerStorageOptions
               {
                   CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
                   SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
                   QueuePollInterval = TimeSpan.Zero,
                   UseRecommendedIsolationLevel = true,
                   DisableGlobalLocks = true // Migration to Schema 7 is required
       });

           yield return new BackgroundJobServer();
       }
       public void Configuration(IAppBuilder app)
       {
           app.UseHangfireAspNet(GetHangfireServers);
           app.UseHangfireDashboard();

           // Let's also create a sample background job
           BackgroundJob.Enqueue(() => Debug.WriteLine("Hello world from Hangfire!"));
       }
   }
公共类启动
{
私有IEnumerable GetHangfireServers()
{
全局配置
.UseSqlServerStorage(“carouselTest”),新的SqlServerStorageOptions
{
CommandBatchMaxTimeout=TimeSpan.FromMinutes(5),
SlidingVisibilityTimeout=时间跨度从分钟(5),
QueuePollInterval=TimeSpan.Zero,
UseRecommendedIsolationLevel=true,
DisableGloballock=true//需要迁移到模式7
});
返回新的BackgroundJobServer();
}
公共无效配置(IAppBuilder应用程序)
{
应用程序UseHangfireAspNet(GetHangfireServers);
app.UseHangfireDashboard();
//我们还将创建一个示例后台作业
BackgroundJob.Enqueue(()=>Debug.WriteLine(“来自Hangfire的你好世界!”);
}
}
应用程序在本地构建并运行良好,但发布时会出现此错误,然后在一两秒钟后消失,但发布仍然失败

这里发生了什么?我需要向global.asx添加一些内容吗?我只添加了OWIN startup.cs,因为它是hangfire的仪表板所必需的