Author Topic: ManagedMapAPI.dll load assembly problem  (Read 6503 times)

0 Members and 1 Guest are viewing this topic.

cannorth

  • Guest
ManagedMapAPI.dll load assembly problem
« on: July 18, 2011, 11:41:44 AM »
Hello,

  I have a problem with loading an assembly in a Visual Studio 2008 64 bit compiled program.  When I netload the program from AutoCAD 2012, and press a button that contains ObjectARX Map code, it says it can't load the assembly ManagedMapAPI.dll.  Do I need to upgrade to Visual Studio 2010 for it to work properly?

Thanks,

cannorth

BillZndl

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #1 on: July 18, 2011, 12:09:58 PM »
Are you compiling to "< AnyCPU >" ?


cannorth

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #2 on: July 18, 2011, 12:42:40 PM »
I tried compiling Any CPU or x64.

Thanks,

cannorth

BillZndl

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #3 on: July 18, 2011, 01:49:03 PM »
Hard to believe but after replacing the acMgd and acDBMgd found in the install directories,
with the ones found in the ObjectARX folders,
the problem i was having with AutoCAD 2012 went away.


cannorth

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #4 on: July 18, 2011, 03:10:58 PM »
I tried that and AutoCAD becomes unstable and crashes when I replace acmgd.dlll and acdbmgd.dll.

cannorth

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: ManagedMapAPI.dll load assembly problem
« Reply #5 on: July 18, 2011, 04:10:39 PM »
Not surprised.  The ObjectARX DLLs are intened as references for building against rather than actual working application files.

The original question sounds like a DLL is auto-loading; can the DLL being loaded be found at the requested location, and is the correct release version for the AutoCAD being tested against?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cannorth

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #6 on: July 18, 2011, 04:25:51 PM »
Hello,

  When I build the .Net dll, it puts the ManagedMapApi dll into my debug or release path.  These subfolders are both under the x64 folder.  The ManagedMapApi.dll matches the date and time of the one in the AutoCAD 2012 folder.  I don't have any other version of AutoCAD installed.  When I change the supported runtime in acad.exe.config to v2.0.50727, it comes up with an unhandled exception error instead:

The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Thanks,

cannorth 

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: ManagedMapAPI.dll load assembly problem
« Reply #7 on: July 18, 2011, 04:32:52 PM »
Sounds like the Copy Local property of that DLL should be set to false in your project.  That should be set for any DLL which is part of the installed AutoCAD application, as opposed to one that needs to be distributed along with the application.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cannorth

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #8 on: July 18, 2011, 04:42:08 PM »
Hello,

  When I turn copy local to false and run the program in AutoCAD, I get the same errors as the last message I sent for v.4.0 and v2.0.50727.

Thanks,

cannorth

cannorth

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #9 on: July 18, 2011, 05:27:44 PM »

  I also commented out any code and variable declaration related to the new AutoMAP Object ARX functions, and it did worked.

cannorth

BillZndl

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #10 on: July 19, 2011, 07:09:00 AM »
Not surprised.  The ObjectARX DLLs are intened as references for building against rather than actual working application files.

The original question sounds like a DLL is auto-loading; can the DLL being loaded be found at the requested location, and is the correct release version for the AutoCAD being tested against?

FWIW: I don't know enough about this to make an argument but I've seen this recommendation in more than one place.
Of coarse I don't do any shipping of my products as they are all used "in house".
Quote
NoteThe DLLs in the ObjectARX SDK are simplified versions of the same files that ship with AutoCAD, as they do not contain dependencies on the AutoCAD user interface. It is recommended that you download and install the ObjectARX SDK, and then reference the DLL files that come with the SDK instead of those that are found in the install directory of AutoCAD 2010.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: ManagedMapAPI.dll load assembly problem
« Reply #11 on: July 19, 2011, 10:26:42 AM »
Somebody recommended replacing DLLs that came with the program with the SDK DLLs...?  The second quote you provides says it all: "NoteThe DLLs in the ObjectARX SDK are simplified versions of the same files that ship with AutoCAD, as they do not contain dependencies on the AutoCAD user interface." (emphasis mine)
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

BillZndl

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #12 on: July 19, 2011, 10:41:08 AM »
Again, I do not know why but somewhere over in the Autodesk net dicussions I saw where Tony Tanzillo recommended that for some reason.

