我正在使用Windows应用商店应用程序,并且遇到问题。InitializeComponent - AccessViolationException
我离开了我的电脑,完全没有错误的功能程序。 离开电脑几天后,我启动它并尝试运行我的程序。 它立即崩溃并声明:“AccessViolationException未处理,尝试读取或写入受保护的内存,这通常表示其他内存已损坏。”在InitializeComponent中。
我,但是可以更改我的App.Xaml.cs文件起始页在OnLaunched方法网主页,它workes罚款。但后来我没有登录页面。我不能重定向从主页到登录页面,否则它崩溃。
我的调用堆栈 [外部代码]
EmployeeAssistant.exe!EmployeeAssistant.PagesWithSnappedViews.LoginPage.LoginPage()线49 + 0x8中字节C# [外部代码] EmployeeAssistant.exe!EmployeeAssistant.App。 OnLaunched(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs参数)线58个+的0x42字节C# [外部代码]
我的当地人
------------------- -------------------编辑
private readonly ObservableCollection<PropertyInfo> _colorSource = new ObservableCollection<PropertyInfo>();
private string _selectedColorName;
public ObservableCollection<PropertyInfo> ColorSource
{
get { return _colorSource; }
}
public string SelectedColorName
{
get { return _selectedColorName; }
set
{
_selectedColorName = value;
OnPropertyChanged();
}
}
public LoginPage()
{
InitializeComponent();
var colors = typeof(Colors).GetTypeInfo().DeclaredProperties;
foreach (var item in colors)
{
ColorSource.Add(item);
}
}
的App.OnLaunched:
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(LoginPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active
Window.Current.Activate();
}
,如果我尝试调试,看看发生了什么它所做的是从LayoutAwarePage和该行加载代码: 私人只读的ObservableCollection _colorSource =新的ObservableCollection(); 然后它进入InitializeComponent,我得到AccessViolationException。
没有人有发生什么事,也许如何解决这个的想法?
Niklas
这听起来像你的应用程序可能有一些问题,当暂停后恢复 - 你可以发布一些源代码? – 2013-05-13 12:08:18
发表了一些源代码。希望它够了。 – NiklasHansen 2013-05-13 12:23:51
也许你可以发布'EmployeeAssistant.App.OnLaunched'呢? – 2013-05-13 12:37:14