c# - Cannot obtain value of local or argument 'hwndSource' as it is not available at this instruction pointer -


I am playing with Interpost and I thought: "O code is something that reaches the clipboard ..." So I googled and found some article (yes I'm doing it with WPF - .NET 3.5).

Although the following method triggers an error (seen in the title) and throws a stackoverflow.

  Private Zero Windows_SourceInitialized (Object Sender, EventArgs E) {// Hook Clipboard Base.OnSourceInitialized (e); HwndSource hwndSource = Presentation Source.frameVisual (this) as HWDSOSR; If (hwndSource! = Null) {installHandle = hwndSource.Handle; Viewer Handle = Setclipboard View (Installed Handle); HwndSource.AddHook (new HwndSourceHook (this.hwndSourceHook)); } // and hook to clipboard}  

I do not know (actually) what is happening there.

Any thoughts?

To call your issue, base.OnSourceInitialized is. When you are overriding the method, you should call the base implementation, but this is not the case here: you are handling a method, do not override a method.

Since SourceInitialized event is picked up by the OnSourceInitialized method, if you call OnSourceInitialized by call Will revive the event again So you have an infinite recurrence, which eventually causes a stack overflow.

So you have 2 options to fix the problem:

  • Override OnSourceInitialized sourceInitialized event
  • Instead of dealing with base.OnSourceInitialized

Comments

Post a Comment

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -