[英]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.