无法确定调用者的应用程序身份? [英] Unable to determine application identity of the caller?
问题描述
我正在 VS2010 中为 Windows Phone 编写 Silverlight 透视应用程序.我刚刚添加了来自 msdn here.现在每次我重新加载设计器时都会出现异常:
I'm writing a Silverlight pivot app in VS2010 for Windows Phone. I just added the example code from msdn here. Now every time I reload the designer I get an exception:
无法确定调用者的应用程序身份.
Unable to determine application identity of the caller.
在 System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type appEvidenceType)
at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type appEvidenceType)
在 System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type applicationEvidenceType)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type applicationEvidenceType)
在 System.IO.IsolatedStorage.IsolatedStorageSettings.get_ApplicationSettings()在 C:..Settings.cs:line 34
at System.IO.IsolatedStorage.IsolatedStorageSettings.get_ApplicationSettings() at SettingsSample.AppSettings..ctor() in C:..Settings.cs:line 34
这是 Visual Studio/Windows Phone SDK 中的错误吗?
Is this a bug in Visual Studio/Windows Phone SDK?
这是第 34 行构造函数中的代码:
This is the code in the constructor at line 34:
public AppSettings()
{
// Get the settings for this application.
try
{
settings = IsolatedStorageSettings.ApplicationSettings;
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
我添加了 try-catch 以查看发生了什么.
I added the try-catch to see what was going on.
我怀疑 Visual Studio(调用方)正在尝试运行代码,但没有关联的应用程序(应用程序标识),所以它失败了.也许?
I suspect that Visual Studio(the caller) is attempting to run the code but there is no application(application identity) associated, so it fails. Maybe?
有什么想法吗?
推荐答案
您需要添加一个检查到 DesignerProperties.IsInDesignTool 到该代码,因为访问 Visual Studio 或 Expression Blend 中的 IndependentStorageSettings 无效.
You need to add a check to DesignerProperties.IsInDesignTool to that code since accessing IsolatedStorageSettings in Visual Studio or Expression Blend is invalid.
if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
{
settings = IsolatedStorageSettings.ApplicationSettings;
}
这篇关于无法确定调用者的应用程序身份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!