<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Corrupt Memory Error in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442502#M71562</link>
    <description>I'm afraid your code looks OK.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I think you should post a bit more, the things we can see in this code are ok.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However, we don't know what is happening in &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DataBox.Draw()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;InsertDataBoxPointBlock()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And that is probably where the issue is.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you don't want to post the entire code, post the specific AutoCAD interactions...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;http://cupocadnet.blogspot.com</description>
    <pubDate>Sat, 07 Mar 2009 18:08:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-03-07T18:08:50Z</dc:date>
    <item>
      <title>Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442494#M71554</link>
      <description>I need help in trying to track down an elusive bug.  I’ve written a fairly sophisticated c# routine that creates blocks based on data stored in a database.  My users have discovered that they can run the routine once to successfully create the blocks in their drawings.  But if they try to run the routine a second time on the same drawing before closing this drawing, an error appears when the routine is trying to commit the transaction.  The error that comes up is “Attempted to read or write protected memory” and then AutoCAD will crash.  If the user saves and closes the drawing before running the routine a second time, the error does not appear.&lt;BR /&gt;
&lt;BR /&gt;
I’ve done some searching on this forum and the internet for the answer and have implemented some changes to my application to try to solve this issue.  One of the first measures I did was to make sure that I’ve disposed all objects that I’ve accessed through the GetObject(OpenMode) method and not dispose any object opened by a transaction.  Then I made sure that my code was not accessing the block table or the modelspace record more than once at the same time in my routine.  The error still occurs as before.&lt;BR /&gt;
&lt;BR /&gt;
I use selection sets occasionally in my application to retrieve existing blocks.  Should I be disposing of any of the objects associated with the selection sets?&lt;BR /&gt;
&lt;BR /&gt;
What other measures can I take to try to solve this issue?&lt;BR /&gt;
&lt;BR /&gt;
Any help would be greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Stephen</description>
      <pubDate>Thu, 05 Mar 2009 13:17:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442494#M71554</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T13:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442495#M71555</link>
      <description>This isn't a TV game show.&lt;BR /&gt;
&lt;BR /&gt;
Without seeing your code or little or nothing about it,&lt;BR /&gt;
there's nothing anyone here can tell you.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;FLETCHMAN&gt; wrote in message news:6136619@discussion.autodesk.com...&lt;BR /&gt;
I need help in trying to track down an elusive bug. I've written a fairly &lt;BR /&gt;
sophisticated c# routine that creates blocks based on data stored in a &lt;BR /&gt;
database. My users have discovered that they can run the routine once to &lt;BR /&gt;
successfully create the blocks in their drawings. But if they try to run the &lt;BR /&gt;
routine a second time on the same drawing before closing this drawing, an &lt;BR /&gt;
error appears when the routine is trying to commit the transaction. The &lt;BR /&gt;
error that comes up is "Attempted to read or write protected memory" and &lt;BR /&gt;
then AutoCAD will crash. If the user saves and closes the drawing before &lt;BR /&gt;
running the routine a second time, the error does not appear. I've done some &lt;BR /&gt;
searching on this forum and the internet for the answer and have implemented &lt;BR /&gt;
some changes to my application to try to solve this issue. One of the first &lt;BR /&gt;
measures I did was to make sure that I've disposed all objects that I've &lt;BR /&gt;
accessed through the GetObject(OpenMode) method and not dispose any object &lt;BR /&gt;
opened by a transaction. Then I made sure that my code was not accessing the &lt;BR /&gt;
block table or the modelspace record more than once at the same time in my &lt;BR /&gt;
routine. The error still occurs as before. I use selection sets occasionally &lt;BR /&gt;
in my application to retrieve existing blocks. Should I be disposing of any &lt;BR /&gt;
of the objects associated with the selection sets? What other measures can I &lt;BR /&gt;
take to try to solve this issue? Any help would be greatly appreciated. &lt;BR /&gt;
Stephen&lt;/FLETCHMAN&gt;</description>
      <pubDate>Thu, 05 Mar 2009 17:20:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442495#M71555</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T17:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442496#M71556</link>
      <description>I didn't post my code for this application because it is close to 3,000 lines long.&lt;BR /&gt;
&lt;BR /&gt;
I wasn't asking anyone to analyse my code for me, figuring that it would be too much to ask someone to look through that much code to see if they could find something wrong.&lt;BR /&gt;
&lt;BR /&gt;
I was hoping that someone else had a similar problem and could tell me how they solved it.  If not, I was hoping someone had some tips that would point me in the right direction for tracking down the issue.</description>
      <pubDate>Thu, 05 Mar 2009 19:30:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442496#M71556</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T19:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442497#M71557</link>
      <description>Sorry, I should have said "relevant parts" of your code.&lt;BR /&gt;
&lt;BR /&gt;
IOW, your entire project isn't necessary, just the code&lt;BR /&gt;
that opens and access the database, which runs just&lt;BR /&gt;
before the failure.&lt;BR /&gt;
&lt;BR /&gt;
Unfortunately, an error when the drawing is saved can&lt;BR /&gt;
have many causes, so even if someone else may have&lt;BR /&gt;
come across it, it could be a completely different cause.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;FLETCHMAN&gt; wrote in message news:6137083@discussion.autodesk.com...&lt;BR /&gt;
I didn't post my code for this application because it is close to 3,000 &lt;BR /&gt;
lines long. I wasn't asking anyone to analyse my code for me, figuring that &lt;BR /&gt;
it would be too much to ask someone to look through that much code to see if &lt;BR /&gt;
they could find something wrong. I was hoping that someone else had a &lt;BR /&gt;
similar problem and could tell me how they solved it. If not, I was hoping &lt;BR /&gt;
someone had some tips that would point me in the right direction for &lt;BR /&gt;
tracking down the issue.&lt;/FLETCHMAN&gt;</description>
      <pubDate>Thu, 05 Mar 2009 22:03:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442497#M71557</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T22:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442498#M71558</link>
      <description>I've included the starting routine in this post.  It won't give a lot of details about what the routine is doing but illustrates how the transactions and blocktable are being handled.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for all your help, Tony.&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
		public void Create()&lt;BR /&gt;
		{&lt;BR /&gt;
			this.DeleteLog();&lt;BR /&gt;
&lt;BR /&gt;
			if (this.CopyMDBFile())&lt;BR /&gt;
			{&lt;BR /&gt;
				this.AddRegAppTableRecord();&lt;BR /&gt;
&lt;BR /&gt;
				this.trans = this.dwgDB.TransactionManager.StartTransaction();&lt;BR /&gt;
&lt;BR /&gt;
				//  Open the block table.&lt;BR /&gt;
&lt;BR /&gt;
				BlockTable bt = null;&lt;BR /&gt;
&lt;BR /&gt;
				try&lt;BR /&gt;
				{&lt;BR /&gt;
					//  Make sure a bold text style has been created when needed.&lt;BR /&gt;
&lt;BR /&gt;
					if (AppPrefs.HasBoldText &amp;amp;&amp;amp; !this.DwgHasTextStyle(Constants.DataBox.BoldStyleName))&lt;BR /&gt;
					{&lt;BR /&gt;
						this.ed.WriteMessage("A bold textstyle must be defined.");&lt;BR /&gt;
						this.trans.Abort();&lt;BR /&gt;
					}&lt;BR /&gt;
					else&lt;BR /&gt;
					{&lt;BR /&gt;
						this.AddDataboxLayers();&lt;BR /&gt;
						this.InsertPointBlock();&lt;BR /&gt;
						this.FindCurrentPointBlocks();&lt;BR /&gt;
&lt;BR /&gt;
						//  Get the list of well IDs.&lt;BR /&gt;
&lt;BR /&gt;
						List&lt;STRING&gt; wellIDs = DataManager.GetUniqueValues(AppPrefs.DataSourceName, AppPrefs.TableName, AppPrefs.TitleField);&lt;BR /&gt;
&lt;BR /&gt;
						if (wellIDs.Count &amp;gt; 0)&lt;BR /&gt;
						{&lt;BR /&gt;
							this.insertedBlocks = new List&lt;STRING&gt;(wellIDs.Count);&lt;BR /&gt;
&lt;BR /&gt;
							bt = (BlockTable)this.trans.GetObject(this.dwgDB.BlockTableId, OpenMode.ForWrite);&lt;BR /&gt;
							DataBox currDataBox = new DataBox(this.dbLayers, this.trans, bt);&lt;BR /&gt;
&lt;BR /&gt;
							//  Initialize and display the status form.&lt;BR /&gt;
&lt;BR /&gt;
							StatusForm statusForm = new StatusForm();&lt;BR /&gt;
							statusForm.TotalDataboxes = wellIDs.Count;&lt;BR /&gt;
							Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(statusForm);&lt;BR /&gt;
&lt;BR /&gt;
							//  Create a databox for each well ID.&lt;BR /&gt;
&lt;BR /&gt;
							foreach (string wellID in wellIDs)&lt;BR /&gt;
							{&lt;BR /&gt;
								System.Windows.Forms.Application.DoEvents();&lt;BR /&gt;
								&lt;BR /&gt;
								if (!statusForm.StopRequested)&lt;BR /&gt;
								{&lt;BR /&gt;
									//  Update the status form.&lt;BR /&gt;
&lt;BR /&gt;
									statusForm.CurrDataboxID = wellID;&lt;BR /&gt;
&lt;BR /&gt;
									//  Initialize the DataBox class.&lt;BR /&gt;
&lt;BR /&gt;
									currDataBox.WellID = wellID;&lt;BR /&gt;
&lt;BR /&gt;
									//  Track the blocks that have been inserted.&lt;BR /&gt;
&lt;BR /&gt;
									this.insertedBlocks.Add(currDataBox.BlockName);&lt;BR /&gt;
&lt;BR /&gt;
									//  Create the databox in AutoCAD.&lt;BR /&gt;
&lt;BR /&gt;
									currDataBox.Draw();&lt;BR /&gt;
&lt;BR /&gt;
									this.InsertDataBoxPointBlock(currDataBox, bt);&lt;BR /&gt;
								}&lt;BR /&gt;
								else&lt;BR /&gt;
								{&lt;BR /&gt;
									break;&lt;BR /&gt;
								}&lt;BR /&gt;
							}&lt;BR /&gt;
&lt;BR /&gt;
							if (!statusForm.StopRequested)&lt;BR /&gt;
							{&lt;BR /&gt;
								//  After all of the databoxes have been created, check to see if &lt;BR /&gt;
								//    there are any leftover databoxes from a previous running of&lt;BR /&gt;
								//    this routine and remove them.&lt;BR /&gt;
&lt;BR /&gt;
								this.DeleteOrphans(bt);&lt;BR /&gt;
&lt;BR /&gt;
								//  Successful run of databox creation, commit the transactions.&lt;BR /&gt;
&lt;BR /&gt;
								this.trans.Commit();&lt;BR /&gt;
&lt;BR /&gt;
								//  Zoom the current view to the extents of the drawing.&lt;BR /&gt;
&lt;BR /&gt;
								Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("zoom e\n", true, false, false);&lt;BR /&gt;
							}&lt;BR /&gt;
							else&lt;BR /&gt;
							{&lt;BR /&gt;
								this.trans.Abort();&lt;BR /&gt;
							}&lt;BR /&gt;
&lt;BR /&gt;
							//  Close the status form.&lt;BR /&gt;
&lt;BR /&gt;
							statusForm.Close();&lt;BR /&gt;
						}&lt;BR /&gt;
						else&lt;BR /&gt;
						{&lt;BR /&gt;
							this.ed.WriteMessage("No IDs found for specified title field.");&lt;BR /&gt;
							this.trans.Abort();&lt;BR /&gt;
						}&lt;BR /&gt;
					}&lt;BR /&gt;
				}&lt;BR /&gt;
				catch (Autodesk.AutoCAD.Runtime.Exception aex)&lt;BR /&gt;
				{&lt;BR /&gt;
					this.ed.WriteMessage("AutoCAD error: " + aex.Message);&lt;BR /&gt;
					this.trans.Abort();&lt;BR /&gt;
				}&lt;BR /&gt;
				catch (System.Exception ex)&lt;BR /&gt;
				{&lt;BR /&gt;
					this.ed.WriteMessage("Error: " + ex.Message);&lt;BR /&gt;
					this.trans.Abort();&lt;BR /&gt;
				}&lt;BR /&gt;
				finally&lt;BR /&gt;
				{&lt;BR /&gt;
					if (bt != null)&lt;BR /&gt;
					{&lt;BR /&gt;
						bt.Dispose();&lt;BR /&gt;
					}&lt;BR /&gt;
					this.trans.Dispose();&lt;BR /&gt;
				}&lt;BR /&gt;
&lt;BR /&gt;
				//  Delete the copied .mdb file.&lt;BR /&gt;
&lt;BR /&gt;
				this.DeleteMDBFile();&lt;BR /&gt;
			}&lt;BR /&gt;
		}&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;/STRING&gt;&lt;/STRING&gt;</description>
      <pubDate>Thu, 05 Mar 2009 22:27:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442498#M71558</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T22:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442499#M71559</link>
      <description>You'll need to attach it, since I can't read it in&lt;BR /&gt;
