在VB中的powershell新网站无法正常工作

编程入门 行业动态 更新时间:2024-10-20 03:39:50
本文介绍了在VB中的powershell新网站无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在尝试使用powershell命令"New-Website Testsite"创建一个新网站。 命令工作原理在Powershell中很好,但不会返回任何内容或使用VB中的Web服务创建网站。甚至尝试使用更多参数。

I've been trying to create a new website using the powershell command "New-Website Testsite" Command works fine in Powershell but does not return anythingor creates the siteusing a webservice in VB. Even tried with more parameters.

VB中简单代码的一部分:

A part of the simple code in VB:

<%@ WebService Language =" VB"类= QUOT; NAVservice" %> 选项严格关闭

<%@ WebService Language="VB" Class="NAVservice" %> Option Strict Off

Imports System.Web.Services Imports System.Collections.ObjectModel Imports System.Management.Automation Imports System.Management.Automation.Runspaces

Imports System.Web.Services Imports System.Collections.ObjectModel Imports System.Management.Automation Imports System.Management.Automation.Runspaces

< System.Web.Services.WebService(Namespace:=" ;删除")> _ $ 公共舱NAV服务 继承WebService

<System.Web.Services.WebService(Namespace:="Removed")> _ Public Class NAVservice Inherits WebService

<的WebMethod()> _ $ Public Sub NAVdeployment() Dim runspace As Runspace = RunspaceFactory.CreateRunspace() 尝试 runspace.Open() Dim pipeline As Pipeline = runspace.CreatePipeline() pipeline.Commands.AddScript(" Import-Module WebAdministration") pipeline.Commands.AddScript(" New-Website NiSo") pipeline.Invoke() 最后为 runspace.Close() 结束尝试 结束点 结束类

<WebMethod()> _ Public Sub NAVdeployment() Dim runspace As Runspace = RunspaceFactory.CreateRunspace() Try runspace.Open() Dim pipeline As Pipeline = runspace.CreatePipeline() pipeline.Commands.AddScript("Import-Module WebAdministration") pipeline.Commands.AddScript("New-Website NiSo") pipeline.Invoke() Finally runspace.Close() End Try End Sub End Class

使用具有不同Powershell命令的相同Web服务可以正常工作。 有人能指出我正确的方向吗?我没有想法。

Using the same Webservice with different Powershell commands works fine though. Could somebody point me in the right directions? I'm out of ideas.

谢谢! Nick

Thanks! Nick

推荐答案

尼克,

你有这么严格宣布选项严格关闭的任何理由。

Any reason you have so strict declared Option Strict Off.

选项Strict Off是所有迟到的主要原因绑定错误,所以首先尝试解决。

Option Strict Off is a main reason for all kind of late binding errors so try to solve that first.

更多推荐

在VB中的powershell新网站无法正常工作

本文发布于:2023-11-01 12:46:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549370.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   工作   网站   VB   powershell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!