Disconnected Context was detected c# clipboard

旧街凉风 提交于 2019-12-10 20:19:22

问题


Transition into COM context 0x27a7788 for this RuntimeCallableWrapper failed with the following error: Object is not connected to server (Exception from HRESULT: 0x800401FD (CO_E_OBJNOTCONNECTED)). This is typically because the COM context 0x27a7788 where this RuntimeCallableWrapper was created has been disconnected or it is busy doing something else and cannot process the context transition. No proxy will be used to service the request on the COM component and calls will be made to the COM component directly. This may cause corruption or data loss. To avoid this problem, please ensure that all COM contexts/apartments/threads stay alive and are available for context transition, until the application is completely done with the RuntimeCallableWrappers that represents COM components that live inside them.

I am trying to access Clipboard in my C# App.... It works .... but whenever i have following text in my clipboard it stops and give me exception Quoted above..

else if (e == Keys) { return ""; }

My Code is following

private string GetClip()
        {
            string MyStr="";
            try
            {
                if(Clipboard.ContainsText())
                MyStr = Clipboard.GetText();
            }
            catch
            {
            }
            return MyStr;
        }

来源:https://stackoverflow.com/questions/13550502/disconnected-context-was-detected-c-sharp-clipboard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!