0

I have console application and a class library build on Target Framework: .NET Framework 4.8. The class library implements the database operations. The programs runs fine locally but not when console application is published on app service using 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.

This is the app.config of my class library:

<?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.

Psychonaut007
  • 167
  • 3
  • 13

1 Answers1

0

I have create a webjob with add class library reference and its work fine as accepted. Check below code and output.

Console application Target Framework .Net Framework 4.8 and also 4.8 for class library.

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();
        }
    }
}

enter image description here

enter image description here

[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. you can check all assemblies load properly.

Mohit Ganorkar
  • 1,917
  • 2
  • 6
  • 11