小编Syl*_*ois的帖子

从.Net Core运行Powershell-无法加载文件或程序集Microsoft.Management.Infrastructure

我一直在尝试使用以下代码从.Net Core Web应用程序运行Powershell脚本(此处不讨论最佳实践;))。

    string command = @"& """c:\\my Folder\\myScript.ps1""";

    using (var ps = PowerShell.Create())
    {
        var results = ps.AddScript(command).Invoke();
    }
Run Code Online (Sandbox Code Playgroud)

它在我的开发机上运行良好,但是在生产中尝试执行此功能时失败:

ps.AddScript(command).Invoke()
Run Code Online (Sandbox Code Playgroud)

我得到以下异常:

System.IO.FileNotFoundException:无法加载文件或程序集'Microsoft.Management.Infrastructure,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'。该系统找不到指定的文件。文件名:System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly程序集,ObjectHandleOnStack retTypes)在System.Reflection.RuntimeAssembly.GetExportedTypes()处的Microsoft.Management.Infrastructure,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35 System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzeModuleAssemblyWithReflection(Assembly assembly,String name,PSSnapInInfo psSnapInInfo,PSModuleInfo moduleInfo,Boolean is.System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzeModuleAssemblyWithReflection(Assembly assembly,String name)的System.Management.Automation.Runspaces.PSSnapInHelpers.GetAssemblyTypes(组装程序集,字符串名称)2& cmdlets, Dictionary2&别名,System 2.System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo,PSSnapInException&warning)的System.Management.Automation.Runspaces.InitialSessionState.CreateDefault()处的别名2& providers, String helpFile, Type& randomCmdletToCheckLinkDemand, Type& randomProviderToCheckLinkDemand) at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzePSSnapInAssembly(Assembly assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, Boolean isModuleLoad, Dictionary2,cmdlet,字典2& aliases, Dictionary2&提供程序,String&helpFile)。系统。管理.Automation.PowerShell.CoreInvokeHelper [TInput,TOutput](PSDataCollection1 input, PSDataCollection …

c# powershell .net-core asp.net-core

10
推荐指数
1
解决办法
1214
查看次数

从 google.cloud 导入 bigquery ModuleNotFoundError:没有名为“google”的模块

遵循基本的 Google 云运行教程 ( https://cloud.google.com/run/docs/quickstarts/build-and-deploy ) 后,

我一直在尝试部署到更复杂的东西,但没有成功。

我的 app.py 从这些导入开始:

import os
import uuid
import requests
import json
from google.cloud import bigquery
from flask import Flask
Run Code Online (Sandbox Code Playgroud)

但是当我尝试运行它时,我收到以下日志:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 
    worker.init_process()
  File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process 
    super(ThreadWorker, self).init_process() 
  File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi() 
  File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 
    self.callable = self.load()
  File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load 
    return …
Run Code Online (Sandbox Code Playgroud)

python google-bigquery dockerfile

2
推荐指数
1
解决办法
8917
查看次数