SOLIDWORKS-PDM-API-SDK icon indicating copy to clipboard operation
SOLIDWORKS-PDM-API-SDK copied to clipboard

Fix assembly resolve issue

Open AmenJlili opened this issue 1 year ago • 0 comments
trafficstars

We're using the following resolver now and making it virtual.

        {
            var Assembly = default(Assembly);
            var thisAssembly = new FileInfo(this.GetType().Assembly.Location);
            var directory = thisAssembly.Directory;




            var nameWithoutExtension = args.Name.Split(',').First();


            Console.WriteLine($"{FileVersionInfo.GetVersionInfo(thisAssembly.FullName).ProductName} - Failed to load {args.Name}");

            var files = directory.GetFiles("*", SearchOption.TopDirectoryOnly);

            if (files != null)
            {
                var dlls = files.ToList().Where(x => x.Extension.ToLower().Contains("interop") == false && x.Extension.ToLower().EndsWith("dll"));
                if (dlls != null)
                {
                    foreach (var dll in dlls)
                    {
                        if (args.Name.ToLower().StartsWith(nameWithoutExtension.ToLower()))
                        {
                            Assembly = System.Reflection.Assembly.Load(AssemblyName.GetAssemblyName(dll.FullName));
                            break;
                        }
                    }
                }

            }


            return Assembly;

        }



AmenJlili avatar Mar 21 '24 07:03 AmenJlili