(Edited to add references I've found:
http://forums.autodesk.com/t5/NET/acmgd-dll-amp-acdbmgd-dll/m-p/2810148/highlight/true#M21246
http://forums.autodesk.com/t5/NET/Referencing-acmgd-and-acdbmgd/m-p/2646365/highlight/true#M18247)

Anyway, I also went to target net 3.5 as there was problems gettting AutoCAD 2012 (win 7)  to load .dll's with 4.0.
« Last Edit: July 19, 2011, 11:31:59 AM by BillZndl »

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: ManagedMapAPI.dll load assembly problem
« Reply #13 on: July 19, 2011, 02:11:02 PM »
Kinda-sorta, what he recommends is *referencing* the SDK DLLs when building your stuff rather than referencing the OOTB AutoCAD DLLs, not physically overwriting the OOTB AutoCAD DLLs.  When your application runs, it finds the OOTB AutoCAD DLLs instead of the SDK versions.  Since the OOTB version is an extension of the SDK (or the SDK is a simplified version of the OOTB one, same diff...) from your DLL's point of view there is no difference at run-time.

Doing it this way allows Visual Studio to reference the content it needs without having to wade through the additional stuff AutoCAD needs but Visual Studio doesn't need for development (which is the point of the SDK).


And sorry for the threadjack, cannorth.   :angel:
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

BillZndl

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #14 on: July 21, 2011, 08:01:34 AM »
Kinda-sorta, what he recommends is *referencing* the SDK DLLs when building your stuff rather than referencing the OOTB AutoCAD DLLs, not physically overwriting the OOTB AutoCAD DLLs.  When your application runs, it finds the OOTB AutoCAD DLLs instead of the SDK versions.  Since the OOTB version is an extension of the SDK (or the SDK is a simplified version of the OOTB one, same diff...) from your DLL's point of view there is no difference at run-time.

Doing it this way allows Visual Studio to reference the content it needs without having to wade through the additional stuff AutoCAD needs but Visual Studio doesn't need for development (which is the point of the SDK).

Oh, I see, thanks!  ^-^

Quote
And sorry for the threadjack, cannorth.   :angel:

Yeah, sorry about that.  :-)

Jeff H

  • Needs a day job
  • Posts: 6150
Re: ManagedMapAPI.dll load assembly problem
« Reply #15 on: July 21, 2011, 08:27:04 AM »
If you look the dll's from the SDK they are nothing but empty methods.
Basiclly just the definition
They stripped out guts and left all you needed for your code to reference it and compile.

From SDK
Code: [Select]
[TypeDescriptionProvider("Autodesk.AutoCAD.ComponentModel.TypeDescriptionProvider`1[[Autodesk.AutoCAD.DatabaseServices.Line, acdbmgd]], acdbmgd")]
[Wrapper("AcDbLine")]
public class Line : Curve
{
[UnitType(UnitType.Angle)]
public double Angle
{
get
{
}
}

public Vector3d Delta
{
get
{
}
}

public Point3d EndPoint
{
get
{
}
set
{
}
}

[UnitType(UnitType.Distance)]
public double Length
{
get
{
}
}

public Vector3d Normal
{
get
{
}
set
{
}
}

public Point3d StartPoint
{
get
{
}
set
{
}
}

[UnitType(UnitType.Distance)]
public double Thickness
{
get
{
}
set
{
}
}

public Line(Point3d pointer1, Point3d pointer2)
{
}

public Line()
{
}

protected internal Line(IntPtr unmanagedObjPtr, bool autoDelete)
{
}

internal AcDbLine* GetImpObj()
{
}
}


From AutoDesk Folder it messed up but you get the idea
Code: [Select]
// Type: Autodesk.AutoCAD.DatabaseServices.Line
// Assembly: Acdbmgd, Version=18.2.0.0, Culture=neutral, PublicKeyToken=null
// Assembly location: C:\Program Files\Autodesk\AutoCAD MEP 2012\acdbmgd.dll

