<?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: Unhandled Exception C0000005 in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652004#M66350</link>
    <description>Did you implement IExtensionApplication and have code run in its Terminate() method?&lt;BR /&gt;
&lt;BR /&gt;
Form the code you showed, you should remove the last 2 lines of "xxx.Dispose();":&lt;BR /&gt;
&lt;BR /&gt;
tstr is the TestStyleTableRecord, which is what you need to create and add to the database and you code does that correctly. But why you dispose it?&lt;BR /&gt;
&lt;BR /&gt;
Also, for tst, the TextStyleTable, which is part of drawing database, you did not create it, why dispose it?&lt;BR /&gt;
&lt;BR /&gt;
While AutoCAD still work OK after running your function, the unnecessary Dispose() may seem harmless, but since the we really have no idea how Autodesk implemented Dispose() method under the hood, there may be chance something gone wrong here. &lt;BR /&gt;
&lt;BR /&gt;
Anyway, whther the Acad exiting error is caused by it or not, the extra 2 Dispose() are redundant, to say the least.</description>
    <pubDate>Fri, 19 Mar 2010 20:09:12 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2010-03-19T20:09:12Z</dc:date>
    <item>
      <title>Unhandled Exception C0000005</title>
      <link>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652003#M66349</link>
      <description>(Access Violation Reading 0xaa00004d)&lt;BR /&gt;
&lt;BR /&gt;
So... I get this error when exiting AutoCAD 2010.  I've narrowed it down to one specific function.  If the function is run, the error gets thrown on exit - if the function does not run, there is no error.  Can someone shed some light on what the heck I'm doing wrong, please?  The function is intended to load a text style based on a specific shx.  It does what it should do, except for the error when exiting AutoCAD.&lt;BR /&gt;
&lt;BR /&gt;
public static void AddTextStyle(String textStyle, String shx)&lt;BR /&gt;
        {&lt;BR /&gt;
            Database db = Application.DocumentManager.MdiActiveDocument.Database;&lt;BR /&gt;
            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;&lt;BR /&gt;
            Transaction tr = tm.StartTransaction();&lt;BR /&gt;
            TextStyleTable tst = (TextStyleTable)tm.GetObject(db.TextStyleTableId, OpenMode.ForWrite);&lt;BR /&gt;
            TextStyleTableRecord tstr = new TextStyleTableRecord();&lt;BR /&gt;
            tstr.Name = textStyle;&lt;BR /&gt;
            tstr.FileName = shx;&lt;BR /&gt;
            tst.Add(tstr);&lt;BR /&gt;
            tr.AddNewlyCreatedDBObject(tstr, true);&lt;BR /&gt;
            tr.Commit();&lt;BR /&gt;
            tr.Dispose();&lt;BR /&gt;
            tstr.Dispose();&lt;BR /&gt;
            tst.Dispose();&lt;BR /&gt;
        }</description>
      <pubDate>Fri, 19 Mar 2010 19:15:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652003#M66349</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-03-19T19:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled Exception C0000005</title>
      <link>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652004#M66350</link>
      <description>Did you implement IExtensionApplication and have code run in its Terminate() method?&lt;BR /&gt;
&lt;BR /&gt;
Form the code you showed, you should remove the last 2 lines of "xxx.Dispose();":&lt;BR /&gt;
&lt;BR /&gt;
tstr is the TestStyleTableRecord, which is what you need to create and add to the database and you code does that correctly. But why you dispose it?&lt;BR /&gt;
&lt;BR /&gt;
Also, for tst, the TextStyleTable, which is part of drawing database, you did not create it, why dispose it?&lt;BR /&gt;
&lt;BR /&gt;
While AutoCAD still work OK after running your function, the unnecessary Dispose() may seem harmless, but since the we really have no idea how Autodesk implemented Dispose() method under the hood, there may be chance something gone wrong here. &lt;BR /&gt;
&lt;BR /&gt;
Anyway, whther the Acad exiting error is caused by it or not, the extra 2 Dispose() are redundant, to say the least.</description>
      <pubDate>Fri, 19 Mar 2010 20:09:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652004#M66350</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2010-03-19T20:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled Exception C0000005</title>
      <link>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652005#M66351</link>
      <description>I've not needed to define text styles through code, so I'm guessing&lt;BR /&gt;
here, that it's happening because the new TextStyleTableRecord is&lt;BR /&gt;
not being correctly initialized. Try setting the XScale property; the&lt;BR /&gt;
FontDescriptor property, and any others whose default values are&lt;BR /&gt;
not the same as they are in the 'standard' style, when you create it.&lt;BR /&gt;
&lt;BR /&gt;
Text Styles you create through the UI have XData attached to them&lt;BR /&gt;
(the FontDescriptor is stored in it). See if your new record has it&lt;BR /&gt;
after you add it to the database. If not, that could be the problem.&lt;BR /&gt;
&lt;BR /&gt;
If none of that works, try calling Clone() on the record for the&lt;BR /&gt;
'Standard' text style, modify that, and append it to the table.&lt;BR /&gt;
&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&lt;BR /&gt;
Supporting AutoCAD 2000 through 2010&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;FYATHYRIO8&gt; wrote in message news:6357726@discussion.autodesk.com...&lt;BR /&gt;
(Access Violation Reading 0xaa00004d)&lt;BR /&gt;
&lt;BR /&gt;
So... I get this error when exiting AutoCAD 2010.  I've narrowed it down to one &lt;BR /&gt;
specific function.  If the function is run, the error gets thrown on exit - if &lt;BR /&gt;
the function does not run, there is no error.  Can someone shed some light on &lt;BR /&gt;
what the heck I'm doing wrong, please?  The function is intended to load a text &lt;BR /&gt;
style based on a specific shx.  It does what it should do, except for the error &lt;BR /&gt;
when exiting AutoCAD.&lt;BR /&gt;
&lt;BR /&gt;
public static void AddTextStyle(String textStyle, String shx)&lt;BR /&gt;
        {&lt;BR /&gt;
            Database db = &lt;BR /&gt;
Application.DocumentManager.MdiActiveDocument.Database;&lt;BR /&gt;
            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = &lt;BR /&gt;
db.TransactionManager;&lt;BR /&gt;
            Transaction tr = tm.StartTransaction();&lt;BR /&gt;
            TextStyleTable tst = &lt;BR /&gt;
(TextStyleTable)tm.GetObject(db.TextStyleTableId, OpenMode.ForWrite);&lt;BR /&gt;
            TextStyleTableRecord tstr = new TextStyleTableRecord();&lt;BR /&gt;
            tstr.Name = textStyle;&lt;BR /&gt;
            tstr.FileName = shx;&lt;BR /&gt;
            tst.Add(tstr);&lt;BR /&gt;
            tr.AddNewlyCreatedDBObject(tstr, true);&lt;BR /&gt;
            tr.Commit();&lt;BR /&gt;
            tr.Dispose();&lt;BR /&gt;
            tstr.Dispose();&lt;BR /&gt;
            tst.Dispose();&lt;BR /&gt;
        }&lt;/FYATHYRIO8&gt;</description>
      <pubDate>Fri, 19 Mar 2010 20:56:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652005#M66351</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-03-19T20:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled Exception C0000005</title>
      <link>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652006#M66352</link>
      <description>The Dispose() calls did not exist in my original code.  I had added them when the problem arose to see if it would fix it.  Yes, I implement IExtensionApplication and a Terminate function (which currently does nothing).  SDI mode was set to 1 (for another application I was developing).  When I set SDI to 0, the problem went away.  Given the environment this will be run in, it's fine if it only works without SDI, although it would be interesting to know why this is an issue.

Edited by: fyathyrio8 on Mar 22, 2010 12:43 PM</description>
      <pubDate>Mon, 22 Mar 2010 12:43:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unhandled-exception-c0000005/m-p/2652006#M66352</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-03-22T12:43:08Z</dc:date>
    </item>
  </channel>
</rss>

