web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

"Failed to initialize the managed interoperability layer of Microsoft Dynamics AX." - Only on Windows Service

(0) ShareShare
ReportReport
Posted on by 15

Hi everyone,

I made a Windows Service using Microsoft .Net for integrating some stuff, but I'm facing some problems:

I have this DLL on which I connect to Dynamics Ax (2012 R3) using business connector, using Axapta.LogOn() method. 

When I call this routine using a Console Application, it works fine; but when I call the same method of the same library using a Windows Service, it throws me the error "Failed to initialize the managed interoperability layer of Microsoft Dynamics AX.".

The console application and the service were executed with the same credentials.

I've checked this thread, but as I checked, the Business Connector is installed both on my local machine and on the server.

I've tried a couple of things too (none of them changed the error message):

  • Copying the business connector locally on the Service installer
  • Copying Microsoft.Dynamics.AX.ManagedInterop.dll locally
  • Changed the build from x64 to x86
  • Running the service setup as administrator

I've runt out of ideas... Anybody has any idea of what can I try?

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Douglas Noel Profile Picture
    3,905 on at

    Hi,

    maybe some hints.  I don't know what exactly the problem is.

     

    If you are speaking of a Windows 'NT' Service  (ServiceControlManager) you should keep in mind that is is 'normally' a non-interactive application. (Exception is when you allow interaction with a windows desktop)

     

    The difference to an interactive application is the following:

     

    Regardeless of using Logon or LogonAs (using the proxy account and simulate another ax user) the configuration for the connection to AOS is drawn from the HKLM hive in registry (Shown as configuration target 'BusinessConnector (non-interactive use only) within Dynamics Ax 2012 client configuration utility in that case, if you don't specify a dedicated configuration file within Logon(.....

     

    You can use both Logon and  LogonAs methods from the services.

     

    for example:

     

    the BC.Logon(string.Empty, string.Empty, string.Empty, string.Empty); will draw the default configuration from 

    HKLM\Software\Microsoft\Dynamics\6.0\Configuration\(contentofcurrentvalue)

     

    in an interactive application the value is drawn from HKCU hive

    HKCU\Software\Microsoft\Dynamics\6.0\Configuration\(contentofcurrentvalue)

    Maybe this is the problem?

    BTW: You can specify a configuaration (even an axc file) within Logon, using this mechanism the code should run interactive and non interactive

    And some more keep in mind:  You cannot  'swap'  the connection during execution of the process (a service seems to be always running). So you can do a Logon and a Logoff, but not a further Logon to another connection (AOS)

    regards - sorry no more ideas

    Douglas

  • Suggested answer
    Joao Luiz dos Reis Santos Profile Picture
    15 on at

    Thanks for the reply,

    Your response gave me an insight of using LogonAs instead of LogOn and that apparently did the trick!

    Thank you very much

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans