I have attached the zip files for the sender side and the receiver side. I am running these projects in Visual Studio (Visual C#). The purpose is to send an audio file from the sender to a receiver.
It is giving me some error when I run the project. The error message is also attached. Please let me know how to fix this error.
You allocate client and netstream inside a try...catch block, but then close them inside the finally {} block. So you are not guaranteed these attributes are not null in case of error. Do instead:
finally
{
if (netstream)
netstream.Close();
if (client)
client.Close();
}
Here is another scenario I am having now. I have started the receiver on one machine and then started the sender.
The port number I used is 29250.
When I select a file and send it to the receiver, a dialog box at the receiver pops up asking me to accept the incoming file.
When I click Yes to accept the incoming file, the receiver side shows the following error:
A first chance exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.