Reply
Member
Posts: 5
Registered: ‎04-09-2021
Accepted Solution

The type initializer for 'AuthorizeNet.Api.Controllers.Bases.ApiOperationBase`2' threw an exception

We are using .NET 3.1 and the .NET Core SDK Beta for our integration solution and are experiencing a vague error message when the following line attempts to execute. I'm not sure how to proceed. Any insight would be great.

 

ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;

 

TypeInitializationException: The type initializer for 'AuthorizeNet.Api.Controllers.Bases.ApiOperationBase`2' threw an exception.

AuthorizeNet.Api.Controllers.Bases.ApiOperationBase<TQ, TS>.set_RunEnvironment(Environment value)

MissingMethodException: Method not found: 'Microsoft.Extensions.Logging.ILoggerFactory Microsoft.Extensions.Logging.DebugLoggerFactoryExtensions.AddDebug(Microsoft.Extensions.Logging.ILoggerFactory, Microsoft.Extensions.Logging.LogLevel)'.

AuthorizeNet.Utilities.LogFactory.get_LoggerFactory()

 

 


Accepted Solutions
Solution
Accepted by topic author xEtMN7LmLyFMhB
‎04-09-2021 12:45 PM
Member
Posts: 5
Registered: ‎04-09-2021

Re: The type initializer for 'AuthorizeNet.Api.Controllers.Bases.ApiOperationBase`2' threw an except

If anyone runs into this problem in the future, my pull request below makes the minor changes needed for this to at least run in .NET Core 3.1+. 

 

.NET Core 3.1+ Compatibility by michaelbernat · Pull Request #20 · AuthorizeNet/dotnet-core-sdk-beta...

View solution in original post


All Replies
Member
Posts: 5
Registered: ‎04-09-2021

Re: The type initializer for 'AuthorizeNet.Api.Controllers.Bases.ApiOperationBase`2' threw an except

Issue was that the .NET Core SDK does not fully support .NET Core 3.1. Some of the method calls in the SDK were deprecated in the 2.x releases of .NET Core, so I downloaded the SDK source and corrected these. After publishing the changes to a nupkg, it's working like a charm. Still have a long ways to go with integration but at least this roadblock is cleared ;)

Solution
Accepted by topic author xEtMN7LmLyFMhB
‎04-09-2021 12:45 PM
Member
Posts: 5
Registered: ‎04-09-2021

Re: The type initializer for 'AuthorizeNet.Api.Controllers.Bases.ApiOperationBase`2' threw an except

If anyone runs into this problem in the future, my pull request below makes the minor changes needed for this to at least run in .NET Core 3.1+. 

 

.NET Core 3.1+ Compatibility by michaelbernat · Pull Request #20 · AuthorizeNet/dotnet-core-sdk-beta...

New Member
Posts: 3
Registered: ‎04-12-2021

Re: The type initializer for 'AuthorizeNet.Api.Controllers.Bases.ApiOperationBase`2' threw an except

We are using .NET 3.1 and the .NET Core SDK Beta for our integration solution and are experiencing a vague error message when the following line attempts to execute.