Author Topic: How can I make a multi-version app?  (Read 2479 times)

0 Members and 1 Guest are viewing this topic.

Pepe

  • Newt
  • Posts: 87
How can I make a multi-version app?
« on: December 13, 2011, 11:09:27 AM »
Hi!

(My first steps on VB.NET, so please, be patient with me as my english is not as good as I would, and my technical vocabulary in this environment even worse!  :oops:)

I'm building a little app. which I want to run on different versions of Autocad, and even on 32 and 64 bits machines.

I've written and compiled as .exe it using Visual Studio 2008 (framework 3.5?) and Autocad 2008. It works fine on my machine, but I tried to make it work on a 64 bits machine and Autocad 2007, and it 'spitted' a naughty message complaining about 'interop' versions  :-o.

Here are my requests:

Is there any way that my app. detect itself which 'interop' use?

(million dollar question) HOW?  :?

Thanks in advance.

tik

  • Guest
Re: How can I make a multi-version app?
« Reply #1 on: December 14, 2011, 09:11:14 AM »
Are you trying to run this app as plug in or a separate .exe. I am familiar with plugins and for plugins to work in both 32 bit and 64 bit try this. In visual studio under your project properties inside the Build tab change Platform target to "Any CPU" and that will build your plug in for both 32 bit and 64 bit architecture.

kaefer

  • Guest
Re: How can I make a multi-version app?
« Reply #2 on: December 14, 2011, 09:28:52 AM »
"Any CPU"

Doesn't help with interop. See Late Binding instead.

Pepe

  • Newt
  • Posts: 87
Re: How can I make a multi-version app?
« Reply #3 on: December 14, 2011, 11:43:53 AM »
Thank you for the answers,

kaefer, thank you for improving my vocuabulary :-D !

YES! 'late binding' is exactly what I need.

I've tried it using this code to get the object (I suppose it's a very 'newbie' code... :oops:, but mine...) and it works.

Code - vb.net: [Select]
  1.         Dim AcadOb As Object
  2.         Dim AcadID As String
  3.         Dim i As Integer
  4.         For i = 16 To 19 Step 1
  5.             AcadID = "AutoCAD.Application." + CStr(i)
  6.             Try
  7.                 AcadOb = CreateObject(AcadID)
  8.                 If AcadOb.hwnd Then
  9.                     Exit For
  10.                 End If
  11.             Catch ex As Exception                
  12.             End Try
  13.         Next
  14.  

But it happens that Autocad starts again although it's already working.

How could I know if Autocad is working and then get it as an object? (I've searching and I've found something about 'marshaling', which i suppose it's the way, but I don't understand very well the concept)

Or... Anybody has an example about?

Thank you in advance again.

ChuckHardin

  • Guest
Re: How can I make a multi-version app?
« Reply #4 on: December 20, 2011, 06:34:49 PM »
Try
AcadOb = GetObject(AcadID)
then if it errors do
AcadOb = CreateObject(AcadID)

Pepe

  • Newt
  • Posts: 87
Re: How can I make a multi-version app?
« Reply #5 on: December 22, 2011, 07:58:14 AM »
Thanks Chuck!

It worked with AcadOb = GetObject(, AcadID).

It was easier than I thought!

Thanks again!

ChuckHardin

  • Guest
Re: How can I make a multi-version app?
« Reply #6 on: December 25, 2011, 02:21:22 PM »
GetObject only works if AUtoCad is open so be sure to look for the error and then try CreateObject then if it errors try a different version of AutoCAD.