Automatically resolve assemblies from separate folder

Posted by: christoph.luidold on 8 April 2018, 11:38 pm EST

    • Post Options:
    • Link

    Posted 8 April 2018, 11:38 pm EST

    Hi,

    I’m using C1Datagrid for my application. The current version i use is C1.WPF.4, Version=4.0.20173.580.

    I work on an project where i extend an existing application via C#-Addins. The existing application is called “Eplan Electric P8”. When i start the application the .NET Runtime creates an AppDomain. The base directory is located in “E:\EplanP8\Platform\Bin”.

    My Addins are located in “E:\Eplan P8\Custom Addins”.

    When i start the software and call my addin with the UI using the c1Datagrid, i always get an error that the DLL “C1.WPF.DataGrid.Filters.4.dll” and “C1.WPF.DataGrid.Summaries.4.dll” couldn’t be found. I already make sure, that the files really exist in the addin directory.

    If i move the missing DLLs to the base directory of the appdomain (E:\EplanP8\Platform\Bin) everything works fine.

    I have also tried to setup an assembly resolver with following code:

    
    private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
            {
                // Ignore missing resources
                if (args.Name.Contains(".resources"))
                {
                    return null;
                }
    
                // check for assemblies already loaded
                var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name);
                if (assembly != null)
                {
                    return assembly;
                }
    
                // Try to load by filename - split out the filename of the full assembly name
                // and append the base path of the original assembly (ie. look in the same dir)
                var filename = args.Name.Split(',')[0] + ".dll".ToLower();
    
                var asmFile = Path.Combine(@"E:\EplanP8\Custom Addins\", filename);
    
                try
                {
                    var assemblyFromFile = Assembly.LoadFrom(asmFile);
                    return assemblyFromFile;
                }
                catch
                {
                    // do nothing
                    return null;
                }
            }
    
    

    can anyone tell me, what i am doin wrong or what is missing in my case?

    thanks.

    Chris

  • Posted 9 April 2018, 10:12 pm EST

    Hi Chris,

    After going through the description of the issue you are facing, I would like to confirm two things first:

    1. Could you please check whether the issue appears with Microsoft dlls too or not (this is just to make sure whether this issue is generic or something related to ComponentOne).
    2. Could you please confirm that the main project in which you are referencing the addin does not directly use ComponentOne i.e., the addin(s) refer ComponentOne and your main project refers this addin and does not interacts with ComponentOne in any other way.

      If it is not the case, then you have to add reference to the ComponentOne dlls in the AppDomain.

    Thanks,

    Ruchir Agarwal

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels