colindabritz / poeitemanalyzer Goto Github PK
View Code? Open in Web Editor NEWProvides real team analysis of Path of Exile items
Provides real team analysis of Path of Exile items
Logging a bug from dev. I again encountered an exception in the interop/com layer while copying text.
Note the code this was found in will be checked in shortly, with the first refactor extracting the library for clipboard monitoring out.
I had previously copied several times when in background, seemed to work (at least twice).
Note: I had a breakpoint active that logged to the console only (and continued) but this may not matter.
After a delay, I copied another chunk of text from this page out of the chrome browser: https://github.com/Reactive-Extensions/Rx.NET
This is therefore, NOT related to copying quickly, as this was very slow.
I have hit this before, previous comments were:
Can apparently throw
System.Runtime.InteropServices.COMException
{"OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))"}
was copying text real quick. Maybe this is the STA apartment thing?
Now the "real quick" factor is no longer relevant.
Transcribed as best I could below.
============================
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
Additional information: OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))
============================
Details:
Error code: -2147221040
HelpLink: null
HResult: -2147221040
InnerException: null
Message: OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))
Source: System
============================
[Larger sections below:]
============================
Data:{System.Collections.ListDictionaryInternal}
Count: 1
IsFixedSize: false
IsReadOnly: false
IsSynchronized: false
Keys: {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
SyncRoot: {object}
Values: {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
[Note above is literal, could not expand details further.]
============================
StackTrace:
at System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC& format, STGMEDIUM& medium)
at System.Windows.DataObject.OleConverter.GetDataInner(FORMATETC& formatetc, STGMEDIUM& medium)
at System.Windows.DataObject.OleConverter.GetDataFromOleHGLOBAL(String format, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetDataFromBoundOleDataObject(String format, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert)
at System.Windows.DataObject.GetData(String format, Boolean autoConvert)
at System.Windows.Clipboard.GetDataInternal(String format)
at System.Windows.Clipboard.GetText(TextDataFormat format)
at System.Windows.Clipboard.GetText()
at PoeItemAnalyzer.LogWindow.ClipboardChanged(Object sender, EventArgs e) in C:\Users\Colin\Documents\GitHubVisualStudio\PoeItemAnalyzer\PoeItemAnalyzer\LogWindow.xaml.cs:line 49
at WpfClipboardMonitor.WindowClipboard.OnClipboardChanged() in C:\Users\Colin\Documents\GitHubVisualStudio\PoeItemAnalyzer\WpfClipboardMonitor\WindowClipboard.cs:line 36
at WpfClipboardMonitor.WindowClipboard.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in C:\Users\Colin\Documents\GitHubVisualStudio\PoeItemAnalyzer\WpfClipboardMonitor\WindowClipboard.cs:line 45
at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at PoeItemAnalyzer.App.Main() in C:\Users\Colin\Documents\GitHubVisualStudio\PoeItemAnalyzer\PoeItemAnalyzer\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
============================
TargetSite:
{Void GetData(System.Runtime.InteropServices.ComTypes.FORMATETC ByRef, System.Runtime.InteropServices.ComTypes.STGMEDIUM ByRef)}
Attributes: Public | Virtual | HideBySig | NewSlot | Abstract
CallingConvention: Standard | HasThis
ContainsGenericParameters: false
CustomAttributes: Count = 0
DeclaringType: {Name = "IDataObject" FullName = "System.Runtime.InteropServices.ComTypes.IDataObject"}
IsAbstract: true
IsAssembly: false
IsConstructor: false
IsFamily: false
IsFamilyAndAssembly: false
IsFamilyOrAssemly: false
IsFinale: false
IsGenericMethod: false
IsGenericMethodDefinition: false
IsHideBySid: true
IsPrivate: false
IsPublic: true
IsSecurityCrritical: true
IsSecuritySameCritical: true
IsSecurityTransparent: false
IsSpecialName: false
IsStatic: false
IsVirtual: true
MemberType: Method
MetadataToken: 100673570
MethodHandle: {System.RuntimeMethodHandle}
MethodImplementationFlags: IL
Module: System.dll
Name: GetData
ReflectedType: {Name = "IDataObject" FullName = "System.Runtime.InteropServices.ComTypes.IDataObject"}
ReturnParameter: {Void }
ReturnType: {Name = "Void" FullName = "System.Void"}
ReturnTypeCustomAttributes: {Void }
While researching the problems described in issue 1: #1
I ran across commentary that "STA Mode" might be an issue. This turns out not to be the case for this particular issue (it was system level clipboard locking), but it might matter in general.
See the comment: "Maybe this is the STA apartment thing?"
In this checkin: 17b690b
During further investigation I had both my main application and item log up, as well as the test application.
On the test application I got an error:
Managed Debugging Assistant 'DisconnectedContext' has detected a problem in 'C:\Users\Colin\Documents\GitHubVisualStudio\PoeItemAnalyzer\TestPanel\bin\Debug\TestPanel.vshost.exe'.
Additional information: Transition into COM context 0x13ab278 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 0x13ab278 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.
It had few other details, and I was unable to reproduce it in two follow-up tests.
This error was interesting as it offered a different perspective to potential issues, although it could be an issue with our com operation returning, and the app crashing so the thread was no longer available.
It may also mean that we need to work on Marshaling and thread lifecycle issues.
The COM Apartment concept comes into play.
Internet research suggests this may be the case.
See:
https://stackoverflow.com/questions/4430869/com-interop-net-sta
https://msdn.microsoft.com/en-us/library/eaw10et3(v=vs.110).aspx
https://stackoverflow.com/questions/4154429/apartmentstate-for-dummies
https://blogs.msdn.microsoft.com/jfoscoding/2005/04/07/why-is-stathread-required/
Testing with:
Console.WriteLine($"Current thread apartment state is: {Thread.CurrentThread.GetApartmentState()}");
our threads are STA in both apps, so this may be only a lifecycle issue.
Logged here to keep track of this error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.