Author Topic: Application.StartupPath not working in ACAD  (Read 1882 times)

0 Members and 1 Guest are viewing this topic.

inneedofhelp

  • Guest
Application.StartupPath not working in ACAD
« on: December 12, 2011, 02:37:05 PM »
i am trying to find the path where the exe was launched and i know that Application.StartupPath is in the basic VB system class . but when i imported the inventor and autodesk dll to the app it now says that it is does not exist in inventor. i need to know what import or DLL to force in so it will operate correctly or if there is another method that i need to use

SGP2012

  • Guest
Re: Application.StartupPath not working in ACAD
« Reply #1 on: December 12, 2011, 08:37:05 PM »
Hi inneedofhelp,

I started off by writing this reply to you ...

>>>
The System.Windows.Forms.Application class is available when you create a Winform application, but not when you create an AutoACD .NET DLL. The Autodesk.AutoCAD.Application class is completely different.

If you want to find the location that AutoCAD (acad.exe) is installed to from your AutoCAD .NET DLL, then one way is via the registry. For AutoCAD 2012 English, the AutoCAD location is stored in HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.2\ACAD-A001:409\AcadLocation. Call HostApplicationServices.Current.RegistryProductRootKey to return the registry key value related to the running AutoCAD instamnce your .NET DLL is loaded into.

If, on the other hand, you want to know the location of the .NET DLL you loaded into AutoCAD, take a look at the .NET Framework 'Assembly' class. On quick inspection, I'd say you need Assembly.Location property.

Of course, there may be a better way. What are you ultimately trying to achieve?
<<<

But then I reread your question and thought again. If you do have a Winform application (standalone executable), then you can't make use of the AutoCAD .NET managed assemblies (acmgd.dll and acdbmgd.dll). They have to be loaded into AutoCAD to work, so maybe you're trying to do something that is not possible. Or maybe you're using COM Interop from your exe - but then I'd expect the AutoCAD application class to be AcadApplicatiom, and not Application. So please clarify what type of application you've created, and which AutoCAD DLLs you're trying to reference?


GEURT

  • Guest
Re: Application.StartupPath not working in ACAD
« Reply #2 on: December 13, 2011, 01:45:57 AM »
See http://www.theswamp.org/index.php?topic=40192.0 thread for some help with application start-up path pointer.

Cheers
Geurt