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)

Error: "Function 'MakeSureDirectoryPathExists' in DLL library 'IMAGEHLP' has caused an exception"

(0) ShareShare
ReportReport
Posted on by

Dear all,

I am getting the above error message when i am running a batch process. This error message does not occur when i am executing the program normally.

The error message is caused when the control reaches below code:

DLL _winApiDLL = new DLL('IMAGEHLP');
DLLFunction MakeSureDirectoryPathExists = new DLLFunction(_winApiDLL, 'MakeSureDirectoryPathExists');
;

MakeSureDirectoryPathExists.returns(ExtTypes::DWord);
MakeSureDirectoryPathExists.arg(ExtTypes::String);

return MakeSureDirectoryPathExists.call(_path); ----->> this code causes the above error.

 


can any one help me with this ??

Regards,

Ajay K S

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    You would have to find out what exception was thrown. There is no generic solution for all possible errors.

    Nevertheless I strongly advise against using this antiquated API. Use .NET Interop instead of DLL* objects. Also note that several useful methods are already wrapped in WinAPIServer class (such as WinAPIServer::fileExists()). You'll see it's not only easier to use, but also easier to debug if necessary.

  • Community Member Profile Picture
    on at

    Dear Martin,

    Thanks for your reply.

    Currently i don't have the authority to change the code and this code is an old code which had been working fine till now.

    I have tried to understand what kind of exception is happening, but i haven't been able to find the reason.

    Do you know what causes this exception?

    Regards,

    Ajay K S

  • Suggested answer
    Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    Just rewriting it may be the most efficient approach...

    There surely is a reason why Microsoft have all WinAPI logic bound to client and use .NET API (sometimes wrapped in WinAPIServer) on server, including batches. I assume that you can't call WinAPI functions from server for some reason.

    Nevertheless you can try calling DLL::lastDLLError(); it may tell you more.

  • Community Member Profile Picture
    on at

    Hi Martin,

    I had tried using DLL::lastDLLError(); in catch portion.

    info(strfmt("%1",WINAPI::formatMessage(DLL::lastDLLError())));

    and it returns me the value "0", i-e, "The operation completed successfully".

    I am not able to figure out which exception is being thrown.

    Rewriting the code is fine but to do so i need to know the reason why this is happening.

    Till i figure that out i cannot rewrite the code.

    Regards,

    Ajay K S

  • Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    It doesn't work because WinAPI isn't supported on AOS. Or you can read it as "WinAPI isn't supported on AOS because it doesn't work".

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