Author Topic: Multi-Version assembly references  (Read 6373 times)

0 Members and 1 Guest are viewing this topic.

slappy

  • Guest
Multi-Version assembly references
« on: January 31, 2011, 01:54:21 PM »
I probably already know the answer to this, but I will ask anyway.  Coding in VS express 2010 using VB.NET for AutoCAD Architecture.

Problem: assembly referencing for multiple windows versions (xp 32, 7 64), multiple CAD versions(2010, 2011, and on).

My code is written, and on review, I realized due to my references I could be loading the wrong assemblies into CAD.  I code on a windows 7 64 bit system for most of the office using XP 32 bit.  Now I have separate projects for the 32 bit windows, but I notice windows 7 has a differnet assembly pathing structure than XP.  Most users have at least two versions of AutoCad installed.

My concern is pathing.  To write for 32 bit systems I have the ObjectARX 32 bit dlls in a path that will not exist on the users system.  Will the pathing cause issue or will it just load whatever it finds?  Should I have a  version for each windows/AutoCAD version combination?  What's the best practice for referencing assemblies in this scenario?

This is all base on early binding.

Hope my question make sense.

Thanks

Slap

kaefer

  • Guest
Re: Multi-Version assembly references
« Reply #1 on: February 01, 2011, 03:51:15 AM »
Will the pathing cause issue or will it just load whatever it finds?

As I understand the issue, the general consensus appears to be thus:
You build with Platform target "Any CPU".
You do not distribute the assemblies against which you have build.

Quote
Should I have a  version for each windows/AutoCAD version combination?

From the above, it wouldn't be necessary. Handling version-specific features like hatch transparency would require a version check, but not a differnt build.

Quote
This is all base on early binding.

In my opinion that's not always the best course of action, since certain API incompatibilities can be handled by Reflection, e.g. renamed property TextStyle (<= 2009) and TextStyleId (>= 2010).

Quote
What's the best practice for referencing assemblies in this scenario?

I'd like to see an authoritative answer to this question as well.

Cheers, Thorsten

slappy

  • Guest
Re: Multi-Version assembly references
« Reply #2 on: February 01, 2011, 10:43:45 AM »
Will the pathing cause issue or will it just load whatever it finds?
Assuming this:
Quote
You do not distribute the assemblies against which you have build.
Is that a yes?

Quote
Quote
Should I have a  version for each windows/AutoCAD version combination?

From the above, it wouldn't be necessary. Handling version-specific features like hatch transparency would require a version check, but not a differnt build.
[/quote]
OK, but to an extreme degree, couldn't you conceivably do this for each interop"eration"?

Quote
Quote
This is all base on early binding.
In my opinion that's not always the best course of action, since certain API incompatibilities can be handled by Reflection, e.g. renamed property TextStyle (<= 2009) and TextStyleId (>= 2010).
I'm still unsure to the term "Reflection", could you use more, uh, layman terms... :ugly:

Quote
Quote
What's the best practice for referencing assemblies in this scenario?

I'd like to see an authoritative answer to this question as well.
Nice!  Guess we are all shooting arrows in the dark, just some of us are wearing sunglasses.

Thanks
Slap

sinc

  • Guest
Re: Multi-Version assembly references
« Reply #3 on: February 01, 2011, 11:17:07 AM »
You shouldn't need separate projects for 32-bit and 64-bit.  And if you are writing solely a .NET program, with no Interops, PInvokes, or such stuff, you shouldn't need separate builds for the different variants of Autocad.  Just reference the managed DLLs from the ObjectARX 2010 directory, and make sure you turn off the "Copy Local" option.

You can run into problems on your target machines, however, if you have side-by-side installs of 32-bit and 64-bit variants of Autocad from the same year.  The problem is that the assemblies get installed into something in Windows called the Global Access Cache, or GAC.  For any given release of Autocad, both the 32-bit and 64-bit versions of AutoCAD register their assemblies using the same GUID.  So this value can only point to either 32-bit Autocad or 64-bit Autocad.  The upshot is that your .NET assemblies will only run on one of them.  For example, it might work fine on your 32-bit installations of Autocad products, but you get an E_NOINTERFACE error on your 64-bit installs.  Or vice-versa.

slappy

  • Guest
Re: Multi-Version assembly references
« Reply #4 on: February 01, 2011, 11:46:56 AM »
...side-by-side installs of 32-bit and 64-bit variants of Autocad from the same year.

Who does this... 

LE3

  • Guest
Re: Multi-Version assembly references
« Reply #5 on: February 01, 2011, 11:55:08 AM »
I have some projects target from 2007 to 2011 32/64 and all use their specific references from the arx sdk - some plain .net, others mix managed/unmanaged, and with pinvoke calls and with use of conditional compilation symbols to switch from different method signatures changes.

My 0.000000000000000001 cts :)

slappy

  • Guest
Re: Multi-Version assembly references
« Reply #6 on: February 01, 2011, 11:58:34 AM »
I have some projects target from 2007 to 2011 32/64 and all use their specific references from the arx sdk - some plain .net, others mix managed/unmanaged, and with pinvoke calls and with use of conditional compilation symbols to switch from different method signatures changes.

My 0.000000000000000001 cts :)

Yea, what he said.   :ugly:

LE3

  • Guest
Re: Multi-Version assembly references
« Reply #7 on: February 01, 2011, 12:04:07 PM »
I have some projects target from 2007 to 2011 32/64 and all use their specific references from the arx sdk - some plain .net, others mix managed/unmanaged, and with pinvoke calls and with use of conditional compilation symbols to switch from different method signatures changes.

My 0.000000000000000001 cts :)

Yea, what he said.   :ugly:
Was clear as mud ?

slappy

  • Guest
Re: Multi-Version assembly references
« Reply #8 on: February 01, 2011, 12:10:39 PM »
I have some projects target from 2007 to 2011 32/64 and all use their specific references from the arx sdk - some plain .net, others mix managed/unmanaged, and with pinvoke calls and with use of conditional compilation symbols to switch from different method signatures changes.

My 0.000000000000000001 cts :)

Yea, what he said.   :ugly:
Was clear as mud ?
You lost me after "I"... :lmao:

LE3

  • Guest
Re: Multi-Version assembly references
« Reply #9 on: February 01, 2011, 12:17:20 PM »
OK, rewind....

First:

- What AutoCAD versions do you have?
- Do you have their ObjectARX SDK for each of them?


You lost me after "I"... :lmao:

slappy

  • Guest
Re: Multi-Version assembly references
« Reply #10 on: February 01, 2011, 12:54:30 PM »
Sorry, being facicious.

Currently, I've got ACA 2010 32bit project and 64 bit project, windows neutral (meaning there doesn't seem to be issue between XP and 7).  I code, test and compile in windows 7 64 bit with ACA 2010 64bit.  I am in the process of testing them in a later version (which will be call it ACA MMXII).

It sounds as if as long as my local copy is off I can use as is.  Just attach the latest assemblies and check for errors.

I won't be messing around with "If this version then do that, else do this..."  Just doesn't seem time effective.  The projects are not complex and if maintaining them only requires a yearly check for errors, I'm cool with that.

Oh! and yes I do have the ObjectARX SDK.

sinc

  • Guest
Re: Multi-Version assembly references
« Reply #11 on: February 01, 2011, 01:09:17 PM »
...side-by-side installs of 32-bit and 64-bit variants of Autocad from the same year.

Who does this...  

Various customers of mine ran into this problem, since C3D was only available in 32-bit versions prior to the 2011 version.  So they might have a side-by-side install of C3D along with 64-bit Autocad or some other vertical.

Some Autodesk resellers also saw the problem, since they often install lots of Autodesk products side-by-side on their machines.

It wasn't a common problem, but I thought I'd mention it, because it was a nasty issue to figure out...
« Last Edit: February 01, 2011, 01:12:57 PM by sinc »

sinc

  • Guest
Re: Multi-Version assembly references
« Reply #12 on: February 01, 2011, 01:11:23 PM »
I have some projects target from 2007 to 2011 32/64 and all use their specific references from the arx sdk - some plain .net, others mix managed/unmanaged, and with pinvoke calls and with use of conditional compilation symbols to switch from different method signatures changes.

We do something like that, too, but it adds "complications"...  And it sounds like Slappy may not need to worry about this sort of thing.

slappy

  • Guest
Re: Multi-Version assembly references
« Reply #13 on: February 01, 2011, 01:33:45 PM »
...use of conditional compilation symbols to switch from different method signatures changes.

Is there a simple translation for this statement...  Maybe it's the terms that are loosing me...

LE3

  • Guest
Re: Multi-Version assembly references
« Reply #14 on: February 01, 2011, 02:06:25 PM »
I read that you only target 2010 right now.

Steps:
1. you have a solution with a single project .csproj
2. rename the project to i.e. myproject18 (for 32 bits)
3. then go to myproject18.csproj, make a copy an rename it to i.e: myproject18x64.csproj (for 64 bits)
4. go back to your solution and add a new project into your solution, select myproject18x64.csproj.
5. then go to myproject18 and do the autocad references to target objectarxsdklocation\ObjectARX 2010\inc-win32\ and select AcDbMgd.dll and  AcMgd.dll - copy local to false
6. then go to myproject18x64 and do the autocad references to target objectarxsdklocation\ObjectARX 2010\inc-x64\ and select AcDbMgd.dll and  AcMgd.dll - copy local to false

HTH.

Is there a simple translation for this statement...  Maybe it's the terms that are loosing me...

Open properties, go to the Build section tab and there is that section, can be use to define your conditional vars and use them like or when you are using an early or new method that is not available or have changed the signature:
Quote
#if (_ACADTARGET_18)
        const string _ARX = "Ext18.arx"; // target A2010
#endif
#if (_ACADTARGET_17)
        const string _ARX = "Ext17.arx"; // target A2007 trough A2009
#endif
#if (_ACADTARGET_18x64)
        const string _ARX = "Ext18x64.arx"; // target A2009
#endif
#if (_ACADTARGET_17x64)
        const string _ARX = "Ext17x64.arx"; // target A2009
#endif