修复了无法加载类库所依赖的类库

This commit is contained in:
fengjiayi
2025-09-08 13:53:56 +08:00
parent 51c268baad
commit 0161c64e2c
2 changed files with 13 additions and 7 deletions

View File

@@ -28,17 +28,24 @@ namespace Serein.NodeFlow.Tool
protected override Assembly? Load(AssemblyName assemblyName)
{
string? assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName); // 加载程序集
if (!string.IsNullOrEmpty(assemblyPath))
if (!string.IsNullOrEmpty(assemblyPath) && File.Exists(assemblyPath))
{
var assembly = Default.LoadFromAssemblyPath(assemblyPath); // 通过默认方式进行加载程序集及相关依赖
//var assembly = LoadFromAssemblyPath(assemblyPath);
return assembly;
try
{
var assembly = Default.LoadFromAssemblyPath(assemblyPath); // 通过默认方式进行加载程序集及相关依赖
return assembly;
}
catch (Exception ex)
{
var assembly = LoadFromAssemblyPath(assemblyPath);
return assembly;
}
}
else
{
return Default.Assemblies.FirstOrDefault(x => x.FullName == assemblyName.FullName);
var assembly = Default.Assemblies.FirstOrDefault(x => x.FullName == assemblyName.FullName);
return assembly;
}
// return null;
// 构建依赖项的路径

View File

@@ -69,7 +69,6 @@
<ProjectReference Include="..\Library\Serein.Library.csproj" />
<ProjectReference Include="..\NodeFlow\Serein.NodeFlow.csproj" />
<ProjectReference Include="..\Serein.Extend.NewtonsoftJson\Serein.Extend.NewtonsoftJson.csproj" />
<ProjectReference Include="..\Serein.Proto.Modbus\Serein.Proto.Modbus.csproj" />
<ProjectReference Include="..\Serein.Script\Serein.Script.csproj" />
</ItemGroup>