Results 1 to 9 of 9

Thread: Migrating old vb.net to AutoCAD 2013

  1. #1
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Migrating old vb.net to AutoCAD 2013

    All of my older programs were written in visual studio 2008 express and worked great for years. I recompiled all of them with 2010 express and 4.0 framework using the new accoremgd.dll as well as the old ones (newer version of them though). All seems to work great with loading the program and the graphics and such but as soon as I try to programmatically insert a block from a specific directory I get multiple errors. One error is the "eHadMultipleReaders" and then a fatal error and the other states "eOutOfRange". This error seems random because I can insert some drawing files from a directory list within the program but the drawing file listed right below it in the list gives these errors. From a list of about 25 files, only 10 or so will insert without error and the rest just crash. Where these are in the list is ramdon also. All of my problems appear for now to be the insertion of external drawing files. Some insert, some don't with the exact same procedure. Any ideas? Why would the very same code work great for years and now not work at all?

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,758
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    Have you done any debugging to find out what line the code errors on? Can you post the code in question?
    C:> ED WORKING....

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,538
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3630, Core i9-9900K 5.0GHz, 128GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,758
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    What IDE are you using? One of the express versions? To find out what the error means, you need to look it up in the arx.chm found in the sdk. This is from the help for the ObjectID.UpgradeOpen method.
    If the object is currently open AcDb::kForRead with only one reader, then this function upgrades the object to open AcDb::kForWrite. In the process of changing to open for write, the object is closed, thus triggering any pertinent notification.

    Returns Acad::eOk if successful. If the object has more than one reader, then the open status is not changed and Adesk::eHadMultipleReaders is returned. If the object is already open AcDb::kForWrite, then Acad::eWasOpenForWrite is returned. If the object is currently sending notification, then the open status is not changed and Acad::eWasNotifying is returned.
    Last edited by Ed Jobe; 2012-07-19 at 06:15 PM.
    C:> ED WORKING....

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,758
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    VS has allows you to set a property in your project settings for dll type projects that specifies which program to run the dll in. But the Express versions do not have this option. However, you can manually edit your project file to set this up. You can edit your Project.csproj file or it is reccommended to edit the Project.csproj.user file. Here is a sample. You need to add the PropertyGroup to the end of your user file. Of course, you need to change the path to where you have acad installed.
    Code:
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <StartAction>Program</StartAction>
        <StartProgram>C:\Program Files\AutoCAD Map 3D 2010\acad.exe</StartProgram>
        <StartArguments></StartArguments>
        <StartWorkingDirectory>C:\Program Files\AutoCAD Map 3D 2010</StartWorkingDirectory>
      </PropertyGroup>
    </Project>
    After you set up your project, hit F5 and after acad starts, netload your dll. Then you can set a breakpoint and run a command to step through the code to see what line gives you the error.

    Since you haven't posted any code, its kind of hard/impossible to tell you're getting eOutOfRange from. But that usually comes from requesting an index number from a list/array that is out of bounds.
    C:> ED WORKING....

  6. #6
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    I've never actually debugged any of my programs and wouldn't even know how to since it runs within AutoCAD. Is it easy?
    What does the "eHadMultipleReaders" even suggest? Internet and forum searches for "eHadMultipleReaders" don't really tell me much or are too broad of an answer.

  7. #7
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    I'm using Visual Basic 2010 Express to make all of this. I was using 2008 but went to 2010 for the 4.0 framework.
    With a little debugging myself I found that when I changed the Boolean from False to True for the preserveSourceDatabase property in

    Dwg.Insert(Filenamestring, DwgDatabase, True)

    ... that most of my external drawings will insert now and the error "eHadMultipleReaders" doesn't pop up anymore. However, a couple of external drawings still give a "eOutOfRange" error and won't insert the file. I feel like I'm getting there but jut don't know how or why.

  8. #8
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    Thanks for the debugging info. I'll give it a try.
    As for the "OutOfRange" errors... Turns out there's something wrong with the files I'm trying to insert with my program. They're older files from older versions and have never given me any trouble before but 2013 seems to not like them. I manually inserted them into a blank drawing and then WBLOCKed them back out by selecting the block definition from the list and simply overwrote the old file by the same name. By doing this, no errors occur and the files block in beautifully. Of course my old method of viewing the thumbnail of the drawing file doesn't work now....

  9. #9
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,538
    Login to Give a bone
    0

    Default Re: Migrating old vb.net to AutoCAD 2013

    FWIW -

    I use Visual Studio 2010 Express, and used to manually edit project files as Ed has described to be able to debug, but it is just _so_ much simpler to use one of the .NET Wizards instead:

    AcadNetAddinWizard by SpiderInNet1

    AutoCAD .NET Wizard by Autodesk Developer Network

    ... Or other.

    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3630, Core i9-9900K 5.0GHz, 128GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

Similar Threads

  1. MA9210-1: Migrating from AutoCAD to AutoCAD Electrical
    By Autodesk University in forum Manufacturing
    Replies: 0
    Last Post: 2014-12-01, 03:23 AM
  2. MA115-4: Migrating from AutoCAD® to AutoCAD® Electrical
    By Autodesk University in forum Manufacturing
    Replies: 0
    Last Post: 2013-05-06, 01:24 AM
  3. MA23-3: Migrating from AutoCAD® to AutoCAD® Electrical
    By Autodesk University in forum Manufacturing
    Replies: 0
    Last Post: 2013-04-17, 04:50 AM
  4. MA33-3: Migrating from AutoCAD® to AutoCAD® Electrical
    By Autodesk University in forum Manufacturing
    Replies: 0
    Last Post: 2013-04-10, 01:38 AM
  5. Migrating from Microstation to AutoCAD
    By acenish in forum AutoCAD General
    Replies: 0
    Last Post: 2011-06-24, 08:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •