Click here to Skip to main content
15,909,741 members
Home / Discussions / C#
   

C#

 
GeneralRe: .NET Decompiler ?? !! Pin
Dan Suthar5-Oct-07 19:50
professionalDan Suthar5-Oct-07 19:50 
GeneralRe: .NET Decompiler ?? !! Pin
lmoelleb6-Oct-07 1:17
lmoelleb6-Oct-07 1:17 
GeneralRe: .NET Decompiler ?? !! Pin
Dan Suthar6-Oct-07 2:22
professionalDan Suthar6-Oct-07 2:22 
GeneralRe: .NET Decompiler ?? !! Pin
lmoelleb6-Oct-07 3:18
lmoelleb6-Oct-07 3:18 
GeneralRe: .NET Decompiler ?? !! Pin
Nathan Holt at EMOM8-Oct-07 9:38
Nathan Holt at EMOM8-Oct-07 9:38 
AnswerRe: .NET Decompiler ?? !! Pin
Dan Suthar8-Oct-07 21:37
professionalDan Suthar8-Oct-07 21:37 
QuestionAssembly/DLL Hierarchy Deployed Behind a Web Service Problem Pin
Alex Webber5-Oct-07 6:02
Alex Webber5-Oct-07 6:02 
Questionpowershell scripts Pin
winsane5-Oct-07 6:02
winsane5-Oct-07 6:02 
Hello,
I am trying to cobble together some C# code to make my powershell scripts launch from buttons on a menu. I seem to be running into about 6 or 8 syntax errors. I don't know C#
very well yet, so I have a hard time finding these kinds of issues. Here is my code, if someone would be so kind to look it over...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management.Automation;
using System.Collections.ObjectModel;
using System.Management.Automation.Runspaces;

/// Class that assists in asynchronously executing and retrieving the results of a powershell script pipeline.

public class PipelineExecutor
{
/// Gets the powershell Pipeline associated with this PipelineExecutor
public Pipeline Pipeline
{
get;
}

public delegate void DataReadyDelegate(PipelineExecutor sender, ICollection data);
public delegate void DataEndDelegate(PipelineExecutor sender);

/// Occurs when there is new data available from the powershell script.
public event DataReadyDelegate OnDataReady;

/// Occurs when powershell script completed its execution.
public event DataEndDelegate OnDataEnd;

/// Constructor, creates a new PipelineExecutor for the given powershell script.
public PipelineExecutor(Runspace runSpace, ISynchronizeInvoke invoker, string command);

/// Start executing the script in the background.
public void Start();

/// Stop executing the script.
public void Stop();
}

namespace ScriptLauncher
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button3_Click(object sender, EventArgs e)
{
private string RunScript(string scriptText)
{
// create Powershell runspace
Runspace runspace = RunspaceFactory.CreateRunspace();

// open it
runspace.Open();

// create a pipeline and feed it the script text
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(scriptText);

// add an extra command to transform the script output objects into nicely formatted strings
// remove this line to get the actual objects that the script returns. For example, the script
// "Get-Process" returns a collection of System.Diagnostics.Process instances.
pipeline.Commands.Add("Out-String");

// execute the script
Collection results = pipeline.Invoke();

// close the runspace
runspace.Close();

// convert the script result into a single string
StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.ToString());
}

return stringBuilder.ToString();
}
MessageBox.Show(

private void button4_Click(object sender, EventArgs e)
{
"I'm so happy", "Whoopee!!!");
}
}
}
}
QuestionProblem with columns in DataGridView Pin
Knoen5-Oct-07 5:07
Knoen5-Oct-07 5:07 
AnswerRe: Problem with columns in DataGridView Pin
led mike5-Oct-07 5:45
led mike5-Oct-07 5:45 
GeneralRe: Problem with columns in DataGridView Pin
Knoen5-Oct-07 5:47
Knoen5-Oct-07 5:47 
GeneralRe: Problem with columns in DataGridView Pin
led mike5-Oct-07 6:15
led mike5-Oct-07 6:15 
GeneralRe: Problem with columns in DataGridView Pin
Knoen5-Oct-07 6:24
Knoen5-Oct-07 6:24 
Questiontextbox check Pin
NewToAspDotNet5-Oct-07 4:29
NewToAspDotNet5-Oct-07 4:29 
AnswerRe: textbox check Pin
Matthew Cuba5-Oct-07 4:47
Matthew Cuba5-Oct-07 4:47 
AnswerRe: textbox check Pin
PIEBALDconsult5-Oct-07 4:53
mvePIEBALDconsult5-Oct-07 4:53 
AnswerRe: textbox check Pin
Peter Vertes5-Oct-07 5:04
Peter Vertes5-Oct-07 5:04 
AnswerRe: textbox check Pin
Ajay.k_Singh5-Oct-07 5:21
Ajay.k_Singh5-Oct-07 5:21 
Question"Anti-Grain Geometry" question Pin
Richard Blythe5-Oct-07 4:18
Richard Blythe5-Oct-07 4:18 
AnswerRe: "Anti-Grain Geometry" question Pin
Dave Kreskowiak5-Oct-07 8:30
mveDave Kreskowiak5-Oct-07 8:30 
QuestionHow do i.... Pin
MMaines20055-Oct-07 4:07
MMaines20055-Oct-07 4:07 
AnswerRe: How do i.... Pin
leckey5-Oct-07 4:15
leckey5-Oct-07 4:15 
AnswerRe: How do i.... Pin
Matthew Cuba5-Oct-07 4:26
Matthew Cuba5-Oct-07 4:26 
AnswerRe: How do i.... Pin
martin_hughes5-Oct-07 4:51
martin_hughes5-Oct-07 4:51 
Questiondateandtime issue Pin
NewToAspDotNet5-Oct-07 4:05
NewToAspDotNet5-Oct-07 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.