代码之家  ›  专栏  ›  技术社区  ›  Sam

使用。WebJob定位中的NET Core 2.0库。NET Framework 4.7

  •  0
  • Sam  · 技术社区  · 7 年前

    我在中创建了许多类库。我想在我正在创建的新WebJobs项目中使用的NET Core 2.0。WebJobs项目的目标。NET Framework 4.7。

    具有标识的程序集“MyNetCore20Library”。。。使用的系统。运行时, '系统。运行时“具有标识”系统。运行时,版本=4.1.2.0, 文化=中性,公钥令牌=b03f5f11d50a3a'

    知道我怎么用我的吗。新WebJobs项目中的NET Core 2.0库?

    P、 不幸的是,我们还不能在美国创造网络就业机会。NET核心,这就是为什么我试图混合和匹配两个框架。我对此并不疯狂,但无论如何我应该能够做到。

    1 回复  |  直到 7 年前
        1
  •  2
  •   Brando Zhang    7 年前

    根据您的描述,我建议您可以尝试使用net core2.0控制台应用程序来创建web作业。

    1、创建net core 2.0项目。

    enter image description here

    2、更改控制台应用程序的主要方法代码如下:

    使用Microsoft。蔚蓝色的网络作业; 使用系统; 使用系统。IO;

    namespace NetCore2Webjob
    {
        class Program
        {
            static void Main(string[] args)
            {
                Environment.SetEnvironmentVariable("AzureWebJobsDashboard", "connection");
                Environment.SetEnvironmentVariable("AzureWebJobsStorage", "storage connection");
                var config = new JobHostConfiguration();
    
                if (config.IsDevelopment)
                {
                    config.UseDevelopmentSettings();
                }
    
                var host = new JobHost(config);
                host.RunAndBlock();
            }
    
    
        }
        public class Functions
        {
            public static void ProcessQueueMessage([QueueTrigger("myqueue")] string message, TextWriter log)
            {
                log.WriteLine(message);
            }
        }
    }
    

    3、点击〖发布〗按钮,发布控制台应用程序。

    enter image description here

    enter image description here

    dotnet {yourporjectname}.dll
    

    例子:

    dotnet NetCore2Webjob.dll
    

    6.打开webjobs门户并上载此zip。

    enter image description here

    结果:

    enter image description here