Seventy
❔ Getting $StandardIn has not been redirected.$ Error...
public class CmdExecutor
{
private Process process;
public CmdExecutor()
{
InitializeProcess();
}
private void InitializeProcess()
{
process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
CreateNoWindow = true
};
process.StartInfo = startInfo;
process.OutputDataReceived += Process_OutputDataReceived;
process.Start();
process.BeginOutputReadLine();
}
public string ExecuteCommand(string command)
{
try
{
process.StandardInput.WriteLine(command);
process.StandardInput.Flush();
return "";
}
catch (Exception ex)
{
Console.WriteLine("Error executing command: " + ex.Message);
return "";
}
}
private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine(e.Data);
}
public void CloseProcess()
{
if(process != null)
{
process.Close();
process.Dispose();
}
}
}
public class CmdExecutor
{
private Process process;
public CmdExecutor()
{
InitializeProcess();
}
private void InitializeProcess()
{
process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
CreateNoWindow = true
};
process.StartInfo = startInfo;
process.OutputDataReceived += Process_OutputDataReceived;
process.Start();
process.BeginOutputReadLine();
}
public string ExecuteCommand(string command)
{
try
{
process.StandardInput.WriteLine(command);
process.StandardInput.Flush();
return "";
}
catch (Exception ex)
{
Console.WriteLine("Error executing command: " + ex.Message);
return "";
}
}
private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine(e.Data);
}
public void CloseProcess()
{
if(process != null)
{
process.Close();
process.Dispose();
}
}
}
13 replies
❔ System.typeloadexception could not find method due to type load error
Code I am using:
Any ideas why i am getting that error? (feel like i am doing something wrong and its really dumb 💀 )
async void GamerMethod()
{
//Doing gamer things...
await GamerSpace.Grabber.Should_Send_Hello_World_Message();
}
public static async Task Should_Send_Hello_World_Message()
{
var message = new DiscordMessage("Hello World!");
var client = new DiscordWebhookClient("//my super cool url");
await client.SendToDiscord(message);
Assert.IsTrue(true);
}
async void GamerMethod()
{
//Doing gamer things...
await GamerSpace.Grabber.Should_Send_Hello_World_Message();
}
public static async Task Should_Send_Hello_World_Message()
{
var message = new DiscordMessage("Hello World!");
var client = new DiscordWebhookClient("//my super cool url");
await client.SendToDiscord(message);
Assert.IsTrue(true);
}
26 replies
Get list of all Classes using Interface.
Is there a way i can get a list of all the classes using this interface?
Here is a class using it:
Also is there a way i can create a instance of every class using IConsoleCommand?
public interface IConsoleCommand
{
string CommandWord { get;
}
bool Process (string[] args);
}
public interface IConsoleCommand
{
string CommandWord { get;
}
bool Process (string[] args);
}
public class ExampleCommand : IConsoleCommand
{
public string CommandWord { get; } = "example";
public bool Process(string[] args)
{
//Run fancy code here!
//Make sure if the execution of your command was successfull => return true;
//else => return false;
//kind of like this:
if(args.Length == 0 || args == null)
{
MaumConsole.instance.Error("Missing Argument(s)", CommandWord);
return false; // This is optional. Just checking if user entered arguments!
}
if (args[0].Equals("pls", StringComparison.OrdinalIgnoreCase))
{
// yay the entered command was "[prefix][CommandWord] pls" and now i will help by sending some cool data > Debug.log();
MaumConsole.instance.Log("Yay you ran the example command!",CommandWord);
return true;
}
else
{
//oh no
MaumConsole.instance.Error("Wrong Argument(s)",CommandWord);
return false;
}
}
}
public class ExampleCommand : IConsoleCommand
{
public string CommandWord { get; } = "example";
public bool Process(string[] args)
{
//Run fancy code here!
//Make sure if the execution of your command was successfull => return true;
//else => return false;
//kind of like this:
if(args.Length == 0 || args == null)
{
MaumConsole.instance.Error("Missing Argument(s)", CommandWord);
return false; // This is optional. Just checking if user entered arguments!
}
if (args[0].Equals("pls", StringComparison.OrdinalIgnoreCase))
{
// yay the entered command was "[prefix][CommandWord] pls" and now i will help by sending some cool data > Debug.log();
MaumConsole.instance.Log("Yay you ran the example command!",CommandWord);
return true;
}
else
{
//oh no
MaumConsole.instance.Error("Wrong Argument(s)",CommandWord);
return false;
}
}
}
10 replies
Extracting string from string?
I have a string that looks kinda like this:
And i need to get only the "thisthing" part how would i do that?
string superCoolString = ""something.something.thisthing","something.something.thisthing","something.something.thisthing" etc..."
string superCoolString = ""something.something.thisthing","something.something.thisthing","something.something.thisthing" etc..."
7 replies