I wrote code in WPF. Firstly, I wrote a separate project to test work with a COM port device, and it worked well. Next I decided to integrate it in another project, but I ge
In the first code, you are in a class that inherits from Window, so you have a Dispatcher property in scope, which returns an instance of Dispatcher. In the second code, you're in the QRBarCode class, which doesn't have a Dispatcher property; so the compiler assumes you're referring to the Dispatcher type, and tries to call Invoke on this type, but since it's not a static method, it can't be called directly on the type.
You need an instance of Dispatcher to call Invoke; you can use the one from the application:
Application.Current.Dispatcher.Invoke(...);