Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 C# 世界的新手。我有一个用 C++ 编写的 COM 服务器,在某些情况下它返回一个 variant_t::missing()。当我尝试在 C# 中接收该值时:
object a; a = comServer.Value // Value returns missing
它引发了一个我无法在 C# 中进行事件处理的异常。
我该怎么办?
将其包装在 try/catch 中:
try { object a = comServer.Value; } catch (Exception ex) { // handle the error }