Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

.NET Business Connector works on one machine, but not entirely on another to 2012

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have two different web servers hosting ASP.NET 4.x web applications that connect to an AX 2012 R2 instance using the .NET Business Connector. On server A, all functionality works: read, update, etc. On server B, using the exact same piece of code, most functionality works. However, one call to update a custom field in an existing record of SalesLine fails. Being Business Connector, I only get a generic error of on the ASP.NET webserver:

Exception of type 'Microsoft.Dynamics.AX.ManagedInterop.ErrorException' was thrown.
at Microsoft.Dynamics.BusinessConnectorNet.AxaptaRecord.Update()

The AOS server records NO errors for the failed call that we can find in Event Viewer. There's a bunch of validation logic on the update. When called from server A, it succeeds and completes the update after an average of 40-45 seconds. When called from server B, it fails after an average of 20-25 seconds. 

I have verified that the code being used and the business connector DLL files on both servers are the exact same. Configuration for both servers also appears to be identical. Further, all other functions from server B work just fine. I can read and update various tables and fields. Just this one function is causing problems, and only from one of the two servers.

Here's the code:

Axapta axp = new Axapta();
if(axp.Login()){
AxaptaRecord lineToModify = axp.CallStaticRecordMethod(
"SalesLine", "findRecId", saleslineid, true) as AxaptaRecord;

axp.TTSBegin();
lineToModify.set_Field("CustomFieldName", customFieldNewValue);
lineToModify.Update();            çFAILS ON THIS COMMAND
axp.TTSCommit();
lineToModify.Dispose();
axp.Logoff();
axp.Dispose();
}

Completely baffled and not sure where else to look to try and troubleshoot.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    We were unable to figure out the issue. We even engaged Microsoft support, but no luck. We eventually created a new VM patterned after the QA server that does work and it works just fine, so we moved the prod traffic onto the new VM. We gave up trying to figure out the why the other server refuses to successfully process Update calls. It wasn't worth investing more hours into. In the end, the only thing we could figure out was that there is something about that bad server that isn't installed correctly, despite all appearances showing that everything is installed just fine.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,735 Super User 2024 Season 2 on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    Hi BBlake,

    Just a follow up to see if you succeeded solving your issue. Can you update us on your latest 'other tweaks'?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    Update to clarify: The console app, running from the command line by itself, succeeded in updating the data. The DLL version swapped I tried in the ASP.NET app without luck. So next I tweaked the console app so I could pass in parameters and tried calling it from the asp.net app using Process.Start. It failed so far, but I'm going to try a couple other tweaks to that scenario to see if I can get something to work.  

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    Yes, always fails on B. There's only one AOS and no load balancer.

    Additional update: I created a small console app with only that function code in it to call that update. And it worked fine. I have tried swapping out the DLL files (32 bit versions vs 64 bit versions of businessconnector and interop) and the result is still the same. The call fails from the web app.

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    Hi BBlake,

    Does an update to salesLine always fails on server B? Do you have only one AOS or serveral? If several do you use load balancer?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    Yes, both servers using the same account to login and trying to hit the same company, sales line and values, which is the frustrating part. My first guess would have been some kind of permissions problem, but everything is all the same between the two. Still delving into debugging on the .NET and AX sides both and trying to extract a better error message in either place. We're also going to try reinstalling the BC on the failing server.

    This is perhaps the weirdest issue I've run into in 20 years of development.

  • Martin Dráb Profile Picture
    Martin Dráb 230,466 Most Valuable Professional on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    I would still recommend doing both things - checking the Message property and trying to debug code. Even if you believe that it fails before actually reaching application code, you can't be sure unless you test the assumption.

    By the way, do both servers use the same user account and did you test the behavior with the same data (same company, same sales line, same value)? If not, it's easy to imagine that the different context (permissions, data) cause different behavior.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    The only thing in the stack trace is what I posted above, no inner exceptions on the .NET side. My AX guy has been looking at the AX function, but since it works from one machine, but not another, he thinks it's related to the business connector. The problem is nothing changed on the two web servers over the weekend. No updates, no code changes, no patches. The only thing that changed was a deployment update in AX. But that still doesn't explain really why it works from one web server, but not the other.

  • Martin Dráb Profile Picture
    Martin Dráb 230,466 Most Valuable Professional on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    Did you check properties of ErrorException, such as Message and StackTrace?

    Have you tried to debug code inside Update()?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: .NET Business Connector works on one machine, but not entirely on another to 2012

    Can't disagree on the time, but I didn't write the function. However, I am not sure where to look for additional timeout settings. Is there something in the business connector config that I'm missing? I have verified that the ASP.NET app timeouts and IIS timeout are all much greater than that. And 20-25 seconds seems an odd timeout setting regardless.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans