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
Reading Fromuri and Frombody at the Same Time
Httpwebrequest Times Out on Second Call
Combine Two Linq Lambda Expressions
Improving/Fixing a Regex for C Style Block Comments
How to Use Dependency Injection in a .Net Core Actionfilterattribute
Using System.Io.Packaging to Generate a Zip File
Get Powershell Command's Output When Invoked Through Code
The 'Await' Operator Can Only Be Used Within an Async Lambda Expression
Convert.Toint32() a String with Commas
Regular Expression to Get the Src of Images in C#
Outofmemoryexception on Declaration of Large Array