简体   繁体   English

C#运行时异常

[英]C# Runtime Exception

I am working on C# program to get the users from A component called Cyber-Ark which stores encrypted data. 我正在开发C#程序,以便从存储加密数据的名为Cyber​​-Ark的组件中获取用户。 When my code is running half way I am getting this exception and even if i catch all the exceptions i still get it.Is there any work around for this? 当我的代码运行一半时,我得到了这个异常,即使我抓住了所有的例外,我仍然得到它。有什么解决方法吗?

Unhandled Exception: System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease)
   at PAObjectsLib.PrivateArkClass.Term()
   at CyberArk.API.Objects.PrivateArk.Term()
   at CyberArk.API.Objects.PrivateArk.DoDispose(Boolean disposing)
   at CyberArk.API.Objects.CyberArkBase.Dispose()
   at Program.Main(String[] args)

You can get this exception if the underlying COM object has been released (by calls to IUnknown.Release ). 如果已释放基础COM对象(通过调用IUnknown.Release ),则可以获得此异常。 I have seen this happen during shutdown where the runtime has collected the RCW (run-time callable wrapper) and some cleanup code then tries to access the now non-accessible COM object to call a "cleanup" function on the COM object before releasing it. 我已经看到在关机期间发生这种情况,运行时已经收集了RCW(运行时可调用包装器),然后一些清理代码尝试访问现在不可访问的COM对象,以便在释放它之前调用COM对象上的“清理”函数。

If this is correct you could try to Dispose the object earlier at shutdown. 如果这是正确的,您可以尝试在关机时更早地Dispose对象。

What do you want by "I still get it ?" 你想要什么“我还能得到它吗?”

Catching an exception will never it to happened. 捕获异常将永远不会发生。

On the other hand, Visual Studio can be configured to stop when any exception is trown, even if you code handles (catch) it. 另一方面,Visual Studio可以配置为在设置任何异常时停止,即使您编写句柄(捕获)它也是如此。 Go in the debug/Exception menu to configure that level of details. 进入debug / Exception菜单以配置该级别的详细信息。

There are more than one reasons that may be causing the exception. 可能导致异常的原因不止一个。 (try disposing correctly as @Martin Liversage said). (尝试正确处理@Martin Liversage说)。

If it doesn work and you have purchased the component, contact Cyber-Ark tech support. 如果它不起作用且您已购买该组件,请联系Cyber​​-Ark技术支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM