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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to find the source of 'Specified cast is not valid' error properly

(0) ShareShare
ReportReport
Posted on by 314

Hi all, my name is Antony.
When I open the 'Production control -> All production order' menu on AX365, the error 'Specified cast is not valid' appears.

3124.pastedimage1623568506842v1.png

The error also appears when I click estimate/release/start/RAF/end production order, when the dialog form appears as shown below.

8105.pastedimage1623568571687v2.png

I tried to find the source of the error by debugging -> attach to process w3wp.exe.

7635.pastedimage1623568737180v6.png

Then in Exception Settings -> System.InvalidCastException I checked the checkbox.

8623.pastedimage1623570443315v7.png

Then when I try to produce the error in Onebox, the error doesn't appear on the Call Stack tab.

7610.pastedimage1623568695238v5.png

The error only appears on the Output error tab, so it doesn't explain where the error is coming from.

3681.pastedimage1623568620765v3.png

Do you have any suggestions friend, what is the right way to find the source of the error?
Any advice would be very helpful to me.

Thank you and Regards, Antony.

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,257 Most Valuable Professional on at

    Are you attaching debugger to the right process? Shouldn't you attach to iisexpress?

    Also, maybe it's an X++ exception, not System.InvalidCastException. What if you add breakpoints to Info.add() and Message::Add()? (Make sure that your Visual Studio is configured to load symbols for objects outside your solution.)

    By the way, please ask quesions about D365FO in one of D365FO forums, not in AX forum. I moved this thread to Dynamics 365 Finance Forum.

  • Michael Antony Profile Picture
    314 on at

    Hi Martin,
    thank you for your advice, it worked for me.
    I read in here https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-find-the-name-of-the-aspnet-process?view=vs-2019
    for IIS version 6.0 and above I could using w3wp.exe.
    I also changed some settings in Options for debugging by following this guide dynamics365musings.com/.../.
    And finally it worked for me.

    Thank you and Best regards,
    Antony

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 688

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 524 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 301

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans