【问题标题】:"Unable to determine application identity of the caller" for ViewModelLocatorViewModelLocator 的“无法确定调用者的应用程序身份”
【发布时间】:2013-10-25 12:07:41
【问题描述】:

在 app.xaml 中,我在定义 ViewModelLocator 时出错。应用程序启动并运行良好,但在 Studio 中让我很恼火。想知道,可能是什么原因。突出显示的行是

<vm:ViewModelLocator x:Key="ViewModelLocator" d:IsDataSource="True"/>

错误:

错误 1 ​​无法确定调用者的应用程序身份。

如果要进入 vm:ViewModelLocator,那里没有错误迹象。我应该重新检查我的所有视图模型并添加 IsoStorage 设计时保护吗?

if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
{
    settings = IsolatedStorageSettings.ApplicationSettings; 
}

【问题讨论】:

    标签: c# windows-phone-7 mvvm-light


    【解决方案1】:

    如果有人遇到同样的问题。只是建议:尝试在 Blend 中打开您的项目并将 VS 附加到它。您会立即看到问题出在哪里(通常是在设计时访问 IsoStorage)。

    编辑:更准确地说,添加 DesignMode 检查解决了我的突出显示问题。

    public ViewModelLocator()
        {
            if (ViewModelBase.IsInDesignModeStatic)
                return;
    
        ****
    

    【讨论】:

    • 附加VS是什么意思?
    • 调试/附加到 Process/Blend - 这样,您就可以在从 Blend 运行时调试代码。
    • 另外,这篇文章可以提供帮助:stackoverflow.com/questions/11886698/…
    • 好的,我会检查一下,但我厌倦了附加到混合,当错误消息出现时,即使我收到错误消息,VS 也不会触发任何内容。
    • 我不确定您链接到的文章是否适用,我只是以对话框消息框的形式收到该错误消息。我想追捕并纠正它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-27
    • 2020-09-07
    • 2012-05-19
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多