我正在开发一个Windows Phone 8.1应用程序,它与Microsoft Band连接以发送一些通知.我需要执行一些后台任务,所以我添加了一个Windows运行时组件项目.
我从后台任务发送通知,即从Runtime组件项目发送通知.但是我收到了一个错误.错误如下:
错误: System.TypeInitializationException:'Microsoft.Band.Store.StoreResources'的类型初始值设定项引发异常.---> System.Exception:在Microsoft.Band.Store.StoreResources..cctor()的Windows.UI.Xaml.Application.get_Current()中发生灾难性故障(来自HRESULT的异常:0x8000FFFF(E_UNEXPECTED))---结束内部异常堆栈跟踪---在Microsoft.Band.Store.Bore.BluetoothTransport的Microsoft.Band.Store.BluetoothTransport.GetTransport(RfcommDeviceService服务,ILoggerProvider loggerProvider,UInt16 maxConnectAttempts)的Microsoft.Band.Store.StoreResources.get_RfComm_FromId_ReturnedNull()处. System_Threading.Tasks.Task.Execute()中的System.Threading.Tasks.Task`1.InnerInvoke()处于c__DisplayClass1.b__0()
正如本问题的答案所述,前台应用程序在后台应用程序尝试连接时不应尝试连接到乐队.
我认为错误是连接到蓝牙的问题,因为我已经调试并找出了错误的位置:
public async void Run(IBackgroundTaskInstance taskInstance)
{
var deferral = taskInstance.GetDeferral();
try
{
Debug.WriteLine("Task Triggered " + DateTime.Now);
taskInstance.Canceled += (s, e) => { };
taskInstance.Progress = 0;
// Get the list of Microsoft Bands paired to the phone.
var pairedBands = await BandClientManager.Instance.GetBandsAsync();
if (pairedBands.Length < 1)
{
Debug.WriteLine(
"This sample app requires a Microsoft Band …Run Code Online (Sandbox Code Playgroud) 我正在使用MVVM模式创建一个Windows Phone 8.1应用程序.我已经使用日期选择器,并且我希望得到的值(日期)日期选择在视图模型,所以我在视图模型属性绑定这一点.运行此应用程序后,我在Visual Studio的输出窗口中收到错误.
错误:转换器无法将类型'System.DateTime,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 7cec85d7bea7798e'的值转换为'DateTime'类型; BindingExpression:Path ='Date'DataItem ='App1.ViewModel.MainViewModel'; target元素是'Windows.UI.Xaml.Controls.DatePicker'(Name ='null'); target属性是'Date'(类型'DateTime').
这是我的Xaml视图:
<DatePicker Grid.Row="1" Grid.Column="1"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
HorizontalAlignment="Left"
VerticalAlignment="Center" Margin="26,-0.333,0,0.5"
Date="{Binding Date}"
/>
Run Code Online (Sandbox Code Playgroud)
ViewModel属性:
private DateTime _date;
public DateTime Date
{
get { return _date; }
set
{
_date = value;
RaisePropertyChanged();
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个错误.
我正在开发一个Windows项目,我有一年的ComboBox应该包含从1910年到现在的年份.这是我的代码
comboboxYears.DataSource = Enumerable.Range(1910, DateTime.Now.Year).ToList();
Run Code Online (Sandbox Code Playgroud)
但范围不是在1910年到现在之间.相反它在1910年到3924年之间.我在这里做错了什么?
我正在尝试在Windows 10中部署Windows Phone 8.1应用程序.我收到以下错误:
错误:DEP6200:Boostrapping"设备"失败.无法找到设备.Windows Phone IP over USB传输(IpOverUsbSvc)未运行.从服务管理控制台启动Windows Phone IP over USB Transport(IpOverUsbSvc)后重试.
错误:DEP6100:在boostrapping阶段'连接到设备'期间发生以下意外错误:SmartDeviceException - Windows Phone IP over USB Transport(IpOverUsbSvc)未运行.从服务管理控制台启动Windows Phone IP over USB Transport(IpOverUsbSvc)后重试.
我的Lumia手机已连接,可从Windows文件资源管理器访问.
我已经检查了IpOverUsbSvc服务的服务,但它不在那里.所以我也检查了powershell:get-service IpOverUsbSvc
Status Name DisplayName
------ ---- -----------
Stopped IpOverUsbSvc Windows Phone IP over USB Transport...
Run Code Online (Sandbox Code Playgroud)
我在使用Windows 8.1时没有收到这些错误.似乎此服务在Windows 10中不可用.
任何人都可以帮我解决这个问题吗?
有没有办法在c#中获得StackExchange.Redis键的TTL(生存时间)?