using \u003CCppImplementationDetails\u003E;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Autodesk.AutoCAD.DatabaseServices
{
  [Wrapper("AcDbLine")]
  [TypeDescriptionProvider("Autodesk.AutoCAD.ComponentModel.TypeDescriptionProvider`1[[Autodesk.AutoCAD.DatabaseServices.Line, acdbmgd]], acdbmgd")]
  public class Line : Curve
  {
    [UnitType(UnitType.Distance)]
    public double Length
    {
      [Category("Geometry")] get
      {
        AcGePoint3d acGePoint3d1;
        AcGePoint3d acGePoint3d2;
        return \u003CModule\u003E.AcGePoint3d\u002EdistanceTo(\u003CModule\u003E.AcDbLine\u002EstartPoint(this.GetImpObj(), &acGePoint3d1), \u003CModule\u003E.AcDbLine\u002EendPoint(this.GetImpObj(), &acGePoint3d2));
      }
    }

    [UnitType(UnitType.Angle)]
    public double Angle
    {
      [Category("Geometry")] get
      {
        AcGePoint3d acGePoint3d1;
        \u003CModule\u003E.AcDbLine\u002EstartPoint(this.GetImpObj(), &acGePoint3d1);
        AcGePoint3d acGePoint3d2;
        \u003CModule\u003E.AcDbLine\u002EendPoint(this.GetImpObj(), &acGePoint3d2);
        \u0024ArrayType\u0024\u0024\u0024BY02N arrayTypeBy02N1;
        ^(double&) @arrayTypeBy02N1 = ^(double&) @acGePoint3d1;
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 8) = ^(double&) ((IntPtr) &acGePoint3d1 + 8);
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 16) = ^(double&) ((IntPtr) &acGePoint3d1 + 16);
        \u0024ArrayType\u0024\u0024\u0024BY02N arrayTypeBy02N2;
        ^(double&) @arrayTypeBy02N2 = ^(double&) @acGePoint3d2;
        ^(double&) ((IntPtr) &arrayTypeBy02N2 + 8) = ^(double&) ((IntPtr) &acGePoint3d2 + 8);
        ^(double&) ((IntPtr) &arrayTypeBy02N2 + 16) = ^(double&) ((IntPtr) &acGePoint3d2 + 16);
        return \u003CModule\u003E.acutAngle((double*) &arrayTypeBy02N1, (double*) &arrayTypeBy02N2);
      }
    }

    public Vector3d Delta
    {
      [Category("Geometry")] get
      {
        AcGePoint3d acGePoint3d1;
        \u003CModule\u003E.AcDbLine\u002EendPoint(this.GetImpObj(), &acGePoint3d1);
        \u0024ArrayType\u0024\u0024\u0024BY02N arrayTypeBy02N1;
        ^(double&) @arrayTypeBy02N1 = ^(double&) @acGePoint3d1;
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 8) = ^(double&) ((IntPtr) &acGePoint3d1 + 8);
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 16) = ^(double&) ((IntPtr) &acGePoint3d1 + 16);
        \u0024ArrayType\u0024\u0024\u0024BY02N arrayTypeBy02N2;
        \u003CModule\u003E.acdbWcs2Ucs((double*) &arrayTypeBy02N1, (double*) &arrayTypeBy02N2, false);
        AcGePoint3d acGePoint3d2;
        AcGePoint3d* acGePoint3dPtr = \u003CModule\u003E.AcDbLine\u002EstartPoint(this.GetImpObj(), &acGePoint3d2);
        __memcpy(@acGePoint3d1, (IntPtr) acGePoint3dPtr, 24);
        ^(double&) @arrayTypeBy02N1 = ^(double&) @acGePoint3d1;
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 8) = ^(double&) ((IntPtr) &acGePoint3d1 + 8);
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 16) = ^(double&) ((IntPtr) &acGePoint3d1 + 16);
        \u0024ArrayType\u0024\u0024\u0024BY02N arrayTypeBy02N3;
        \u003CModule\u003E.acdbWcs2Ucs((double*) &arrayTypeBy02N1, (double*) &arrayTypeBy02N3, false);
        ^(double&) @arrayTypeBy02N1 = ^(double&) @arrayTypeBy02N2 - ^(double&) @arrayTypeBy02N3;
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 8) = ^(double&) ((IntPtr) &arrayTypeBy02N2 + 8) - ^(double&) ((IntPtr) &arrayTypeBy02N3 + 8);
        ^(double&) ((IntPtr) &arrayTypeBy02N1 + 16) = ^(double&) ((IntPtr) &arrayTypeBy02N2 + 16) - ^(double&) ((IntPtr) &arrayTypeBy02N3 + 16);
        return new Vector3d(^(double&) @arrayTypeBy02N1, ^(double&) ((IntPtr) &arrayTypeBy02N1 + 8), ^(double&) ((IntPtr) &arrayTypeBy02N1 + 16));
      }
    }

    public Vector3d Normal
    {
      [Category("Geometry")] get
      {
        AcGeVector3d acGeVector3d;
        return new Vector3d(\u003CModule\u003E.AcDbLine\u002Enormal(this.GetImpObj(), &acGeVector3d));
      }
      set
      {
        int num = (int) \u003CModule\u003E.AcDbLine\u002EsetNormal(this.GetImpObj(), (AcGeVector3d*) (int) &param0);
        if (num != 0)
          throw new Autodesk.AutoCAD.Runtime.Exception((ErrorStatus) num);
      }
    }

    [UnitType(UnitType.Distance)]
    public double Thickness
    {
      [Category("General")] get
      {
        return \u003CModule\u003E.AcDbLine\u002Ethickness(this.GetImpObj());
      }
      set
      {
        int num = (int) \u003CModule\u003E.AcDbLine\u002EsetThickness(this.GetImpObj(), param0);
        if (num != 0)
          throw new Autodesk.AutoCAD.Runtime.Exception((ErrorStatus) num);
      }
    }

    public override Point3d EndPoint
    {
      [Category("Geometry")] get
      {
        return base.EndPoint;
      }
      set
      {
        int num = (int) \u003CModule\u003E.AcDbLine\u002EsetEndPoint(this.GetImpObj(), (AcGePoint3d*) (int) &param0);
        if (num != 0)
          throw new Autodesk.AutoCAD.Runtime.Exception((ErrorStatus) num);
      }
    }

    public override Point3d StartPoint
    {
      [Category("Geometry")] get
      {
        return base.StartPoint;
      }
      set
      {
        int num = (int) \u003CModule\u003E.AcDbLine\u002EsetStartPoint(this.GetImpObj(), (AcGePoint3d*) (int) &param0);
        if (num != 0)
          throw new Autodesk.AutoCAD.Runtime.Exception((ErrorStatus) num);
      }
    }

    public Line(Point3d pointer1, Point3d pointer2)
    {
      void* voidPtr = \u003CModule\u003E.AcHeapOperators\u002EallocRawMem(8U);
      AcDbLine* acDbLinePtr1 = (AcDbLine*) voidPtr;
      AcDbLine* acDbLinePtr2;
      // ISSUE: fault handler
      try
      {
        acDbLinePtr2 = \u003CModule\u003E.AcDbLine\u002E\u007Bctor\u007D((AcDbLine*) voidPtr, (AcGePoint3d*) (int) &pointer1, (AcGePoint3d*) (int) &pointer2);
      }
      __fault
      {
        // ISSUE: method pointer
        // ISSUE: cast to a function pointer type
        \u003CModule\u003E.___CxxCallUnwindDelDtor((__FnPtr<void (void*)>) __methodptr(AcHeapOperators\u002Edelete), (void*) acDbLinePtr1);
      }
      // ISSUE: explicit constructor call
      base.\u002Ector((IntPtr) ((void*) acDbLinePtr2), true);
    }

    public Line()
    {
      void* voidPtr = \u003CModule\u003E.AcHeapOperators\u002EallocRawMem(8U);
      AcDbLine* acDbLinePtr1 = (AcDbLine*) voidPtr;
      AcDbLine* acDbLinePtr2;
      // ISSUE: fault handler
      try
      {
        acDbLinePtr2 = \u003CModule\u003E.AcDbLine\u002E\u007Bctor\u007D((AcDbLine*) voidPtr);
      }
      __fault
      {
        // ISSUE: method pointer
        // ISSUE: cast to a function pointer type
        \u003CModule\u003E.___CxxCallUnwindDelDtor((__FnPtr<void (void*)>) __methodptr(AcHeapOperators\u002Edelete), (void*) acDbLinePtr1);
      }
      // ISSUE: explicit constructor call
      base.\u002Ector((IntPtr) ((void*) acDbLinePtr2), true);
    }

    protected internal Line(IntPtr unmanagedObjPtr, [MarshalAs(UnmanagedType.U1)] bool autoDelete)
      : base(unmanagedObjPtr, autoDelete)
    {
    }

    internal unsafe AcDbLine* GetImpObj()
    {
      return (AcDbLine*) base.GetImpObj();
    }
  }
}


BillZndl

  • Guest
Re: ManagedMapAPI.dll load assembly problem
« Reply #16 on: July 21, 2011, 10:00:33 AM »
Hmm, interesting...

The OP was talking about an already compiled assembly and I was thinking his problems were similar to what I experienced when netloading a project that I had updated from VS2005.
I was actually having multiple problems with compiler warnings, netloading problems and system security settings.
http://www.theswamp.org/index.php?topic=38392.msg436738#msg436738
http://forums.autodesk.com/t5/NET/Netload-giving-trouble/m-p/3049974#M23872

Again, as a beginner/part time programmer, I searched the web and by substituting the SDK files mentioned when building the project,
switching back to 3.5 net and adding the loadfromremotelocations switch to the acad.exe.config file took care of things i was having trouble with.

In the future I'll just keep my mouth shut and read the replies but then I do learn something everytime whether good or bad.  :laugh:


« Last Edit: July 21, 2011, 01:54:46 PM by BillZndl »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: ManagedMapAPI.dll load assembly problem
« Reply #17 on: July 21, 2011, 10:20:00 AM »
He was saying a new API.

You can build a application with 2008 or 2005 and load it 2012 but you cannot use the dll's for 2012 since they are built with a newer version of .NET.