muhammadmobeen

The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Hello, I am using eSignLive in my UWP project. It was working fine last couple of weeks before. But now it throwing an exception at eslClient = new EslClient(API_KEY, API_URL); Exception: The type initializer for 'log4net.Core.LoggerManager' threw an exception. My code is as below

       private string API_URL = string.Empty;
        private string API_KEY = string.Empty;
        private static EslClient eslClient;
private void Button_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            try
            {
               API_URL = "https://sandbox.esignlive.com/api";
                API_KEY = "M2JPbjpXQVlOmE3N3VIenhJVQ==";

                eslClient = new EslClient(API_KEY, API_URL);

            }
            catch (Exception ex)
            {
             }
        }
Any help would be appreciated. Thanks

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Hi, I am assuming you trimmed down the API key correct?
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
I just changed api key only for post. If you ask I can give you my account api key.

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
No, that's fine. Can you please share the complete exception (including the inner exception)? Thanks,
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Exception: {System.TypeInitializationException: The type initializer for 'log4net.Core.LoggerManager' threw an exception. ---> System.MethodAccessException: Attempt by method 'log4net.Core.LoggerManager.RegisterAppDomainEvents()' to access method 'System.AppDomain.add_ProcessExit(System.EventHandler)' failed. at log4net.Core.LoggerManager.RegisterAppDomainEvents() at log4net.Core.LoggerManager..cctor() --- End of inner exception stack trace --- at log4net.Core.LoggerManager.GetLogger(Assembly repositoryAssembly, String name) at log4net.LogManager.GetLogger(Assembly repositoryAssembly, String name) at log4net.LogManager.GetLogger(Type type) at Silanis.ESL.SDK.Support..ctor() at Silanis.ESL.SDK.EslClient..ctor(String apiKey, String baseUrl) at eSignLiveWorkUWP.EmailDocForSignature.GetESignCredentials()} InnerException: {System.MethodAccessException: Attempt by method 'log4net.Core.LoggerManager.RegisterAppDomainEvents()' to access method 'System.AppDomain.add_ProcessExit(System.EventHandler)' failed. at log4net.Core.LoggerManager.RegisterAppDomainEvents() at log4net.Core.LoggerManager..cctor()} Inner Exception Message: Attempt by method 'log4net.Core.LoggerManager.RegisterAppDomainEvents()' to access method 'System.AppDomain.add_ProcessExit(System.EventHandler)' failed. InnerException StackTrace: at log4net.Core.LoggerManager.RegisterAppDomainEvents() at log4net.Core.LoggerManager..cctor()

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
I have also provided my code project to Ankur Barthakur. Thanks

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
case #00107263 - Code project attached.

Attachments

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Thanks, I will have a look and get back to you when I have more info.
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
And just for my information, did you make any modifications to your code between the time it worked and stopped working?
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
no change

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Can you send me the following dll file "Syncfusion Controls for UWP XAML"? You can send it to [email protected]
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
My mistake. Its an extra assembly, please remove this. Thanks

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
I don't get any errors. Is there anything specific that I should do to reproduce the issue?
Haris Haidary OneSpan Technical Consultant

Attachments

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
But I am getting this error. I am using VS-Professional 2017 version 15.6.6, .NET Framework 4.7.03056. and Target version Build 16299.

Attachments

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
I use VS Community 2017 version 15.7.3, .NET Framework 4.7.02046. Try re-compiling the code with a lower framework version see if that helps. And are you using the latest .NET SDK?
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
yes I am using latest .NET SDK. I will recompile this with back version and will update you.

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
I have updated .NET SDK. Ok, I will recompile this with back version and will update you.

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Dear Haris, I tested this with VS Community 2017 Version 15.5.4, .NET Framework Version 4.7.02556. It also throwing same issue. It is requested to you that please help me to solve this issue firstly because I have spent much more time to resolve it but unfortunately I could not. So, it is humble request to you that please give me the code snippet through which I can upload and download documents. I am waiting your reply. Thanks

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
You can find below the code snippets for downloading and uploading documents: https://developer.esignlive.com/guides/feature-guides/document-management/ https://developer.esignlive.com/guides/feature-guides/retrieving-documents/ Do you have another version of log4net defined in your project?
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Also, the .NET SDK doesn't have any dependency on the log4net library. You'll need to remove that from your project if you have it defined.
Haris Haidary OneSpan Technical Consultant

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Haris my friend, I am still diving into this issue. I have no idea how to resolve this. your provided links not working for me. Because they just tell me about methods to upload and download which is not my issue. My issue is that code throwing exception at the time of object creation. My code is attached with this. Can you please run this code at your machine and test it with credentials in code.
EslClient eslClient = new EslClient(API_KEY, API_URL);
Syncfusion assemly is in "DocumentTemp" folder. Thanks

Reply to: The type initializer for 'log4net.Core.LoggerManager' threw an exception.

0 votes
Dear Haris, I embedded latest eSignLive DLL v11.15.0.0 in my project. Now it is throwing new exception “Could not load type 'System.Net.ServicePointManager' from assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'” I tested this code at nearly all my machines but getting same issue. Haris my friend, have you tested this code at your machine? Would you like to share testing result with me? Thanks

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off