Cannot obtain value of local or argument 'hwndSource' as it is not available at this instruction poi
- by Dänu
Hey Guys
I'm playing around with Interops and I thought: "Hey let's code something that accesses the clipboard ..." so I googled and found some articles (yeah I'm doing it with WPF - .Net 3.5).
However the following method generates an error (as seen in the title) and throws a stackoverflow.
private void Window_SourceInitialized(object sender, EventArgs e)
{
// Hook to Clipboard
base.OnSourceInitialized(e);
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
if (hwndSource != null)
{
installedHandle = hwndSource.Handle;
viewerHandle = SetClipboardViewer(installedHandle);
hwndSource.AddHook(new HwndSourceHook(this.hwndSourceHook));
}
// End Hook to Clipboard
}
I have (really) no idea what's going on there.
Any Ideas?