Unsolved
This post is more than 5 years old
2 Posts
0
1061
January 13th, 2012 09:00
Error between .net and powershell module
Hello all,
I'm trying to develop an integration between .Net and vWorkspace Powershell module,
At the moment it is just a powershell runspace, invoking quest cmdlets, but I unfortunatelly have error at simple examples.
I am trying to execute the following code:
using System;
using System.Text;
using System.Management.Automation.Runspaces;
using System.Collections.ObjectModel;
using System.Management.Automation;
using Quest.vWorkspace.IBusinessLayer;
namespace WcfService3
{
public class Service1 : IService1
{
public string GetData(int value)
{
// create Powershell runspace
Runspace runspace = RunspaceFactory.CreateRunspace();
// open it
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript("Import-Module Quest.vWorkspace.PowerShellModule");
pipeline.Commands.AddScript("Connect-QVWFarm -Farm \"vWorkspace DataBase\";");
// pipeline.Commands.Add("Out-String");
Collection results = new Collection (pipeline.Invoke());
runspace.Close();
StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.GetType().ToString());
}
return stringBuilder.ToString();
}
}
}
but unfortunatelly I ever have the error
Failed to locate exported type [Quest.vWorkspace.IBusinessLayer.IFarm]. See log for more information.
Has someone tried to do something similar?
Thanks in advance.