WPF: Could not load file or assembly error in the designer but application runs with no problems

Kratochvíl Lukáš 5 Reputation points
2024-03-01T08:49:05.19+00:00

To try to solve another issue with the designer I've deleted bin and obj directories. Since then I'm facing this error while being in the designer: "The error message "Could not load file or assembly 'DesktopClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the specified file.". I can run the app with no problems the error is only related to the designer. The DesktopClient assembly is the assembly of the WPF project.

I've already tried:

  • Restarting the IDE
  • Updating the IDE

The project targets .NET 8.0.

Here is XAML code:

<Window x:Class="DesktopClient.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:root="clr-namespace:DesktopClient"
        xmlns:local="clr-namespace:DesktopClient.Views"
        xmlns:viewModels="clr-namespace:DesktopClient.ViewModels"
        xmlns:controls="clr-namespace:DesktopClient.Controls"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800"
        d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel, IsDesignTimeCreatable=true}">
    <Window.Resources>
        <DataTemplate x:Key="IModeViewModel">
            <StackPanel>                
                <ContentControl Content="{Binding}"/>
            </StackPanel>
        </DataTemplate>

        <DataTemplate DataType="{x:Type viewModels:OrdersListModeViewModel}">
            <!-- some content -->
        </DataTemplate>
        <!-- some content -->
	</Window.Resources>
</Window>
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,193 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.