0

重做这个问题(对不起任何正在阅读它的人)

尝试使用 Prism 6,但我的所有 shellview 组件都出现问题,当我在调试模式下工作时一切都很好,但是当我切换到发布模式时,我遇到了很多错误。

Error   CS0246  The type or namespace name 'BindableBase' could not be found 
(are you missing a using directive or an assembly reference?)   
ShellModule C:\Dev\Prism_Prototype\Source\ShellModule\ViewModels\TitleControlViewModel.cs   

这几乎发生在每个文件中。在将鼠标悬停在错误上时,我可以选择添加对 Prism 的引用,并为 Prism.MVVM 添加使用,但是那里已经有一个引用,并且在将引用添加回来之后,我得到的是一个新的错误说明

The type or namespace name "BindableBase" could not be found, are you missing
a using directive or assembly reference.

以下是其中一个出错的文件作为示例。

using Prism.Mvvm;
using ShellModule.ViewModels.Interfaces;

namespace ShellModule.ViewModels
{
    public class TitleControlViewModel : BindableBase, ITitleControlViewModel
    {
        private string _content = "This is my content";

        public string Content
        {
            get { return _content; }
            set { SetProperty(ref _content, value); }
        }
    }
}

和 TitleControlView.xaml

<UserControl
    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:mvvm="http://prismlibrary.com/"
    mc:Ignorable="d"
    mvvm:ViewModelLocator.AutoWireViewModel="true"
    x:Class="ShellModule.Views.TitleControlView"
    HorizontalContentAlignment="Stretch">
    <UserControl.Resources>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="100*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Label x:Name="DekLogo" Background="{DynamicResource     SolidColourASMDefaultRed}" Width="180" Height="60"     HorizontalContentAlignment="Center" VerticalContentAlignment="Center"      Grid.Column="0" Padding="1" >
        <Image Source="{DynamicResource DekLogo}" Height="36" Width="110" />
    </Label>
    <Label x:Name="Notifications" Background="{DynamicResource SolidColourDefaultBackground}" HorizontalContentAlignment="Stretch" Grid.Column="1" Content="{Binding Content}" />
    <Label x:Name="SiplaceLogo" Background="{DynamicResource SolidColourBackground}" Width="180" Height="60" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Grid.Column="2" Padding="1">
        <Image Source="{DynamicResource Logo}" Height="36" Width="110" />
        </Label>
    </Grid>

</UserControl>
4

1 回答 1

0

在玩了更多之后解决了我自己的问题。

由于某种原因(可能在重构期间),我的引用在发布模式下被搞砸了。浏览并卸载了我一直用于 Prism 和 Ninject 的所有 nuget 包,然后重新安装了所有包,发现问题已得到解决。

仍然不知道为什么它首先发生。

于 2016-12-02T17:02:37.763 回答