【问题标题】:Import-Module for custom dll fails自定义 dll 的导入模块失败
【发布时间】:2013-02-07 09:38:02
【问题描述】:

我按照演示 here 创建了一个自定义的 powershell cmdlet。当我尝试导入模块时,出现以下错误:

C:\PS> Import-Module DemoPS.dll
Import-Module : The specified module 'DemoPS.dll' was not loaded because no valid module file was found in any module directory.

如果需要更多信息,请告诉我。

【问题讨论】:

    标签: c# powershell


    【解决方案1】:

    显示错误是因为它找不到您的 dll 文件。您需要为您的模块 DLL 文件指定完整路径(例如 Import-Module c:\users\mj\desktop\DemoPS.dll)。

    作为替代解决方案,您可以将其保存在“模块”文件夹中。这是一个名为“Modules”的文件夹,您必须在配置文件目录中创建它。您可以使用$profile 找到您的个人资料目录。它通常位于C:\Users\<username>\Documents\WindowsPowerShell\。因此,要使用它,请将您的 dll 放在以下路径中:

    C:\Users\<username>\Documents\WindowsPowerShell\Modules\DemoPS\DemoPS.dll
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2022-06-21
      • 2019-04-28
      • 1970-01-01
      • 2022-12-10
      相关资源
      最近更新 更多