Skip to content

报Not Support Platform的异常 #61

@JosonJiang

Description

@JosonJiang

调试跟踪进来 Activator.CreateInstance(type) as TaskBase; 这里报错 如果使用 catch 注释 部分则没有问题

` public static TaskBase CreateTaskInstance(PluginLoadContext context, Guid sid, string assemblyName, string className)
{
string pluginLocation = GetTaskAssemblyPath(sid, assemblyName);

        try
        {
            assemblyName = Path.GetFileNameWithoutExtension(pluginLocation);
            var assembly = context.LoadFromAssemblyName(new AssemblyName(assemblyName));
            Type type = assembly.GetType(className, true, true);
            return Activator.CreateInstance(type) as TaskBase;
        }
        catch (Exception ex)
        {

            
            //Assembly assembly = Assembly.LoadFrom(pluginLocation);//要调用的dll文件路径
            //Type type = assembly.GetType(className, true, true);
            //return Activator.CreateInstance(type) as TaskBase;

            throw new Exception($"{ex.Message}|{ex.InnerException.Message}", ex.InnerException);

        }

    }`

参考一文章介绍

主项目中的nuget包不适合当前平台,则会报Not Support Platform的异常.这时如果主项目是在windows上, 就需要把项目发布目标设置为win-x64.这属于nuget包依赖关系存在错误描述.

这个具体要如果解决?

是 使用SqlSugarCore 报错为 System.Data.SqlClient Not Support Platform

我把打包上传的的DLL 放到另一个项目直接

                Assembly assembly = Assembly.LoadFrom(pluginLocation);//要调用的dll文件路径
                Type type = assembly.GetType(className, true, true);
                return Activator.CreateInstance(type) as TaskBase;

也会提示这样错误,但如果项目中添加 SqlSugarCore 就没这个错误了(打包的DLL 中也有这些依赖)!
但同理在 Hos.ScheduleMaster.Web 添加 SqlSugarCore却还是这提示错误

不知如何解决了

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions