LayoutManager.Current gives 'Common Language Runtime detected an invalid program.' Why?

LayoutManager.Current gives 'Common Language Runtime detected an invalid program.' Why?

QNashJSRL8
Contributor Contributor
715 Views
3 Replies
Message 1 of 4

LayoutManager.Current gives 'Common Language Runtime detected an invalid program.' Why?

QNashJSRL8
Contributor
Contributor

Dim pasteDwg As AcadDocument
Dim acadApp As AcadApplication
acadApp = GetObject(, "AutoCAD.Application.24.2")
pasteDwg = acadApp.ActiveDocument
Dim lm As LayoutManager = LayoutManager.Current

The second it hits LayoutManager.Current I get hit with COmmon Language Runtime Detected an Invalid program
I have these imports
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
*Note Runtime and APplication serverices are greyed out and considered unnecessary but I believe I will need them.

0 Likes
Accepted solutions (1)
716 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant

Hi,

You cannot access to the .NET API (e.g. Autodesk.AutoCAD.DatabaseServices) from a standalone application (exe).

To be able to acces to the .NET API, you have to build a class library project (DLL) and NETLOAD it in a runing AutoCAD session.

See this topic.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4

QNashJSRL8
Contributor
Contributor

Thank you for the quick response. 


So, checking if I understand correctly, I want to use AuctoCAD.Interop methods and objects when talking to AutoCad?

My end goal is to create layouts from a given template, identify the templates several viewports in paper space and put some alignments from model space into the viewports depending on specific criteria. I think I need layout manager for this but is there another way. Would you know a substitute for layout manager?

0 Likes
Message 4 of 4

_gile
Consultant
Consultant
Accepted solution

@QNashJSRL8 wrote:

I want to use AuctoCAD.Interop methods and objects when talking to AutoCad


If so, you're stack to the COM/ActiveX API which does not provide any 'LayoutManager'.

Have a look at the ActiveX Developer's Guide and the ActiveX Reference Guide.

 

While using the COM/ActiveX API (more in VB), you should post in the VBA forum.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes