I've tried #1, and I have only seen it trigger once or twice... and IIRC, it was during library error case not when there was a read/write error by the library itself. It's not something I've spent a lot of time chasing, but I see the need too. The generic HDF5DotNet exceptions are only so helpful.
Anyway, here's the code:
protected override void OnStart(string args)
mProcessStartInfo = new ProcessStartInfo(DPM_APP_FILE_NAME);
mProcess = new Process();
mProcess.StartInfo = mProcessStartInfo;
// Set StdError (HDF error messages) to go to the Debug/Output Window
mProcess.StartInfo.UseShellExecute = false;
mProcess.StartInfo.RedirectStandardError = true;
mProcess.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(p_ErrorDataReceived);
catch (Exception ex)
// Note: this currently doesn't work for an unknown reason.
// BeginErrorReadLine throws an InvalidOperationException "StandardError has not been redirected"
System.Diagnostics.Debug.WriteLine(ex.GetType().ToString() + ": " + ex.Message);
DPM_EventLog.WriteEntry("Redirect StdErr " + ex.GetType().ToString() + ": " + ex.Message+". "+ex.StackTrace);
catch (Exception ex)
static void p_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
System.Diagnostics.Debug.Write(e.Data + Environment.NewLine);
From: Hdf-forum [mailto:firstname.lastname@example.org] On Behalf Of Rowe, Jim
Sent: Monday, December 01, 2014 7:23 PM
To: HDF Users Discussion List
Subject: [Hdf-forum] meaningful errors in hdf5dotnet?
Hello All, we have found the lack of meaningful exception handling in hdf5dotnet to be frustrating at best.
Short of the wrapper implementation improving, how can we get HDF5 error information? Two approaches seem possible, but we can't get either to work:
1) Capturing stdout/err, but that doesn't seem to propagate in the dll and it isn't clear how to get it.
2) Using the H5E.setAuto method, but it isn't clear how to get the callback and clientdata pointers to work through the api.
Examples or suggestions would be greatly appreciated.
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of Exelis Inc. The recipient should check this e-mail and any attachments for the presence of viruses. Exelis Inc. accepts no liability for any damage caused by any virus transmitted by this e-mail.