How to handle Variant Missing
I'm new in C# world. I have a COM server written in C++ and in some situation it returns a variant_t::missing(). When I try to receive that value in C开发者_开发知识库#:
object a;
a = comServer.Value // Value returns missing
it throws a exception that I cannot event handle in C#.
How I should do?
Wrap it in a try / catch:
try
{
object a = comServer.Value;
}
catch (Exception ex)
{
// handle the error
}
精彩评论