Can't initialize RibbonWindow in winform project

May 6, 2009 at 10:58 AM
TypeInitializeException will be thrown with inner exception detail "The URI prefix is not recognized."
According to my understanding, the exception happens because the following code in RibbonWindow constructor:
_dictionary.Source = new Uri("/RibbonControlsLibrary;component/Themes/RibbonWindow.xaml", UriKind.Relative
The above code works perfectly if there exists WPF Application instance which do some initialization to help find URI package. Unfortunately there's no WPF Applicaiton instance in my app, so comes the excepion.

Since WPF Window class can be instantiated in winform project, I think same request to RibbonWindow is reasonable. Actually the minor change may fix the issue:
_dictionary.Source = new Uri("pack://application:,,, /RibbonControlsLibrary;component/Themes/RibbonWindow.xaml", UriKind.Relative

I hope it would be helpful.