Using resources of dll is very very terrible!!!

Using resources of dll is very very terrible!!!

Anonymous
Not applicable
374 Views
1 Reply
Message 1 of 2

Using resources of dll is very very terrible!!!

Anonymous
Not applicable

My plugin 'GridSetting.dll' reference 'Core.dll'.

 

Step 1: Running this(AddInManager) tell me FileNotFoundException 'Core.resources'.

Solution: I add 'Resources.zh-CN.resx' and don't show this message. But, it's the beginning.

--------

Step 2: Running my plugin 'GridSetting.dll' tell me FileNotFoundException 'GridSetting.resources' again.

Discussing: I guess you say 'Adds Resources.zh-CN.resx'. I think so. But, it's a invalid. Why???

Solution: I create a class that store all constants.

 

You'd better save the characters with a constant, unless you know the reason.

 

0 Likes
Accepted solutions (1)
375 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

protected override Assembly ResolveAssemblies(object sender, ResolveEventArgs args)
{
var assembly = args.RequestingAssembly;
var currentDir = typeof(GridSettingCmd).GetDirectoryPath();
var currentDirInfo = new DirectoryInfo(currentDir);

if (assembly is null)
{
var targetAssemblyName = args.Name.Split(',').First();
var targetFiles = currentDirInfo.GetFiles($"{targetAssemblyName}.*", SearchOption.AllDirectories);

foreach (var targetFile in targetFiles)
assembly = Assembly.LoadFrom(targetFile.FullName);
}

return assembly;
}