"Not enough quota is available to process this command" exception when calling Document.CloseAndDiscard or AcadApplication.Documents.Open

"Not enough quota is available to process this command" exception when calling Document.CloseAndDiscard or AcadApplication.Documents.Open

sflemingK8CWD
Explorer Explorer
410 Views
1 Reply
Message 1 of 2

"Not enough quota is available to process this command" exception when calling Document.CloseAndDiscard or AcadApplication.Documents.Open

sflemingK8CWD
Explorer
Explorer

I am a developer for an ACA plugin and recently I've been experiencing an infrequent issue with using Document.CloseAndDiscard and AcadApplication.Documents.Open where I sometimes get this error:

sflemingK8CWD_0-1699890770390.png

If I try to continue past this popup AutoCAD Architecture crashes. 

The code that I am running is like this

void CloseDrawing()
{
   Document activeDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
   activeDoc.CloseAndDiscard(); // sometimes crashes here
}

void OpenDrawing(string fullFileName)
{
   AcadApplication acadApp = (AcadApplication)Application.AcadApplication;
   Autodesk.AutoCAD.Interop.IAcadDocument baseDwg;
   baseDwg = acadApp.Documents.Open(fullFileName, true, null); // sometimes crashes here
   baseDwg.Activate();
}

This problem is something that I have only been able to reproduce in AutoCAD Architecture 2022, but since I can't consistently reproduce this I cannot confidently say that the issue exists only in 2022 and not previous versions as well.

 

Has anyone experienced this issue before, or have any idea what could cause this? My code base is so large that I have no idea where to begin looking for what could be contributing to this error since the exception is originating from an AutoCAD method.

 

Below is the call stack and last unhandled exception from dumpuserinfo.xml

 

-----Current Stack:
at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)
at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at Autodesk.AutoCAD.ApplicationServices.DocumentExtension.CloseInternal(Document doc, Boolean discard, String fileName)
at MyProgram.a()

at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

 

-----Last Unhandled Exception:

-----Last 3 'first chance' exceptions (may not be related to the crash if they were handled):
-----Last-0 'first chance' exception:
System.ComponentModel.Win32Exception (0x80004005): Not enough quota is available to process this command
at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)

 

This is a duplicate of a post I made on the AutoCAD Architecture Forum since that was the wrong forum to ask my question. My original post can be found here: https://forums.autodesk.com/t5/autocad-architecture-forum/quot-not-enough-quota-is-available-to-proc...

0 Likes
411 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

I hope that if you have these 2 methods (CloseDrawing()/OpenDrawing()) used as generally shared code, you have remembered very well that they are ONLY used when your code in the AutoCAD plugin runs in APPLICATION CONTEXT, not in DOCUMENT CONTEXT

 

Since you did not show or mention how these 2 methods are called, I am not sure if the AutoCAD error/crash is due to the methods being called in document context: if you do, they would crash AutoCAD for sure. So you have to look into it. OTH, if you do understand Application context and Document context well and calls the 2 methods only in Application context, the error would be a bit of mystical: I never saw something like this (mentioned "enough quota..."). Again, showing more relevant code where these 2 methods are called might be helpful.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes