<?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: ReadDwgFile - eFileSharingViolation in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076683#M76930</link>
    <description>Document 'locking' has nothing to do with file locking &lt;BR /&gt;
or share permissions. When one application locks the&lt;BR /&gt;
document, that tells AutoCAD that it shouldn't allow &lt;BR /&gt;
any other application to modify the state or data of &lt;BR /&gt;
that document or its database (here, 'document' and&lt;BR /&gt;
'database' refer to the in-memory objects, not the &lt;BR /&gt;
source DWG file).&lt;BR /&gt;
&lt;BR /&gt;
In general, the ObjectARX docs clearly explain many &lt;BR /&gt;
things that eliminate the need for speculation.&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 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;MARK johnston=""&gt; wrote in message news:5731489@discussion.autodesk.com...&lt;BR /&gt;
It looks like you are locking the active document, then opening a database, then doing a transaction in another unknown document (doc).&lt;BR /&gt;
Something was bound to break.&lt;BR /&gt;
You should be locking the same document you are having the  transaction with.&lt;/MARK&gt;</description>
    <pubDate>Wed, 26 Sep 2007 00:09:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-09-26T00:09:56Z</dc:date>
    <item>
      <title>ReadDwgFile - eFileSharingViolation</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076678#M76925</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
A Question: I'm getting a eFileSharingViolation when I use the method "ReadDwgFile" if the selected drawing is open.&lt;BR /&gt;
&lt;BR /&gt;
Is it not possible to use a open drawing with this method?&lt;BR /&gt;
If so, any idea on a workaround for this?&lt;BR /&gt;
&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
using (DocumentLock docLock = Application.DocumentManager.MdiActiveDocument.LockDocument())&lt;BR /&gt;
                {&lt;BR /&gt;
                    using (Database db = new Database(false, false))&lt;BR /&gt;
                    {&lt;BR /&gt;
                        db.ReadDwgFile(fname, System.IO.FileShare.Read, true, null);&lt;BR /&gt;
                        using (Transaction t = doc.TransactionManager.StartTransaction())&lt;BR /&gt;
                        {&lt;BR /&gt;
                            ObjectId idBTR = doc.Database.Insert(BlockName, db, false);&lt;BR /&gt;
                            t.Commit();&lt;BR /&gt;
                        }&lt;BR /&gt;
&lt;BR /&gt;
                    }&lt;BR /&gt;
                }&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
&lt;BR /&gt;
A Caddie</description>
      <pubDate>Tue, 25 Sep 2007 18:50:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076678#M76925</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-25T18:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile - eFileSharingViolation</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076679#M76926</link>
      <description>ps. using: AutoCAD 2008, VS2005, WinXP pro sp2</description>
      <pubDate>Tue, 25 Sep 2007 18:54:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076679#M76926</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-25T18:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile - eFileSharingViolation</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076680#M76927</link>
      <description>It looks like you are locking the active document, then opening a database, then doing a transaction in another unknown document (doc).&lt;BR /&gt;
Something was bound to break.&lt;BR /&gt;
You should be locking the same document you are having the  transaction with.</description>
      <pubDate>Tue, 25 Sep 2007 19:55:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076680#M76927</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-25T19:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile - eFileSharingViolation</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076681#M76928</link>
      <description>Hi Mark,&lt;BR /&gt;
&lt;BR /&gt;
I'll have to clean up my code.&lt;BR /&gt;
Before I start the transaction I set "doc" also to the active MdiDocument....so the Lock and transactions are the same document...&lt;BR /&gt;
&lt;BR /&gt;
Well i corrected the code, but still same trouble.&lt;BR /&gt;
I can insert drawing that aren't open, and the message "eFileSharingViolation" sounds to me like it wants to lock the file, but because the file is open it can't lock it....&lt;BR /&gt;
&lt;BR /&gt;
here's the error I get:&lt;BR /&gt;
Error Autodesk.AutoCAD.Runtime.Exception: eFileSharingViolation&lt;BR /&gt;
   at Autodesk.AutoCAD.DatabaseServices.Database.ReadDwgFile(String fileName, &lt;BR /&gt;
FileShare fileSharing, Boolean allowCPConversion, String password)&lt;BR /&gt;
&lt;BR /&gt;
O, I just checked the ObjectARX documentation on this method again......seems it can't access files already open.&lt;BR /&gt;
&lt;BR /&gt;
Just tried to insert a file set to Read-Only...this goes!!!??&lt;BR /&gt;
&lt;BR /&gt;
Seems You can't use this on a open file  &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Maybe copy the file first to a temp location...and read it there&lt;BR /&gt;
Anyone another solution&lt;BR /&gt;
&lt;BR /&gt;
A Caddie.</description>
      <pubDate>Tue, 25 Sep 2007 22:00:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076681#M76928</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-25T22:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile - eFileSharingViolation</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076682#M76929</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
Well seems after reading the ObjectARX several times on "ReadDwgFile" that the mode specified determines what other processes can do to the file, well because it's a open file it needs Write (or read) access.. so "System.IO.FileShare.ReadWrite" instead of "Read" solves the problem...the documentation only gives a warning that the file could change during the "ReadDwgFile" method.&lt;BR /&gt;
&lt;BR /&gt;
But because I want to insert the whole drawing (as block) into the current drawing that shouldn't be a issue, maybe only with a large drawing...&lt;BR /&gt;
&lt;BR /&gt;
A. Caddie</description>
      <pubDate>Tue, 25 Sep 2007 22:17:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076682#M76929</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-25T22:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile - eFileSharingViolation</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076683#M76930</link>
      <description>Document 'locking' has nothing to do with file locking &lt;BR /&gt;
or share permissions. When one application locks the&lt;BR /&gt;
document, that tells AutoCAD that it shouldn't allow &lt;BR /&gt;
any other application to modify the state or data of &lt;BR /&gt;
that document or its database (here, 'document' and&lt;BR /&gt;
'database' refer to the in-memory objects, not the &lt;BR /&gt;
source DWG file).&lt;BR /&gt;
&lt;BR /&gt;
In general, the ObjectARX docs clearly explain many &lt;BR /&gt;
things that eliminate the need for speculation.&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 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;MARK johnston=""&gt; wrote in message news:5731489@discussion.autodesk.com...&lt;BR /&gt;
It looks like you are locking the active document, then opening a database, then doing a transaction in another unknown document (doc).&lt;BR /&gt;
Something was bound to break.&lt;BR /&gt;
You should be locking the same document you are having the  transaction with.&lt;/MARK&gt;</description>
      <pubDate>Wed, 26 Sep 2007 00:09:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-efilesharingviolation/m-p/2076683#M76930</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-26T00:09:56Z</dc:date>
    </item>
  </channel>
</rss>

