应用程序已退出,代码为 1 (0x1),在本地计算机上运行时
App has exited with code 1 (0x1), When runnin on local machine
我正在开发一个通用 windows 应用程序,它在 Windows Phone、Phone 模拟器上运行良好,但是当我尝试 运行 这个本地机器(桌面)它不断退出并显示消息“应用程序已退出,代码为 1”,我认为有人用 1 发送退出信号,但为什么......?没有可用信息。
我找到了一些相关的问题,但没有一个有明确的答案。
如有任何帮助和建议,我们将不胜感激。
App.xaml.cs代码
public App()
{
this.InitializeComponent();
this.ExtendedSplashScreenFactory = (splashscreen) => new ExtendedSplashScreen(splashscreen);
#if DEBUG
HockeyClient.Current.Configure("Appid");
HockeyClient.Current.SendCrashesAsync();
#endif
// start live tiles updates
SportsClassLibrary.Common.SportsLiveTiles.StartPeriodicTileUpdate("https://tve.rpc.org/windows/sportsTile.cgi");
}
protected override Task OnInitializeAsync(IActivatedEventArgs args)
{
_container.RegisterType<IAlertDialogService, AlertDialogService>(new ContainerControlledLifetimeManager());
_container.RegisterType<IAccountService, AccountService>(new ContainerControlledLifetimeManager());
_container.RegisterType<IConfigService, ConfigServices>(new ContainerControlledLifetimeManager());
_container.RegisterInstance <INavigationService>(this.NavigationService);
_container.RegisterInstance<IEventAggregator>(new EventAggregator());
ServiceLocator.SetUnityContainer(_container);
// override the default viewmodel assembly location
Prism.Mvvm.ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) =>
{
var viewModelTypeName = string.Format(System.Globalization.CultureInfo.InvariantCulture, "SportClassLibrary.ViewModels.{0}ViewModel,SportClassLibrary", viewType.Name);
var viewModelType = Type.GetType(viewModelTypeName);
return viewModelType;
});
return Task.FromResult<object>(null);
}
protected override object Resolve(Type type)
{
return _container.Resolve(type);
}
protected override async Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
{
if (args.PreviousExecutionState != ApplicationExecutionState.Running)
{
IConfigService configServices = (IConfigService)ServiceLocator.getServiceInstanceForType(typeof(IConfigService));
await configServices.GetConfigAsync();
}
this.NavigationService.Navigate(Experiences.Experience.Epg.ToString(), null);
}
}
所有方法执行正常
好的,我发现了问题,实际上我是在构造函数方法中异步向 hockey 发送崩溃报告,HockeyClient.Current.SendCrashesAsync();
将此代码移动到 OnInitializeAsync
方法解决了这个问题。
我正在开发一个通用 windows 应用程序,它在 Windows Phone、Phone 模拟器上运行良好,但是当我尝试 运行 这个本地机器(桌面)它不断退出并显示消息“应用程序已退出,代码为 1”,我认为有人用 1 发送退出信号,但为什么......?没有可用信息。
我找到了一些相关的问题,但没有一个有明确的答案。
如有任何帮助和建议,我们将不胜感激。
App.xaml.cs代码
public App()
{
this.InitializeComponent();
this.ExtendedSplashScreenFactory = (splashscreen) => new ExtendedSplashScreen(splashscreen);
#if DEBUG
HockeyClient.Current.Configure("Appid");
HockeyClient.Current.SendCrashesAsync();
#endif
// start live tiles updates
SportsClassLibrary.Common.SportsLiveTiles.StartPeriodicTileUpdate("https://tve.rpc.org/windows/sportsTile.cgi");
}
protected override Task OnInitializeAsync(IActivatedEventArgs args)
{
_container.RegisterType<IAlertDialogService, AlertDialogService>(new ContainerControlledLifetimeManager());
_container.RegisterType<IAccountService, AccountService>(new ContainerControlledLifetimeManager());
_container.RegisterType<IConfigService, ConfigServices>(new ContainerControlledLifetimeManager());
_container.RegisterInstance <INavigationService>(this.NavigationService);
_container.RegisterInstance<IEventAggregator>(new EventAggregator());
ServiceLocator.SetUnityContainer(_container);
// override the default viewmodel assembly location
Prism.Mvvm.ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) =>
{
var viewModelTypeName = string.Format(System.Globalization.CultureInfo.InvariantCulture, "SportClassLibrary.ViewModels.{0}ViewModel,SportClassLibrary", viewType.Name);
var viewModelType = Type.GetType(viewModelTypeName);
return viewModelType;
});
return Task.FromResult<object>(null);
}
protected override object Resolve(Type type)
{
return _container.Resolve(type);
}
protected override async Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
{
if (args.PreviousExecutionState != ApplicationExecutionState.Running)
{
IConfigService configServices = (IConfigService)ServiceLocator.getServiceInstanceForType(typeof(IConfigService));
await configServices.GetConfigAsync();
}
this.NavigationService.Navigate(Experiences.Experience.Epg.ToString(), null);
}
}
所有方法执行正常
好的,我发现了问题,实际上我是在构造函数方法中异步向 hockey 发送崩溃报告,HockeyClient.Current.SendCrashesAsync();
将此代码移动到 OnInitializeAsync
方法解决了这个问题。