Skip to main content
 首页 » 编程设计

c#之Designview 中的 IsolatedStorage 异常

2024年02月20日12dudu

大家好,我在尝试编辑我的 UI 时遇到了一个孤立的异常

它说

Unable to determine application identity of the caller. at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type appEvidenceType) at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type applicationEvidenceType)at "CLASS FILE NAME.cs"

当我尝试这样做时

    <data:scheduledItems x:Key="alarmCollection" /> 
</phone:PhoneApplicationPage.Resources> 

我用它来绑定(bind)数据。它可以工作,但我无法对我的设计 View 做任何事情

谢谢!

请您参考如下方法:

在我看来,Visual Studio 正在尝试从独立存储中检索数据,但它不能,因为它是 Visual Studio 而不是您的应用程序。如果您考虑一下,这是有道理的——隔离存储仅在应用程序部署到 Windows Phone 后创建,而不是在此之前。它在设计 View 中不可用。

如果您想在设计 View 中实际显示此数据,则不能。但是您可以检查是否附加了设计 View ,并避免尝试以这种方式访问​​独立存储。

using System.ComponentModel; 
 
... 
 
if (DesignerProperties.IsInDesignView) 
{ 
    // return dummy data for the design view 
} 
else 
{ 
   // grab data from isolated storage 
}