.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoLISP .Net Function causes System.InvalidProgramException

1 REPLY 1
Reply
Message 1 of 2
RIdleyTechnology
479 Views, 1 Reply

AutoLISP .Net Function causes System.InvalidProgramException

I am trying to write some code in .Net that is to be called by AutoLISP. The code retrieves data from a database that AutoLISP then uses to draw some parameterised objects. The .Net code is replacing a VB6 implementation that was written a long time ago and which is not compatible with our company’s Windows 7/x64 image. The AutoLISP code is still good so we don’t want to waste resources rewriting that in .Net.

 

The .Net Solution references AcCoreMgd.dll and AcDbMgd.dll and uses the ResultBuffer and TypedValue types. The code includes the [LispFunction(“myMethodName”)] attribute and compiles without any errors or warnings. Unfortunately attempting to execute any code that contains the ResultBuffer and TypedValue types ends up throwing an InvalidProgram exception. ‘Watching’ any variables of these types typically shows:+ Value    'caseNameTV32.Value' threw an exception of type 'System.InvalidProgramException'     object {System.InvalidProgramException}. Any ‘Watched’ variables will show this even before the code is executed.

 

Researching 'System.InvalidProgramException' indicates that there could be a problem with the MSIL, possibly due to the compiler that created the dlls. Running PEVerify on AcCoreMgd.dll and AcDbMgd.dll shows many errors, particularly on AcCoreMgd.dll (PEVerify output attached).

 

Can anyone offer any guidance on the cause or how to fix this?

 

Why are these errors occurring? I would hope that it is unlikely that AutoDesk would make defective dlls available.

 

I am fairly sure that I have downloaded the latest version of the dlls.

 

Is the source code available so I can try compiling with Visual Studio 2012?

 

1 REPLY 1
Message 2 of 2

From the error message you showed:

 

C:\Users\hbaj065\Documents\Visual Studio 2012\Projects\AutoCAD KIPS Link 64\AutoCAD KIPS Link 64\bin\Debug\AcDbMgd.dll

 

I assume that "AutoCAD KIPS Link 64" is the name of your Visual Studio project. It seems that you have included the AutoCAD .NET API assemblies (accoremgd.dll, acdbmgd.dll and acmgd.dll) in the build output (e.g. the "Copy Local" property of the references to these assemblies is set "True". That could be the reason: if these DLLs is from downloaded ObjectARX SDK, then these DLLs are for "development" only. They only contains classes' signatures of properties/methods without internal implemetation.

 

If you compare the same dlls from SDK and the ones in AutoCAD installation folder, you would notice the files sizes of those from SDK are smaller.

 

Since the actual .NET API DLLS are installed with AutoCAD, when doing your .NET add-ins, you do not need these .NET DLLs being included in your output. I the case of using these DLLs from SDK, you MUST NOT include them in the output. Thus, the "COPY LOCAL" must be set to "False".

 

BTW, these issue has been mentioned in this forum many, many times.

 

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost