简体   繁体   English

当我添加对 class 库项目的引用时,为什么我的 webjob 失败了?

[英]Why my webjob is failing when I am adding reference to class library project?

I have console application and a class library build on Target Framework : .NET Framework 4.8 .我有控制台应用程序和基于目标框架构建的 class 库: .NET Framework 4.8 The class library implements the database operations. class 库实现数据库操作。 The programs runs fine locally but not when console application is published on app service using publish azure webjob .程序在本地运行良好,但在使用publish azure webjob在应用服务上发布控制台应用程序时无法正常运行。 The error message is:错误信息是:

 [06/24/2022 17:36:29 > fa1ef8: SYS INFO] Status changed to Initializing [06/24/2022 17:36:34 > fa1ef8: SYS INFO] Run script 'WinSCP.exe' with script host - 'WindowsScriptHost' [06/24/2022 17:36:34 > fa1ef8: SYS INFO] Status changed to Running [06/24/2022 17:36:43 > fa1ef8: SYS INFO] Status changed to Failed [06/24/2022 17:36:43 > fa1ef8: SYS ERR ] Job failed due to exit code -1073740771

But when i am removing the reference of my class library and commenting the referenced code then it works fine.但是当我删除我的 class 库的引用并评论引用的代码时,它工作正常。

This is the app.config of my class library:这是我的 class 库的 app.config:

 <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77089" requirePermission="false" /> </configSections> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework"> <parameters> <parameter value="System.Data.SqlServerCe.4.0" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" /> </providers> </entityFramework> <system.data> <DbProviderFactories> <remove invariant="System.Data.SqlServerCe.4.0" /> <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=8984c91" /> </DbProviderFactories> </system.data> <appSettings> <add key="EhrApiBaseUrl" value="http://something/api/" /> <add key="EhrUsername" value="xyz@xyz.com" /> <add key="EhrPassword" value="xyz" /> <add key="FCMServerKey" value="xyz" /> <add key="FCMSenderId" value="xyz" /> <add key="App" value="web" /> </appSettings> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Google.Apis" publicKeyToken="4b01db77ab" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.40.0.0" newVersion="1.40.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b0134db77ab" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.40.0.0" newVersion="1.40.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b11" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Memory" publicKeyToken="cc7b12ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b1ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7bddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.5.1" newVersion="4.0.5.1" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7dd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b12ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b1d2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Identity.Client" publicKeyToken="0a619e8ae" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.30.1.0" newVersion="4.30.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Azure.Core" publicKeyToken="9272e44c8" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.23.0.0" newVersion="1.23.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Azure.Storage.Common" publicKeyToken="9274244c8" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-12.10.0.0" newVersion="12.10.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup><system.serviceModel> <bindings> <basicHttpBinding> <binding name="IInnovaServicebinding" /> </basicHttpBinding> </bindings> <client> <endpoint address="http://1.1.1.1/xyz/xyz.dll/xyz/xyz" binding="basicHttpBinding" bindingConfiguration="IInnovaServicebinding" contract="InnovaService.IInnovaService" name="IInnovaServicePort" /> </client> </system.serviceModel> </configuration>

Can you please suggest me how should I deal with this error when no log is being created in Azure Storage because the program is failing before start.您能否建议我在 Azure 存储中未创建日志时应如何处理此错误,因为程序在启动前失败。

I have create a webjob with add class library reference and its work fine as accepted.我已经创建了一个带有添加 class 库参考的网络作业,并且它的工作正常被接受。 Check below code and output.检查下面的代码和 output。

Console application Target Framework.Net Framework 4.8 and also 4.8 for class library.控制台应用程序 Target Framework.Net Framework 4.8 以及 class 库的 4.8。

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using ClassLibrary2; namespace ConsoleApp5 { internal class Program { static void Main(string[] args) { Console.WriteLine("Application Start"); Class1 class1 = new Class1(); foreach(var val in class1.list) { Console.WriteLine(val.ToString()); } Console.WriteLine("Add value in list"); for(int i= 6;i < 10; i++){ class1.list.Add(i ); Thread.Sleep(1000); Console.WriteLine("Add value in Database Table " + (i)); } Console.WriteLine("Print value after add value in Database Table"); foreach (var val in class1.list) { Console.WriteLine(val.ToString()); } Console.ReadLine(); } } }

在此处输入图像描述

在此处输入图像描述

 [07/04/2022 10:01:12 > ec2b20: INFO] Application Start [07/04/2022 10:01:12 > ec2b20: INFO] 1 [07/04/2022 10:01:12 > ec2b20: INFO] 2 [07/04/2022 10:01:12 > ec2b20: INFO] 3 [07/04/2022 10:01:12 > ec2b20: INFO] 4 [07/04/2022 10:01:12 > ec2b20: INFO] 5 [07/04/2022 10:01:12 > ec2b20: INFO] Add value in list [07/04/2022 10:01:13 > ec2b20: INFO] Add value in Database Table 6 [07/04/2022 10:01:14 > ec2b20: INFO] Add value in Database Table 7 [07/04/2022 10:01:15 > ec2b20: INFO] Add value in Database Table 8 [07/04/2022 10:01:16 > ec2b20: INFO] Add value in Database Table 9 [07/04/2022 10:01:16 > ec2b20: INFO] Print value after add value in Database Table [07/04/2022 10:01:16 > ec2b20: INFO] 1 [07/04/2022 10:01:16 > ec2b20: INFO] 2 [07/04/2022 10:01:16 > ec2b20: INFO] 3 [07/04/2022 10:01:16 > ec2b20: INFO] 4 [07/04/2022 10:01:16 > ec2b20: INFO] 5 [07/04/2022 10:01:16 > ec2b20: INFO] 6 [07/04/2022 10:01:16 > ec2b20: INFO] 7 [07/04/2022 10:01:16 > ec2b20: INFO] 8 [07/04/2022 10:01:16 > ec2b20: INFO] 9

your application cannot start due to problem while loading some .net assemblies.在加载一些 .net 程序集时,您的应用程序无法启动。 you can check all assemblies load properly.您可以检查所有程序集是否正确加载。

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

相关问题 Azure appservice 添加 webjob 失败 - Azure appservice adding webjob failing 在 Azure Function 项目中添加对类库的引用导致未找到程序集 - Adding Reference to Class LIbrary in Azure Function project causes assembly not found 将现有项目添加为Azure Webjob“将webjob添加为Web应用程序时,找不到Microsoft.Web.WEbJobs.Publish软件包的1.0.12版” - Adding Existing Project as Azure Webjob “unable to find version 1.0.12 of package Microsoft.Web.WEbJobs.Publish when adding as webjob to web app” 使用lxml的Azure WebJob一直失败...为什么? - Azure WebJob using lxml keeps failing…why? 为什么 webjob 失败,退出代码为 532462766? - Why webjob is failing with exit code 532462766? 为什么在创建 QueueTrigger WebJob 函数时会看到 FunctionIndexingException? - Why do I see a FunctionIndexingException when creating a QueueTrigger WebJob Function? 当我添加 System.Runtine 4.3.1 时,Nuget 对 System.ComponentModel.Composition 的引用不正确 - Incorrect Nuget Reference to System.ComponentModel.Composition when I am adding System.Runtine 4.3.1 为什么未计划我的Azure WebJob? - Why isn't my Azure WebJob scheduled? 为什么我的webjob在不引发异常的情况下终止? - Why is my webjob terminating without throwing an exception? 为什么我的 azure webjob 没有登录到存储 blob? - why is my azure webjob not logging to the storage blob?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM