开发者

How to handle Variant Missing

开发者 https://www.devze.com 2023-01-11 23:17 出处:网络
I\'m new in C# world. I have a COM server written in C++ and in some situation it returns a variant_t::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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消