TheSwamp
Code Red => .NET => Topic started by: teslaxx on February 03, 2011, 06:43:23 AM
-
Hello,
I have a net dll, which has been developed with visual studio 2008, language c#. When I tried it on a windows 7 64 bits it does absolutely nothing, it gives no errors, but does absolutely nothing when you type the commands. Commands are not recognized and it does not change the default system menu in autocad.
I set platform target: Any CPU and all the Autocad references have the setting: Copy Local set to false
-
So, you do see ""Unknown Command" prompt at command line when trying to execute a custom command defined in the loaded DLL, right?
One possible reason for this issue: does the loaded DLL contain a class that is an ExtensionApplication (e.g. it implements IExtensionApplication interface)? If yes, do you have code doing something in the implemented Initialize() method (I guess you do, if a class does implement IExtensionApplication)? Then, do you have try...catch{} block that wraps up all code in Initialize()?
If there is an exception occurs in Initialize() without being caught, AutoCAD simply silently jumps out Intialize() and then the loaded DLL becomes useless, thus the commands defined in it can not be recognised by AutoCAD.
-
Nope, is not working. Some behavior.
-
It does work on 32 bit or XP/Vista?
Is your class public?
-
Is your class public?
Other possible failure modes:
Is your method public?
Takes it void and returns it void? (Had that in F#: last statement didn't return unit, then the overall signature of the command method wasn't unit->unit)
As already mentioned, does your class implement IExtensionApllication, without exception handling?
-
Yes, all my classes are public and my dll are working on XP.
-
Do you have your build options set to "Any CPU"?
-
Other to check ...
If you use the arx/net wizard and end up adding something like:
[assembly: CommandClass(typeof(YourNamespace.Commands))]
Make sure to have this line added in all your classes, where you have command methods calls.
Or, simple remove all those calls.
... hth maybe
-
Another:
If you have some assemblies that are required to be side by side with your assembly app, check that.
I have to sometimes to rebuild or to make sure I am loading the latest build, when testing/debugging code on my 32 or 64 machines.
... hth maybe
-
Another
Having a commands defined in two classes
-
Another ..
spelling.
-
Seeing the solution files may help someone resolve the issue.
Or creating a mini-solution that demonstrates your problem.
-
Another ..
spelling.
Thats why I use the Tab key
I can't spell :oops:
-
For all the questions above: Yes and checked. :-)
Once again. The "thing" is working on Windows XP, Windows 7(32Bits), but not on the Windows7(64bits)
P.S. And yes, I set to Any CPU and all the suggestions you... suggested.
-
For all the questions above: Yes and checked. :-)
Once again. The "thing" is working on Windows XP, Windows 7(32Bits), but not on the Windows7(64bits)
P.S. And yes, I set to Any CPU and all the suggestions you... suggested.
What am I, chopped liver ??
Seeing the solution files may help someone resolve the issue.
Or creating a mini-solution that demonstrates your problem.
-
Hahahahahah :-D
So funny!!
I attached a mini Project!
On W7 on 32bits, it's working fine.
Now, it seems that Autocad dies if I load the dll file on W7 on 64bits.
-
You are using P/Invoke:
[DllImport("acad.exe", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl, EntryPoint = "?acedPostCommand@@YAHPB_W@Z")]
extern static public int acedPostCommand(string strExpr);
First of all check EntryPoint string for AutoCAD x64. It's look like EntryPoint = "?acedPostCommand@@YAHPEB_W@Z"
-
Thank you Alex. Now, I can load the .dll file and I can see the menu.
But..
When I enter the command from the menu, it's dies instantly.
When I enter the command in the command menu, it's show "Select the..." and after 1 seconds, it's dies.
-
Sorry. I has not AutoCAD x64. That is why I can not test your's code. Try to start transaction AFTER selection of entities.
-
I haven't looked closely at the code yet ..
Your pre-compiled debug DLL loaded into AC2011 x64
The Menu Loads and can be accessed via Right-Click
I got this while running myMethod after selecting 2 lines.
************** Exception Text **************
System.MissingMethodException: Method not found: 'Void Autodesk.AutoCAD.DatabaseServices.Entity.IntersectWith(Autodesk.AutoCAD.DatabaseServices.Entity, Autodesk.AutoCAD.DatabaseServices.Intersect, Autodesk.AutoCAD.Geometry.Point3dCollection, Int32, Int32)'.
at MyNameSpace.Helper.Intersectare(Entity entity1, Entity entity2)
at MyNameSpace.Helper.myMethod() in C:\Users\iMac\Documents\Visual Studio 2008\Projects\MiniSolution\MiniSolution\Helper.cs:line 54
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.CommandClass.CommandThunk.Invoke()
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4952 (win7RTMGDR.050727-4900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
acdbmgd
Assembly Version: 18.1.0.0
Win32 Version: 18.1.49.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/AcdbMgd.DLL
----------------------------------------
Have you tried to debug this yourself ??
-
I haven't had the time for this problem.
Now, I have :)
I know I receive a similar exception (referring to IntersectWith method) and I changed the references from ObjectARX 2011 to 2010 and it worked.
-
Are you saying that in spite using AutoCAD2011, you have to use AutoCAD2010's DLLs as references (because of Win7 64-bit)? It is strange, isn't it?
I haven't had the time for this problem.
Now, I have :)
I know I receive a similar exception (referring to IntersectWith method) and I changed the references from ObjectARX 2011 to 2010 and it worked.
-
I haven't had the time for this problem.
Now, I have :)
I know I receive a similar exception (referring to IntersectWith method) and I changed the references from ObjectARX 2011 to 2010 and it worked.
AutoCAD 2011 Update 1.1 (http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=15569492&linkID=9240618) must resolve this problem.
-
Are you saying that in spite using AutoCAD2011, you have to use AutoCAD2010's DLLs as references (because of Win7 64-bit)? It is strange, isn't it?
No. When I changed the references from ObjectARX 2010 to ObjectARX 2011, I observed that exception when I was using the IntersectWith method.
So, I was received this error, no matter what operating system I was using.
...
Have you tried to debug this yourself ??
I don't have a Windows 7 on 64bits at my disposal. The only thing I can do is asking the person to run my dll. :)
AutoCAD 2011 Update 1.1 (http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=15569492&linkID=9240618) must resolve this problem.
I will try your suggestion. :)
Thank You for your responses! :) Have a nice week-end.
-
Now I have XP 64-bit here running 2010 Mechanical and I ran it and worked no problem.
Mind you its not Win7 and its not 2011. Though just wanted to say it did work :)
-
Are you saying that in spite using AutoCAD2011, you have to use AutoCAD2010's DLLs as references (because of Win7 64-bit)? It is strange, isn't it?
No. When I changed the references from ObjectARX 2010 to ObjectARX 2011, I observed that exception when I was using the IntersectWith method.
So, I was received this error, no matter what operating system I was using.
...
Have you tried to debug this yourself ??
I don't have a Windows 7 on 64bits at my disposal. The only thing I can do is asking the person to run my dll. :)
AutoCAD 2011 Update 1.1 (http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=15569492&linkID=9240618) must resolve this problem.
I will try your suggestion. :)
Thank You for your responses! :) Have a nice week-end.
Did this issue get resolved? I'm having the exact same problem. I've tried everything everyone has suggested, up to the AutoCAD 2011 update and recompiling with the 2011 objectARX, which will be the next step for me.
Thanks..
-
Hi,
Isn't this related to the fact the Entity.IntersectWith() method has different signatures for 32 and 64 bit platforms ?
The Entity.IntersectWith() two last arguments are typed as Int32 on 32 bit and Int64 on 64 bits.
Tony Tanzillo provided a 'PlatformCompatibilityExtensionMethods' static class to insure a compatible method: C# (http://www.caddzone.com/PlatformUtils.cs) and VB (http://www.caddzone.com/PlatformUtils.vb).
-
I don't have Entity.IntersectWith() in my code. My dll does, however run under 32 bits on XP with AutoCAD 2010, but the same code gives me "unknown command" when run under 64bit on Windows7 and AutoCAD 2011.
-
I'm attaching a copy of the code. I tried the AutoCAD update, but that didn't make a difference. I also tried both the 2010 and 2011 ObjectARX references; it doesn't make a difference.
I am compiling with Vis Studio 2008 on 32bit XP machine. My client is running W7, 64-bit 2011 AutoCAD Mechanical with update 1 (which includes update 1.1 for AutoCAD). I have access to a test machine that's running XP, AutoCAD 2011 (not mechanical), 32 bit, and this code works on that machine, compiled with ObjectARX 2010.
This code is copied from the video that shows how to convert VBA to VB.Net; it's in several places on the web. And it works on my test machine, but not on my client's machine.
The specific line of code that's creating the error is:
aDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.AcadDocument
If I comment out that line, recompile, netload my dll, and type TST, I get "This is a TST command". However, the BeginCommand and EndCommand code still don't display Begin and End Command.
If I leave that line in the code, recompile and netload my dll, and type TST, I get "unknown command".
So.. it's got something to do with referencing the acadDocument. But again, it works on my test machine - just not my client's.
Any ideas?
Thanks for your time.
-
Why you have to use COM API (AcadApplication/AcadDocument) and handle the COM object event? COM API code, not like .NET code that works with both 32-bit and 64-bit system, is bit-specific. Since you develop with 32-bit Acad, it would not run with 64-bit AutoCAD.
You can do what you want (catch event before and after a command is executed) with pure .NET API: Document.CommandWillStart/CommandEnded.
I am pretty much against the propaganda of saying how easy it would be to move VBA code to .NET code. Most of such saying is abuse COM API and does learning AutoCAD .NET API programming bad than good.
I'm attaching a copy of the code. I tried the AutoCAD update, but that didn't make a difference. I also tried both the 2010 and 2011 ObjectARX references; it doesn't make a difference.
I am compiling with Vis Studio 2008 on 32bit XP machine. My client is running W7, 64-bit 2011 AutoCAD Mechanical with update 1 (which includes update 1.1 for AutoCAD). I have access to a test machine that's running XP, AutoCAD 2011 (not mechanical), 32 bit, and this code works on that machine, compiled with ObjectARX 2010.
This code is copied from the video that shows how to convert VBA to VB.Net; it's in several places on the web. And it works on my test machine, but not on my client's machine.
The specific line of code that's creating the error is:
aDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.AcadDocument
If I comment out that line, recompile, netload my dll, and type TST, I get "This is a TST command". However, the BeginCommand and EndCommand code still don't display Begin and End Command.
If I leave that line in the code, recompile and netload my dll, and type TST, I get "unknown command".
So.. it's got something to do with referencing the acadDocument. But again, it works on my test machine - just not my client's.
Any ideas?
Thanks for your time.
-
I thought as long as you included the 64-bit references instead of the 32-bit, it would still work. Is this incorrect?
I will try changing the begin/end to the document.commandWillStart/CommandEnded, as you suggested.
I still need thisDrawing.adoc set, though, since it's used in a few hundred places in the code. Or is there a way around it without using COM API? How else can you reference it?