Right now my .NET macro is built for 17.6.0.1021, I found that if I load it into earlier version of CorelDRAW X7 it would outright crash the whole program.
Is there a way to check CorelDRAW DLL Assembly version so that it would prompt user to update their CorelDRAW? I'm thinking that I should do this within VBA before calling the DLL, but I haven't found out how.
In VBA this simple code returns Corel Version:
You can use it in a corel Event...
Debug.Print Application.Version
You can check that using a VBScript:
1 2 3 4
Dim Cor Set Cor = CreateObject("CorelDraw.Application") MsgBox "Corel " & Cor.Version, , "Corel Version" Set Cor = nothing
Or directly in C# using Corel COM object or not. Using it in a similar way of VBScript or extracting from Registry the Corel.exe path and than the version of VGCore.dll in Assembly folder. Relatively easy...
Spot on, thank you.
In C# Addon you can modify the Constructor in Main entry
public partial class DockerUI : UserControl { private Corel.Interop.VGCore.Application corelApp; public DockerUI(dynamic app) //use reflection for support any corel version { InitializeComponent(); if (!versionOk(app.Version)) { //Show a friendly message return; } this.corelApp = app as Corel.Interop.VGCore.Application;//cast for correct type, reflection will showdown your app } protected bool versionOk(string version) { //Make your check return false; } }
Could this code run even though the addon is compiled with different assembly?
Yes this is Works in any versiion, but if you try cast a more new versiion for a older versiion you Will got a exceptiion