【问题标题】:how to load sharepoint.client assembly during run time in c#如何在 C# 运行时加载 sharepoint.client 程序集
【发布时间】:2021-05-18 12:40:48
【问题描述】:

嗨,我一直在尝试在运行时加载共享点程序集,但我总是收到错误消息 “抛出异常:mscorlib.dll 中的‘System.Reflection.ReflectionTypeLoadException’ "

这是我的代码 sn-p

Assembly assembly = Assembly.LoadFile(extension);
Type type = assembly.GetType("Microsoft.SharePoint.Client.File");
var obj = Activator.CreateInstance(type);

另外,如果我想知道所有的方法名称,我会怎么做?

请帮忙!!!

【问题讨论】:

  • 您是否检查并验证了所需的程序集已安装在运行此代码的机器上?
  • 我的目标是在运行时将库安装在 ssis 脚本任务中。我正在运行这段代码来测试它。我的 dll 文件位于我的本地文件存储中,我正在加载 assmbly.load()

标签: c# .net sharepoint .net-assembly


【解决方案1】:

您可以使用 Assembly.GetExportedTypes() 获取确切包含的类型。

使用 Type.GetMethods() 可以获取一个类型的所有方法。

【讨论】:

  • 我收到此错误异常:mscorlib.dll 中的“System.IO.FileNotFoundException”在 mscorlib.dll 中发生“System.IO.FileNotFoundException”类型的未处理异常无法加载文件或程序集'Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' 或其依赖项之一。系统找不到指定的文件。
  • 当我使用 nuget cli 将 NUPCKG 格式转换为 dll 时,我得到了 sharepoint.client 的多个 dll 文件,在这种情况下,我可能只加载“Microsoft.SharePoint.Client.dll “它在其他文件夹中的依赖关系正在停止运行它?只是一个想法
猜你喜欢
  • 1970-01-01
  • 2012-08-02
  • 2020-06-16
  • 2011-09-09
  • 1970-01-01
  • 1970-01-01
  • 2012-02-07
  • 2018-04-24
相关资源
最近更新 更多