What I am using:
Windows 7 32 bit
AutoCAD 2012
Visual Studio 2010
ObjectARX .NET 2012 (Upgraded from 2011 when I started running into this error, and created new project with code below to ensure the most up to date files are being used)
.NET 4.0 (not client in build settings)
I am writing some software to automate some drawing processes based on information from a database and excel files. I am finding that the AutoCAD .NET portion of the programming is taking about 99% of the design and troubleshooting time with its insane API and bizarre errors. So I have narrowed my few thousand lines of code to one simple program, with only one line of code. This is a completely stand alone project with nothing but the 2012 libraries referenced (copylocal is false) using the wizard.
Two questions that should not have to be asked in the first place: Why and how do I fix? :realmad:
As far as the class goes I have tried every combination of static/non static and session flags with no difference on the result.
The error information:
tempDb = {Autodesk.AutoCAD.DatabaseServices.Database}
ApproxNumObjects = 'tempDb.ApproxNumObjects' threw an exception of type 'System.AccessViolationException'
base {System.SystemException} = {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}
// (C) Copyright 2011 by
//
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(Test.MyCommands))]
namespace Test
{
public class MyCommands
{
[CommandMethod("MyCommand")]
public static void MyCommand()
{
Database tempDb = new Database(false, true);
}
}
}