a newsreader.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;FLETCHMAN&gt; wrote in message news:6137198@discussion.autodesk.com...&lt;BR /&gt;
I've included the starting routine in this post. It won't give a lot of &lt;BR /&gt;
details about what the routine is doing but illustrates how the transactions &lt;BR /&gt;
and blocktable are being handled. Thanks for all your help, Tony. {code} &lt;BR /&gt;
public void Create() { this.DeleteLog(); if (this.CopyMDBFile()) { &lt;BR /&gt;
this.AddRegAppTableRecord(); this.trans = &lt;BR /&gt;
this.dwgDB.TransactionManager.StartTransaction(); // Open the block table. &lt;BR /&gt;
BlockTable bt = null; try { // Make sure a bold text style has been created &lt;BR /&gt;
when needed. if (AppPrefs.HasBoldText &amp;amp;&amp;amp; &lt;BR /&gt;
!this.DwgHasTextStyle(Constants.DataBox.BoldStyleName)) { &lt;BR /&gt;
this.ed.WriteMessage("A bold textstyle must be defined."); &lt;BR /&gt;
this.trans.Abort(); } else { this.AddDataboxLayers(); &lt;BR /&gt;
this.InsertPointBlock(); this.FindCurrentPointBlocks(); // Get the list of &lt;BR /&gt;
well IDs. List wellIDs = &lt;BR /&gt;
DataManager.GetUniqueValues(AppPrefs.DataSourceName, AppPrefs.TableName, &lt;BR /&gt;
AppPrefs.TitleField); if (wellIDs.Count &amp;gt; 0) { this.insertedBlocks = new &lt;BR /&gt;
List(wellIDs.Count); bt = &lt;BR /&gt;
(BlockTable)this.trans.GetObject(this.dwgDB.BlockTableId, &lt;BR /&gt;
OpenMode.ForWrite); DataBox currDataBox = new DataBox(this.dbLayers, &lt;BR /&gt;
this.trans, bt); // Initialize and display the status form. StatusForm &lt;BR /&gt;
statusForm = new StatusForm(); statusForm.TotalDataboxes = wellIDs.Count; &lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(statusForm); &lt;BR /&gt;
// Create a databox for each well ID. foreach (string wellID in wellIDs) { &lt;BR /&gt;
System.Windows.Forms.Application.DoEvents(); if (!statusForm.StopRequested) &lt;BR /&gt;
{ // Update the status form. statusForm.CurrDataboxID = wellID; // &lt;BR /&gt;
Initialize the DataBox class. currDataBox.WellID = wellID; // Track the &lt;BR /&gt;
blocks that have been inserted. &lt;BR /&gt;
this.insertedBlocks.Add(currDataBox.BlockName); // Create the databox in &lt;BR /&gt;
AutoCAD. currDataBox.Draw(); this.InsertDataBoxPointBlock(currDataBox, &lt;BR /&gt;
bt); } else { break; } } if (!statusForm.StopRequested) { // After all of &lt;BR /&gt;
the databoxes have been created, check to see if // there are any leftover &lt;BR /&gt;
databoxes from a previous running of // this routine and remove them. &lt;BR /&gt;
this.DeleteOrphans(bt); // Successful run of databox creation, commit the &lt;BR /&gt;
transactions. this.trans.Commit(); // Zoom the current view to the extents &lt;BR /&gt;
of the drawing. &lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("zoom &lt;BR /&gt;
e\n", true, false, false); } else { this.trans.Abort(); } // Close the &lt;BR /&gt;
status form. statusForm.Close(); } else { this.ed.WriteMessage("No IDs found &lt;BR /&gt;
for specified title field."); this.trans.Abort(); } } } catch &lt;BR /&gt;
(Autodesk.AutoCAD.Runtime.Exception aex) { this.ed.WriteMessage("AutoCAD &lt;BR /&gt;
error: " + aex.Message); this.trans.Abort(); } catch (System.Exception ex) &lt;BR /&gt;
{ this.ed.WriteMessage("Error: " + ex.Message); this.trans.Abort(); } &lt;BR /&gt;
finally { if (bt != null) { bt.Dispose(); } this.trans.Dispose(); } // &lt;BR /&gt;
Delete the copied .mdb file. this.DeleteMDBFile(); } } {code}&lt;/FLETCHMAN&gt;</description>
      <pubDate>Thu, 05 Mar 2009 23:17:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442499#M71559</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T23:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442500#M71560</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Try posting it in Rich Text.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Joe ...&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;lt;FletchMan&amp;gt; wrote in message &lt;A&gt;&lt;BR /&gt;
  href="news:6137198@discussion.autodesk.com"&amp;gt;news:6137198@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;I've &lt;BR /&gt;
  included the starting routine in this post. It won't give a lot of details &lt;BR /&gt;
  about what the routine is doing but illustrates how the transactions and &lt;BR /&gt;
  blocktable are being handled. Thanks for all your help, Tony. {code} public &lt;BR /&gt;
  void Create() { this.DeleteLog(); if (this.CopyMDBFile()) { &lt;BR /&gt;
  this.AddRegAppTableRecord(); this.trans = &lt;BR /&gt;
  this.dwgDB.TransactionManager.StartTransaction(); // Open the block table. &lt;BR /&gt;
  BlockTable bt = null; try { // Make sure a bold text style has been created &lt;BR /&gt;
  when needed. if (AppPrefs.HasBoldText &amp;amp;&amp;amp; &lt;BR /&gt;
  !this.DwgHasTextStyle(Constants.DataBox.BoldStyleName)) { &lt;BR /&gt;
  this.ed.WriteMessage("A bold textstyle must be defined."); this.trans.Abort(); &lt;BR /&gt;
  } else { this.AddDataboxLayers(); this.InsertPointBlock(); &lt;BR /&gt;
  this.FindCurrentPointBlocks(); // Get the list of well IDs. List&lt;STRING&gt; &lt;BR /&gt;
  wellIDs = DataManager.GetUniqueValues(AppPrefs.DataSourceName, &lt;BR /&gt;
  AppPrefs.TableName, AppPrefs.TitleField); if (wellIDs.Count &amp;gt; 0) { &lt;BR /&gt;
  this.insertedBlocks = new List&lt;STRING&gt;(wellIDs.Count); bt = &lt;BR /&gt;
  (BlockTable)this.trans.GetObject(this.dwgDB.BlockTableId, OpenMode.ForWrite); &lt;BR /&gt;
  DataBox currDataBox = new DataBox(this.dbLayers, this.trans, bt); // &lt;BR /&gt;
  Initialize and display the status form. StatusForm statusForm = new &lt;BR /&gt;
  StatusForm(); statusForm.TotalDataboxes = wellIDs.Count; &lt;BR /&gt;
  Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(statusForm); &lt;BR /&gt;
  // Create a databox for each well ID. foreach (string wellID in wellIDs) { &lt;BR /&gt;
  System.Windows.Forms.Application.DoEvents(); if (!statusForm.StopRequested) { &lt;BR /&gt;
  // Update the status form. statusForm.CurrDataboxID = wellID; // Initialize &lt;BR /&gt;
  the DataBox class. currDataBox.WellID = wellID; // Track the blocks that have &lt;BR /&gt;
  been inserted. this.insertedBlocks.Add(currDataBox.BlockName); // Create the &lt;BR /&gt;
  databox in AutoCAD. currDataBox.Draw(); &lt;BR /&gt;
  this.InsertDataBoxPointBlock(currDataBox, bt); } else { break; } } if &lt;BR /&gt;
  (!statusForm.StopRequested) { // After all of the databoxes have been created, &lt;BR /&gt;
  check to see if // there are any leftover databoxes from a previous running of &lt;BR /&gt;
  // this routine and remove them. this.DeleteOrphans(bt); // Successful run of &lt;BR /&gt;
  databox creation, commit the transactions. this.trans.Commit(); // Zoom the &lt;BR /&gt;
  current view to the extents of the drawing. &lt;BR /&gt;
  Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("zoom &lt;BR /&gt;
  e\n", true, false, false); } else { this.trans.Abort(); } // Close the status &lt;BR /&gt;
  form. statusForm.Close(); } else { this.ed.WriteMessage("No IDs found for &lt;BR /&gt;
  specified title field."); this.trans.Abort(); } } } catch &lt;BR /&gt;
  (Autodesk.AutoCAD.Runtime.Exception aex) { this.ed.WriteMessage("AutoCAD &lt;BR /&gt;
  error: " + aex.Message); this.trans.Abort(); } catch (System.Exception ex) { &lt;BR /&gt;
  this.ed.WriteMessage("Error: " + ex.Message); this.trans.Abort(); } finally { &lt;BR /&gt;
  if (bt != null) { bt.Dispose(); } this.trans.Dispose(); } // Delete the copied &lt;BR /&gt;
  .mdb file. this.DeleteMDBFile(); } } {code}&lt;/STRING&gt;&lt;/STRING&gt;&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 06 Mar 2009 12:36:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442500#M71560</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-06T12:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442501#M71561</link>
      <description>Sorry about that.  I've attached the code to this reply.&lt;BR /&gt;
&lt;BR /&gt;
Let me know if you want more examples and what I should be including.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Stephen</description>
      <pubDate>Fri, 06 Mar 2009 13:39:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442501#M71561</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-06T13:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442502#M71562</link>
      <description>I'm afraid your code looks OK.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I think you should post a bit more, the things we can see in this code are ok.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However, we don't know what is happening in &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DataBox.Draw()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;InsertDataBoxPointBlock()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And that is probably where the issue is.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you don't want to post the entire code, post the specific AutoCAD interactions...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;http://cupocadnet.blogspot.com</description>
      <pubDate>Sat, 07 Mar 2009 18:08:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442502#M71562</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-07T18:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442503#M71563</link>
      <description>Thanks, Bertvan.&lt;BR /&gt;
&lt;BR /&gt;
I've attached the InsertDataPointBlock method and the Databox class.  I've removed most of the methods that have no AutoCAD interaction.&lt;BR /&gt;
&lt;BR /&gt;
I appreciate all of the help.&lt;BR /&gt;
Stephen</description>
      <pubDate>Mon, 09 Mar 2009 13:39:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442503#M71563</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-09T13:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442504#M71564</link>
      <description>My experience is, although simple, is a locked document somewhere which did not get unlocked?&lt;BR /&gt;
&lt;BR /&gt;
Just thought I would toss in something that might help.</description>
      <pubDate>Mon, 09 Mar 2009 17:20:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442504#M71564</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-09T17:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442505#M71565</link>
      <description>I don't think I locked any documents in this case.  Can this be implicitly done?  And if so, how?  Then the question becomes how do you unlock a document?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Stephen</description>
      <pubDate>Mon, 09 Mar 2009 18:34:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442505#M71565</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-09T18:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Corrupt Memory Error</title>
      <link>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442506#M71566</link>
      <description>You don't need to lock the document if your code is called from&lt;BR /&gt;
the handler of a registered command (that does not use the&lt;BR /&gt;
CommandFlags.Session flag).&lt;BR /&gt;
&lt;BR /&gt;
The LockDocument() method of the Document locks the&lt;BR /&gt;
document, and disposing the object it returns unlocks the&lt;BR /&gt;
document.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;FLETCHMAN&gt; wrote in message news:6138680@discussion.autodesk.com...&lt;BR /&gt;
I don't think I locked any documents in this case. Can this be implicitly &lt;BR /&gt;
done? And if so, how? Then the question becomes how do you unlock a &lt;BR /&gt;
document? Thanks, Stephen&lt;/FLETCHMAN&gt;</description>
      <pubDate>Mon, 09 Mar 2009 19:53:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/corrupt-memory-error/m-p/2442506#M71566</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-09T19:53:59Z</dc:date>
    </item>
  </channel>
</rss>

