Author Topic: References in a project - ActiveX  (Read 2389 times)

0 Members and 1 Guest are viewing this topic.

latour_g

  • Newt
  • Posts: 184
References in a project - ActiveX
« on: March 25, 2015, 02:14:03 PM »
Hi,

I have copy a project and when I try to run this new project in debug mode, I have an error message (see image) and it won't load the palette in AutoCAD.
I am able to netload the dll and the palette open fine if I'm not in debug mode.

In the reference of my project, for AXDBLib and ACSMCOMPONENTS19Lib, I have notice that if I try to change the path (for the new one since it still refer to the old project), the file type will change from ActiveX to Assembly (see image).  I don't understand why..

Maybe those two problems are link together ... but I don't know, I'm lost with that !

Let me know if I'm not clear!
« Last Edit: March 26, 2015, 09:32:17 AM by latour_g »

n.yuan

  • Bull Frog
  • Posts: 348
Re: References in a project - ActiveX
« Reply #1 on: March 26, 2015, 09:41:12 AM »
Firstly, you did not say, I have to assume that "ToolsPalette" is a System.Windows.Forms.Control/UserControl.

Then, regarding the ActiveX reference. You need to change "Embed Interop Types" to "False" and make sure "Copy Local" is set correctly: If you use the AutoCAD Interop assemblies downloaded from ObjectARX, then "Copy Local" should be set to "False", because the Interop assemblies is installed in AutoCAD installation folder (but not in the GAC, as AutoCAD2012 or older, any more). However, if the interop assemblies is generated by Visual Studio (you set reference to AutoCAD type library by using References dialog box's COM tab), then "Copy Local" should be "True".

latour_g

  • Newt
  • Posts: 184
Re: References in a project - ActiveX
« Reply #2 on: March 26, 2015, 01:56:02 PM »
Yes that's is, ToolsPalettes is a System.Windows.Forms.UserControl

I was not sure for Copy Local if I had to choose True or False, I tried them both and it doesn't change anything for my debug problem, maybe it's not even rely.


n.yuan

  • Bull Frog
  • Posts: 348
Re: References in a project - ActiveX
« Reply #3 on: March 26, 2015, 05:49:53 PM »
Did you set "Embed Interop TYpes" to "False"?

latour_g

  • Newt
  • Posts: 184
Re: References in a project - ActiveX
« Reply #4 on: March 27, 2015, 09:10:25 AM »
Yes I did

n.yuan

  • Bull Frog
  • Posts: 348
Re: References in a project - ActiveX
« Reply #5 on: March 27, 2015, 09:56:17 AM »
OK. I guess your palette (UserControl) (or your project) has the reference to SheetManager COM component. That is, when you go to "Add references" dialog box and select the Sheet Manager component in the "COM" tab, VIsual Studio generates 2 interop assemblies:

interop.AcSmComponents19lib.dll
Interop.AXDbLib.dll (this is a dependency to the Sheet Manager component)

When you move your project files to a new project, you need to have these 2 interop assemblies both referenced, and "Copy Local" must be "True", "Embed Interop Types" must be "False".

To make things simple, in the newly created project, you simply remove old references, and go to "Add references" dialog box and "COM" tag to add reference to sheet manager component. This way, Visual Studio will create fresh interop assemblies for you, which would guaranteed to work (do not forget to make "Copy Local" and "Embed Interop Types" correctly set).

latour_g

  • Newt
  • Posts: 184
Re: References in a project - ActiveX
« Reply #6 on: March 27, 2015, 11:19:37 AM »
Yes, you're right, I'm using reference to SheetManager COM component in my project.
I add Reference with COM tag and now the reference show correctly.

I also solved my problem for the debug mode.  My project is located is my C: drive and I chose to generate the DLL in my D: drive.
I put the DLL back in my C: drive and now everything is working fine.

Thank for you help !