bonus630 / DockerTemplateX7

CorelDraw Addons Templates for Visual Studio 2005 or Higher. This templates provides easy and fast way to build a custom addin for CorelDRAW, here you can find four diferents templates. A control template, to build a fast and more simple addin, this control will be placed in standard tool bar. A custom tool project, based in official template, but updated to recent versions of visual studio and CorelDRAW. And the big one, docker template, to build a complex addin allocaded in a CorelDRAW docker.
https://marketplace.visualstudio.com/items?itemName=bonus630.CorelDrawDockerTemplate
11 stars 2 forks source link

Sometimes CorelDRAW does not load UserControl #11

Open finich1981 opened 1 year ago

finich1981 commented 1 year ago

Sometimes CorelDRAW does not load UserControl, and the docker window is empty, only the name and icon. On my computer, where the development environment is located, everything works well, some users have this problem, not everyone. Maybe the problem is in XSLT. My project https://sourceforge.net/projects/litholo-docker/files/Lithology%20Docker%203.0.1.0.zip/download

bonus630 commented 1 year ago

Sorry, this "problem" has been known to me for years, problems in XSLT files cause your addon not to be shown, in the case of docker it would not be available. This problem is most often related to VGCore versioning and modified versions. Note that for the controls present in the dockers to be displayed it is necessary to execute the "InitializeComponent" method in the constructor of your Docker, if this method is not executing we have the blank control, so the error occurs before, probably at the moment that .NET tries loads the unmanaged DLL into memory

bonus630 commented 1 year ago

image`

You can try to resolve the assemblies path at runtime, but this will cause problems with other addons loaded in coreldraw

  AppDomain.CurrentDomain.AssemblyResolve += (s, args) =>
            {
                string name = args.Name;
                if (name.Contains("Corel.Interop.VGCore"))
                {
                    string vgCoreDllPath = @"<CorelProgramFolder>\Assemblies\Corel.Interop.VGCore.dll";
                    Assembly asm = Assembly.LoadFile(vgCoreDllPath);
                    return asm;
                }
                return args.RequestingAssembly;
            };
            InitializeComponent();
finich1981 commented 11 months ago

Unfortunately, this does not work in my case, since it does not come to the class constructor. Docker does not load if there is a link to the VGCore assembly in the reference. Only the late binding via dynamic helped me. Also a good way could be to use ComImport to import class descriptions and interfaces from the assembly without connecting it, but I did not succeed. The only late binding problem I've encountered is using structures and classes from the top level of the VGCore namespace. An Application object is passed to the constructor of the docker class, and I can't get objects from VGCore. For example, I use the CurveElement structure to create arrays of curve elements and to use them further in CreateCurveFromArray, and with late binding I don't have access to it. I also decompiled different versions of the Vcore assembly and found that some classes and interfaces have different GUIDs from version to version, while others do not change, which is very strange.