In a C# solution, how do I add an .EXE project to a solution of DLL project's?

This is using Microsoft Visual Studio Professional.

I have been handed a solution file which contains three projects. But all three projects generate DLL files. It is kind of unique because I have uncovered that they contain XAML files. So there is the opportunity to use the dll's to display WPF style UI as long as I properly create a new project for the solution. And this is what I am asking. What are the steps involved in creating a new project in the solution that is an executable and loads the DLL's and displays the UI'S?

Dani AI

Generated

As suggested, the cleanest approach is to add a WPF application project to the solution and make it the startup EXE; as noted, reference the existing DLLs from that EXE. The important details people often miss are target-framework compatibility, resource build actions, and how XAML from another assembly is referenced at runtime — follow these steps.

  1. Inspect the three existing projects: open each Project > Properties and note the Target Framework, Assembly name, and whether XAML files have Build Action = Page (WPF) or Resource. If their framework differs from what you create for the EXE, either retarget the EXE or the libraries so they match.
  2. Add a new project: Add > New Project > WPF Application (choose the matching framework). Add project references (preferred) to the solution projects, or add binary references to the compiled DLLs. Set the new project as Startup Project and set Project Dependencies so the DLL projects build first. Ensure referenced DLLs have Copy Local = True so they end up in the EXE output folder.

XAML integration notes (common pitfalls)

  • To use controls defined in a library, reference them in XAML with a clr-namespace + assembly declaration, e.g.:

    xmlns:lib="clr-namespace:MyLib.Namespace;assembly=MyLibAssembly"
    <lib:SomeUserControl />
  • External ResourceDictionaries must be referenced with a pack URI and the XAML files must be compiled as Page:

    <ResourceDictionary Source="/MyLibAssembly;component/Themes/LibraryStyles.xaml" />

Troubleshooting checklist

  • If you get XamlParseException or "Cannot locate resource", check the assembly name, pack URI syntax, and that the XAML Build Action = Page.
  • Designer errors often clear after a full Rebuild; open the designer only after a successful build.
  • Ensure types you instantiate are public; if internals are required across assemblies, use InternalsVisibleTo.
  • Watch for platform/bitness mismatches and mismatched .NET targets.

If the DLLs contain loose XAML (not compiled) you may need to load them with XamlReader at runtime instead of normal references. These checks cover the usual gaps beyond simply "add a WPF project" and "add references."

Recommended Answers

All 2 Replies

Right-click the solution and add a new project, WPF since you think it is XAML.

Then add references to the dll's you want to use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.