0

I have a visualbasic application that interacts with several versions of software (Catia) The Visual basic code is common to all versions of Catia software but it only works if the dlls of the correct version are referenced. Is it possible to reference the dlls of all Catia software versions in the app (they have the same name) and to use the correct dlls after having detected the software version.

  • I'd suggest to check on the "Specific Version" setting on the reference (see the Properties window with the reference selected in the Solution Explorer). If you turn it off, you will be able to work off of any assembly of the same name. The risk is that you will require the versions you use to maintain binary compatibility on any features you use. If you have to handle version discovery, I would expect it to become quite a bit more complicated. – Craig Aug 08 '22 at 14:49

3 Answers3

0

I don't think there is any simple way to work around this.

If you have multiple versions you just have to run CNEXT -regserver (as admin) in the BIN folder of the version you want before CATIA is started.

Even this may not prevent problems, as libraries which change or disappear between versions and settings may not be compatible.

C R Johnson
  • 964
  • 1
  • 5
  • 12
0

I understand that you have a compiled .exe referencing the catia-api. I encountered the same problems with our applications. Two solutions that worked for me:

  1. compile separate .exes for each catia release you require. Means: have one catia release running, then compile. Repeat with next release. The -regserver should be done by Catia when starting (which I am not 100% sure about, you might still need to do the -regserver as C R Johnson explained).

  2. Use LateBinding which means do not reference any catia-dll/tlb at all. Instead use reflection to call api-methods. This is a lot more effort when developing your app, because you cannot use IntelliSense. (As a workaround you could develop with EarlyBinding in only one Catia release. When finished, change your code to LateBinding getting rid of all catia-api-references.)

Tom667
  • 95
  • 1
  • 10
0

I developed and deployed an application with this type of architecture to meet this need to work with several versions of CATIA from a single .exe.

Yes, DRAFTINGITF.dll need to be unique for each Version

  • MainProject : Dependencies Catlib, Catlib27, Catlib30
  • Catlib : All the need to work with CATIA V5 | Dependecies all .tlb of Catia
  • Catlib27 : Specific methods to work with DRAFTINGITF.dll on CatiaV5R27 | Depedencies Catlib
  • Catlib30 Same methods than Catlib27 but with DRAFTINGITF.dll built by CatiaV5R30 | Dependencies Catlib

Catlib27 contains the DraftingTypeLib.tlb (building DRAFTINGITF.dll)

Catlib30 contains the DRAFTINGITF.dll built after using application using CatiaV5R30 as debug mode.

Catlib contains an Interface with all methods specific to drafting.

namespace catLib
{
    public class CatHandler
    {
    public string Version
        {
            get
            {
                if(Catia == null) { return ""; }
                return Catia.SystemConfiguration.Release.ToString();
            }
        }
     public ICatHandler CatHandlerBySpecificVersion { get; set; }
    }
}

The MainProject returns the version of the dll 27 or 30 depending on the CATIA version used

ICatHandler catHandler = null;
if (CatHandler._CATIA.Version == "27")
{
CatHandler._CATIA.CatHandlerBySpecificVersion = new catLib27.CatHandler27();
 }
 else if (CatHandler._CATIA.Version == "30")
 {
 CatHandler._CATIA.CatHandlerBySpecificVersion = new catLib30.CatHandler30();
 }

example project catlib27:

namespace catLib27
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    public class CatHandlerVersionAttribute : Attribute
    {
        public string Version { get; }

        public CatHandlerVersionAttribute(string version)
        {
            Version = version;
        }
    }

    [CatHandlerVersion("27")]
    public class CatHandler27 : catLib.ICatHandler
    {
        public void createPlan(string pathFile, itemCATIA itemCatia, string userName)
        {

        }
    }

Important: On each project catlib27 et catlib30, please right click on the reference .TLB and .Dll => Local Copye = 'YES'.

Important to before each publish: Clean the solution, Rebuild, Publish (and Deploy).

Only one .exe is published even if users need to work with multiple version of Catia. Working well for versions 27 et 30 => users can automatize drafts for these versions without issues.

Disvoys
  • 61
  • 1
  • 7