0

We are working on a .NET Core solution where the request comes in to do some communications with Dynamics AX 2009.

In AX we have some static methods that we need to call from within our solution. In other .NET Framework solutions we used the Business Connector that gets installed with AX. This was always working fine but now in the .NET Core solution we got exception during Autofac resolving:

Autofac.Core.DependencyResolutionException: 
An exception was thrown while invoking the constructor 'Void 
.ctor(Core.Configuration.AppConfig, Core.Logging.ILogger)' on type
'AxConnectionProvider'. ---> System.BadImageFormatException: Could not load file or assembly
'Microsoft.Dynamics.BusinessConnectorNet, Version=5.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35'. An attempt was made to load a program with an incorrect format. 

Which is correct because the Business Connector is not supported in .NET Core.

But how can we solve this issue in order to work with AX 2009 and call static methods from within our .NET Core solution?

We have a .NET Standard library where we included all AX code and where we included the Business Connector dll as a reference.

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
Mivaweb
  • 5,580
  • 3
  • 27
  • 53
  • Can you just use your `.NET Standard` library as a proxy and call it from your `.NET Core` solution? Have you proven your standard library works correctly? – Alex Kwitny Feb 02 '21 at 16:18
  • What I did is create a class inside this class library which calls the Business Connector and does all kinds of operations. But then in Autofac in my ASP.NET Core website I need to register this proxy class to be used in other services and there I got the exception. The Business connector is in the output folder. Current solution I did was to create a separated internal ASP.NET WebAPI in .NET Framework which contains all the Business Connector related operations. Then I call this using a Typed HttpClient from within my .NET Core project. – Mivaweb Feb 03 '21 at 06:30
  • See this question - https://stackoverflow.com/questions/65779152/is-it-possible-to-use-azure-service-bus-with-azure-ad-not-adfs-for-exposing-ax. You could ignore the AzureRelay part unless you wanted to use it. I believe AX2009 has WCF services, you could just use them as connected services with your ASP.NET Core application and be done. You could skip the BC all together. – Alex Kwitny Feb 03 '21 at 17:50

0 Answers0