Arduino Micro serial communication with C#

Hello,
in my thesis project I'm using an ATMega32u4 as an Arduino Micro. I have programmed it with the bootloader and I can upload sketches via USB. When I try to establish a serial connection, the Serial Monitor of the IDE perfectly shows all the data I've send. This is the sketch I use:

void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
    Serial.println("123456789");
  // I also tried it using
    delay(10);
}

Very simple, for testing. The monitor shows:
123456789
123456789
et cetera.

When I try to read this data with a C# program with the following code:

serialPort1 = new System.IO.Ports.SerialPort();
                    serialPort1.PortName = "COM4"; //Com Port Name                
                    serialPort1.BaudRate = 9600; //COM Port Speed
                    serialPort1.WriteTimeout = 1000;
                    serialPort1.ReadTimeout = 5000;

                    if (!serialPort1.IsOpen)
                    {
                        try
                        {

                            serialPort1.Open();
                            string read = serialPort1.ReadExisting(); 
                            read = serialPort1.ReadLine();
                            serialPort1.Close();
                            System.Threading.Thread.Sleep(100);
                            //some methode to give out "read"
                        }
                        catch
                        {
                            MessageBox.Show("There was an error. Please make sure that the correct port was selected, and the device, plugged in.");
                        }
                    }

I get a ReadTimeout (I know that because it always takes the amount of time that I set in ReadTimeout). The Arduino Micro is at port COM4. Windows Device Manager shows it as connected.

If I try the same sketch with my Arduino Uno (different port, of course), it works, the C# program puts out: 123456789. The ports are identical in their baud rate, parity, etc.

What can I try to make this work or to figure out the problem?
Thank you for your help!

You may need to set DTR and RTS in your C# program when it opens the serial port.

...R

Opening the serial port resets the Arduino. Do that ONCE in your C# code, NOT every time you want to collect data from it.

You can, and should, use the fact that serial data arrives asynchronously, to trigger a callback on another thread, to handle the serial data.

@Robin2: Tank you very much, it worked!

@PaulS: I guess I should do that, but it is not a big problem, so I won't :wink: Maybe later... Thanks, though!