I have a Windows Service that hangs when opening an OLEDB-connection to an Excel-file, like this:
using (var connection = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ fileName + ";Extended Properties=\"Excel 8.0\""))
{
connection.Open();
// start using the connection
}
This code works fine when running as a console application. When I debug the Windows Service with Visual Studio, I can step into the code until I hit the call to connection.Open(). At that point, the thread hangs. No exception is thrown. Visual Studio remains responsive, until I hit the "Break All" or "Stop Debugging" button. At that point, Visual Studio also hangs. When I kill the process, Visual Studio becomes responsive again.
Does anyone know why this happens and how to solve it?
EDIT: fileName is an absolute path; the file was written by the service itself.