C
C#•10mo ago
xirus 𖣂

Error

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=WinFormsApp3 StackTrace: at WinFormsApp3.Form1.button2_Click(Object sender, EventArgs e) in C:\Users\actex\source\repos\WinFormsApp3\Form1.cs:line 248 at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam) at Windows.Win32.PInvoke.DispatchMessage(MSG* lpMsg) at System.Windows.Forms.Application.ComponentManager.Microsoft.Office.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context) at WinFormsApp3.Program.Main() in C:\Users\actex\source\repos\WinFormsApp3\Program.cs:line 14
No description
14 Replies
Jimmacle
Jimmacle•10mo ago
yes, that is an error
Anu6is
Anu6is•10mo ago
find what's null once u know what's null you can work out a solution
i like chatgpt
i like chatgpt•10mo ago
Do you have a microphone installed? @xirus
xirus 𖣂
xirus 𖣂OP•10mo ago
yes but i havent intewgrated mic streams only a wav file
i like chatgpt
i like chatgpt•10mo ago
Try troubleshooting with voiceClient.Microphone?.CopyFrom(...); first.
Anu6is
Anu6is•10mo ago
Why guess, you have the ability to inspect the objects and find what's null
xirus 𖣂
xirus 𖣂OP•10mo ago
i did idk i set the path right there should be no problem
Anu6is
Anu6is•10mo ago
so what's null?
xirus 𖣂
xirus 𖣂OP•10mo ago
llok
private void button2_Click(object sender, EventArgs e)
{
CancellationTokenSource source = new CancellationTokenSource();
string music = "C:/Users/actex/Downloads/untitled.wav";
ulong channelId = 1162394653845377129; // Replace with the actual channel ID
voiceClient = new DiscordVoiceClient(client, 1162394653312696400);

OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Audio files (*.ogg;*.mp3;*.wav)|*.ogg;*.mp3;*.wav|All files (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;


voiceClient.Connect(channelId, new VoiceConnectionProperties() { Muted = true });
{
try
{
while (voiceClient.State == MediaConnectionState.Ready && !source.IsCancellationRequested)
voiceClient.Microphone.Bitrate = 510000;
voiceClient.Microphone.SetSpeakingState(DiscordSpeakingFlags.Soundshare);
voiceClient.Microphone.CopyFrom(DiscordVoiceUtils.GetAudioStream(music), source.Token);
}
catch (InvalidOperationException ex) {
MessageBox.Show($"An error occurred: {ex.Message}");
}
}
}
private void button2_Click(object sender, EventArgs e)
{
CancellationTokenSource source = new CancellationTokenSource();
string music = "C:/Users/actex/Downloads/untitled.wav";
ulong channelId = 1162394653845377129; // Replace with the actual channel ID
voiceClient = new DiscordVoiceClient(client, 1162394653312696400);

OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Audio files (*.ogg;*.mp3;*.wav)|*.ogg;*.mp3;*.wav|All files (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;


voiceClient.Connect(channelId, new VoiceConnectionProperties() { Muted = true });
{
try
{
while (voiceClient.State == MediaConnectionState.Ready && !source.IsCancellationRequested)
voiceClient.Microphone.Bitrate = 510000;
voiceClient.Microphone.SetSpeakingState(DiscordSpeakingFlags.Soundshare);
voiceClient.Microphone.CopyFrom(DiscordVoiceUtils.GetAudioStream(music), source.Token);
}
catch (InvalidOperationException ex) {
MessageBox.Show($"An error occurred: {ex.Message}");
}
}
}
Anu6is
Anu6is•10mo ago
First look at the debugger - Visual Studio (Windows)
Get started debugging your applications by using the Visual Studio debugger and see what your code is doing while it runs.
Anu6is
Anu6is•10mo ago
Think this would be useful for you
xirus 𖣂
xirus 𖣂OP•10mo ago
i figured out when i connect i get disconnected like the voice call call media state since i did if '... state = Ready then i can transmit audio so the problem is the media state connection
xirus 𖣂
xirus 𖣂OP•10mo ago
No description
xirus 𖣂
xirus 𖣂OP•10mo ago
any possible fixes? dw i alr put the await before the task run
Want results from more Discord servers?
Add your server