I am wondering how to compile a WPF application into an independent shared class library(dll)? Any sample?
Solution Explorer -> Right Click on "MySolution" -> Add -> New Project -> WPF User Control Library
Add your controls there and use from any other application.
Convert your current project to dll: Solution Explorer -> MyWpfApplication -> Right Click -> Properties -> Application Tab -> Output Type = Class Library
Or you can add references from other Applications to your existing project even if it's exe. (Controls are still available)
A library is not an application, so we can't convert a WPF application to a dll and expect to be able to run it independently.
One workaround might be to change the projects output type to "Class Library", then create a new WPF application which hooks into the dll.
To make the new application hook into the dll, first add a reference to the dll, then edit App.xaml and change StartupUri to a pack Uri pointing to the dll.
<Application x:Class="WpfApplication13.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="pack://application:,,,/ReferencedAssembly;component/MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With