I am developing a WPF windows application and am getting into a trouble running the app in .NET 3.0. Everytime that I try to access the System.Windows.Threading.Dispatcher.Invoke() method, I get a method-not-found error.
Basically, I spawn a new thread from the main thread and try to change some UI properties (basically update a progress-bar) from the new thread using the following code:
updateStatusDelegate usd = new updateStatusDelegate(progressBar.SetValue);
Dispatcher.Invoke(usd, System.Windows.Threading.DispatcherPriority.Background, new object[] { System.Windows.Controls.ProgressBar.ValueProperty, Convert.ToDouble(perc) });
Can someone help me understand why do I encounter this error in .NET 3.0 version? I am able to get this going in .NET 3.0 SP2. But I guess .NET is not distributed independantly and is packaged only with .NET 3.5 version. My goal is to get away with the dependancy of .net 3.5 and have a dependancy on .NET 3.0 version
Any help would be appreciated.
Thanks
Kapil
There’s been a fair amount of flux in the WPF classes. Note the “Supported in” annotation at the bottom of the MSDN Library article for this method. You’ll need to have at least .NET 3.0 SP1 installed on that machine, the service pack that was released at the same time as .NET 3.5.
There is no good way to check for this, the [AssemblyVersion] didn’t change. This was papered-over by relying on Windows Update automatically upgrading the .NET version. If your customer blocks these updates then you’ll have to setup a test machine that has the original .NET 3.0 release installed.
The workaround is simple enough, once you find them, use an overload that is available in 3.0 RTM. Asking the customer to deploy 3.5 SP1 would be wise.