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)

System.IO.IOException: The file exists - QRCode.Encoder.GetTempFile(String input)

(1) ShareShare
ReportReport
Posted on by 689

I got the problem when running the RDP report on LIVE (another environment still okay).

here is stack

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.IOException: The file exists.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Path.InternalGetTempFileName(Boolean checkHost)
   at Microsoft.Dynamics.QRCode.Encoder.GetTempFile(String input)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Dynamics.AX.ManagedInterop.ClrBridgeImpl.InvokeClrInstanceMethod(ClrBridgeImpl* , ObjectWrapper* objectWrapper, Char* pszMethodName, Int32 argsLength, ObjectWrapper** arguments, Boolean* argsAreByRef, Boolean* isException)

As far as I debug 

2017_2D00_02_2D00_09_5F00_16h34_5F00_43.png

2017_2D00_02_2D00_09_5F00_16h36_5F00_08.png

qrCodeReturn will return path of temp file, but error cause here. Try to delete AppData\Local\Temp, but It's didn't work. 

You could take a look at these standard method EInvoiceCFDIReportDP_MX.callQRCodeEncoder() and EInvoiceCFDIReportDP_MX.callQRCodeEncoderMethod(), current I'm using these code to create QR code report.

Thanks in advanced for your advise.

Max

*This post is locked for comments

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

    This may happen if your Temp folder contains too many files (more than 65535). If it's the case, simply clean up the folder. Just make sure you're working with the right Temp folder - get it from System.IO.Path::GetTempPath() or consult documentation.

  • Luan Nguyen Profile Picture
    689 on at

    Martin,

    thanks for your answer.

    I did delete AppData\Local\Temp folder on my user and It didn't work, as I mentioned before. I think this is a cross-application limitation.

    Do you have another advise?

    thanks,

    Max

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

    Your reply doesn't address my suggestion - have you verified that AppData\Local\Temp is the right folder? (See details in my previous reply.)

  • Luan Nguyen Profile Picture
    689 on at

    Martin,

    Yes, you were right.

    I got wrong folder. It wasn't current user folder. It used AOS user account, the function worked after deleting Temp folder.
    System.IO.Path::GetTempPath() this one just return current user domain temp folder.

    To prevent this error happen in future, we can use this code

    System.IO.File::Delete(tempFileName);
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Of course that GetTempPath() returns the temp folder of the current user, the point is that which folder it is depends on configuration; calling the method (in the same user context) shows you which folder is used by GetTempPath(), so you can work with the right folder.

  • Jose Eliseo Nunez Profile Picture
    29 on at

    Hi according your comments cleaning temp folder fix this issue, quick question this folder should be cleaned on the AOS where services ae running? and should be with service user?

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