简体   繁体   English

Hangfire + ASP.NET MVC

[英]Hangfire + ASP.NET MVC

This is my first time posting here. 这是我第一次在这里发帖。

I am currently writing an ASP.NET MVC application (using .NET 4.5.2 and MVC 5). 我目前正在编写一个ASP.NET MVC应用程序(使用.NET 4.5.2和MVC 5)。 I want to integrate Hangfire into my project. 我想将Hangfire整合到我的项目中。 I have set up a side project which worked. 我已经建立了一个可行的辅助项目。 But when I tried to integrate it into my main project, several errors occurred. 但是,当我尝试将其集成到我的主项目中时,发生了一些错误。 They are: 他们是:

  1. The .dll files had to be strong-named (I fixed this issue by using ildasm/ilasm to strong name them. I replace the original files that came with the nuget package.) .dll文件必须使用强名(我使用ildasm / ilasm对其进行强命名来解决此问题。我替换了nuget软件包随附的原始文件。)

  2. After strong-naming and replacing the files, I ran into another error. 在强命名并替换文件后,我遇到了另一个错误。 When I tried to build and run the solution, a 'GlobalConfiguration' does not exists in the current context, and also a are you missing an assembly reference error is thrown. 当我尝试构建和运行解决方案时,当前上下文中不存在“ GlobalConfiguration”,并且您是否遗漏了程序集引用错误。

I have tried various ways to solve this, but to no avail. 我尝试了各种方法来解决此问题,但无济于事。 I would really like some advice on this ! 我真的很想对此提出建议! Thanks ! 谢谢 !

GlobalConfiguration is a class in the Hangfire namespace. GlobalConfigurationHangfire命名空间中的类。 You should import the namespace so that you can use it (and the extension methods it provides) 您应该导入名称空间,以便可以使用它(及其提供的扩展方法)

using Hangfire;

So now code like this will work: 因此,现在这样的代码将起作用:

GlobalConfiguration.Configuration.UseSqlServerStorage("MyConnectionString");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM