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

'ReadDwgFile' throws memory corruption exception

11 REPLIES 11
Reply
Message 1 of 12
cabbi
1371 Views, 11 Replies

'ReadDwgFile' throws memory corruption exception

I'm working with VS 2008 and AutoCAD 2006. I compile my plugin DLL using framework 2.0. I did everything discussed in http://discussion.autodesk.com/thread.jspa?messageID=5955432 and http://discussion.autodesk.com/thread.jspa?threadID=633031 threads but did not solve my problem, when I call 'ReadDwgFile' and exception is thrown!!! 😞

I also did anything possible with the acad.exe.config file, commented uncommented and set the different framework versions!!!

I also get the error when compiling in release mode and run AutoCAD without VS.

Any help is appreciated!!!

Cabbi
11 REPLIES 11
Message 2 of 12
Grasshopper
in reply to: cabbi

Face the same problem, "eRepeatedDwgRead" exception
Message 3 of 12
cabbi
in reply to: cabbi

I got a different exception: eFileInternalErr

Isn't that you call twice the ReadDwgFile function on the same database object?

Cabbi
Message 4 of 12
Anonymous
in reply to: cabbi

cabbi wrote:
> I'm working with VS 2008 and AutoCAD 2006. I compile my plugin DLL using framework 2.0. I did everything discussed in http://discussion.autodesk.com/thread.jspa?messageID=5955432 and http://discussion.autodesk.com/thread.jspa?threadID=633031 threads but did not solve my problem, when I call 'ReadDwgFile' and exception is thrown!!! 😞
> I also did anything possible with the acad.exe.config file, commented uncommented and set the different framework versions!!!
> I also get the error when compiling in release mode and run AutoCAD without VS.

We recently ran into this problem as well. The cause is service pack 1
(SP1) for .Net 2.0/3.0. Using .Net 1.1 will also not have this issue,
but you can't use .Net 1.1 with VS 2008.
The only way we've been able to resolve it is to reinstall .Net 2.0/3.0
and not apply the service pack.

--
Joel Lucsy
CAD fx
810-732-0085 or 877-741-2175
http://www.cadfx.com
Message 5 of 12
cabbi
in reply to: cabbi

Every drafter's PC should be reinstalled and on each of these PCs automatic update should be disabled. IT policy in our company does not allow this!

So there is no other solution?

I also tried to use the 'Open' method but when I save the document, again I got an exception!?!? 😞

Is this issue solved in AutoCAD 2008???

Cabbi
Message 6 of 12
dmarcotte4
in reply to: cabbi

Interesting, this code works fine on my machine. Using VS2008 .NET 3.5 and Acad2006.
I never touched the acad.exe.config file, Maybe if you posted your code, we can find the problem


[CommandMethod("doit")]
public static void doit()
{
Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
try
{
using (Database db = new Database(false, true))
{
db.ReadDwgFile(@"C:\64.dwg", FileShare.Read, true, "");
AcDb.TransactionManager Tm = db.TransactionManager;

using (Transaction tr = Tm.StartTransaction())
{
BlockTable tb = (BlockTable)tr.GetObject
(db.BlockTableId, OpenMode.ForRead, false);

BlockTableRecord btr = (BlockTableRecord)tr.GetObject
(tb[BlockTableRecord.ModelSpace], OpenMode.ForRead, false);

foreach (ObjectId id in btr)
{
DBObject dboject = (tr.GetObject(id, OpenMode.ForWrite));
dboject.DowngradeOpen();
}
}
db.CloseInput(true);
}
}
catch(System.Exception ex)
{
ed.WriteMessage("\n" + ex.Message);
ed.WriteMessage("\n" + ex.StackTrace);
}
}
Message 7 of 12
cabbi
in reply to: cabbi

So, I did some more testing placing more traceing lines:
1. when I debug with VS I get the memory corruption exception on the 'ReadDwgFile'
2. when I do not debug I get 'eFileInternalErr' exception on the db.Save() method

I'm quite sure case 2. is my fault... I'll do some more testing!

Thanks a lot for your suggestion, now I know 'ReadDwgFile' works if not debugging!!! 🙂

Cabbi
Message 8 of 12
Grasshopper
in reply to: cabbi

Database database = new Database(false,true);

try to use this code to creat the database, it may avoid the the ReadDwgFile exception.

When I add the db.save() method, the same problem occur. I just want to add a entity into the unopen dwg, how to do this?
Message 9 of 12
Grasshopper
in reply to: cabbi

Save() method has not been implemented yet, try SaveAs()...
It works well in my environment
Message 10 of 12
cabbi
in reply to: cabbi

Yes, SaveAs works also for me!!!

Now without debugging with VS my plugin works fine! 😉

Cabbi Message was edited by: cabbi
Message 11 of 12
Anonymous
in reply to: cabbi

The Save() method of the Database is not implemented, and
you must use the SaveAs() method instead.

You also should never save the file directly back to the same
file you read from. Instead, save it to another temporary file
in the same location, then after you dispose() of the Database
(or call CloseInput), you can delete the original file and then
rename the saved file to that name.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5956577@discussion.autodesk.com...
So, I did some more testing placing more traceing lines:
1. when I debug with VS I get the memory corruption exception on the 'ReadDwgFile'
2. when I do not debug I get 'eFileInternalErr' exception on the db.Save() method

I'm quite sure case 2. is my fault... I'll do some more testing!

Thanks a lot for your suggestion, now I know 'ReadDwgFile' works if not debugging!!! 🙂

Cabbi
Message 12 of 12
Grasshopper
in reply to: cabbi

Very appreciate

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