How to Avoid a System.Runtime.Interopservices.Comexception

How to avoid a System.Runtime.InteropServices.COMException?

Your code (or some code called by you) is making a call to a COM method which is returning an unknown value. If you can find that then you're half way there.

You could try breaking when the exception is thrown. Go to Debug > Exceptions... and use the Find... option to locate System.Runtime.InteropServices.COMException. Tick the option to break when it's thrown and then debug your application.

Hopefully it will break somewhere meaningful and you'll be able to trace back and find the source of the error.

How to correct this error of 'System.Runtime.InteropServices.COMException'?

I tried adding this :

System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

and it worked, it seems like the problem was due to a language conflict.

System.Runtime.InteropServices.COMException: The device is not ready

For me it looks like that your device (logical drive) D: is not ready.

            var driveInfo = new DriveInfo("D"); // or "D:\"

if (driveInfo.IsReady)
{
// do your stuff..
}
else
{
// loggin, show to the user or throw an exception..
}

System.Runtime.InteropServices.COMException when trying to drag and drop between two WPF applications

You should decorate the FakeNodeViewModel class with the System.SerializableAttribute for it be COM serializable:

[Serializable]
public class FakeNodeViewModel
{
...
}


Related Topics



Leave a reply



Submit