Just curious if this is currently the only version of AutoCAD installed on this machine? If so has it ever had any other version installed on it?
I'm not sure. Is it possible that the invisible AutoCAD session is trying to get user input, like asking the user to select the template file for the new drawing or something?
Would it be possible for you to attach the smallest version of your code that still has the error so that I can try it here?
Actually I don't think it does, anyway I attached the code you asked for, the exception occures at line 63.
It is working every time for me, the only thing that I did see that I would change is cleaning up after accessing the Acad Object. I added this to the end of what you have.
Finally Try acApp.Application.Quit() System.Runtime.InteropServices.Marshal.ReleaseComO
bject(acApp) GC.Collect() GC.WaitForPendingFinalizers() Catch ex2 As Exception MsgBox(ex2.Message) End Try
Please note that if this was going to run several times a minute I would not call the garbage collector on it every time.
I don't know what to do. although the sleep function somehow solved this problem too, but I am convinced that this solution is not the best way handle this problem.
Thank you all for your support.
I want to provide some information about my system that my be useful.
Windows 7 Home Premium (64-bit edition)
Microsoft Visual Studio 2010 Ultimate
AutoCAD 2012 Structural Detailing (64-bit version)
and I have AutoCAD VBA Enabler installed too
can these information help?
Well, I am able to run your code (with my message filter code) without incident.
I am developing on WinXP 32 bit, with AutoCAD 2012, Visual Studio 2010 Professional.
I also built the program (with "Any CPU" as the Target platform) and ran it on a Windows 7 Professional 64 bit, with AutoCAD 2012 64 bit.
Neither my dev machine nor the users machine has the VBA enabler installed, but I can't imagine that being the problem.
Might I suggest you try what I did and see what happens. To run your code, I had to create a form and stick a button on it, but then I added a ListBox control, and added a line to the ListBox in each of the message filter functions, and as status updates as the code went through your process. I have attached my modified version. Try adding a ListBox to your form and running this new code, to see if you get any messages in the ListBox.
Actually your code worked without any error, here is a summarized version of it's output (I replaced the listbox with a textbox in order to be able to copy from it):
Pending: (336 times)
AutoCAD Started:18.2s (LMS Tech)
Pending: (2 times)
Pending: (48 times)
Pending: (3 times)
Pending: (2 times)
Pending: (5 times)
I tested it repeatedly and it worked every time, that is weird because your code is not different from my code.
I can't concentrate right now, I will test your code thoroughly tomorrow and I'll post any problem that might occur.
Thank you very much