【发布时间】:2016-05-22 08:13:27
【问题描述】:
您好,我有一个针对 WP8.1 的 silverlight 项目,它是一个游戏。我使用 backgroundTask 来提醒用户他上次玩的时间,如果他太慢而无法遵守,我想从 bagroundTask 调用服务器以退出游戏。
backgroundTask 是使用stackoverflow 和this blog 制作的,只是backgroundTask 的基本实现。
然后我安装 NuGet 包Microsoft.Azure.Mobile.Client 一切正常,然后我进行编译,一切成功。
应用程序安装并出现启动画面,然后我在App.xaml.cs中的MobileServiceClient初始化时在主项目中出现错误
public MobileServiceClient MobileService = new MobileServiceClient(
"https://xxxxx.azurewebsites.net"
);
上述行中的异常状态:
“System.IO.FileNotFoundException”类型的异常发生在 mscorlib.ni.dll 中,但未在用户代码中处理 附加信息:无法加载文件或程序集“System.Runtime.InteropServices,Version=4.0.10.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。系统找不到指定的文件。
唯一的变化是在 backgroundTask 项目中安装了 NuGet 包。上述异常的堆栈跟踪输出。
在 System.ModuleHandle.ResolveType(RuntimeModule 模块,Int32 typeToken,IntPtr* typeInstArgs,Int32 typeInstCount,IntPtr* methodInstArgs,Int32 methodInstCount,ObjectHandleOnStack 类型) 在 System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule 模块,Int32 typeToken,RuntimeTypeHandle[] typeInstantiationContext,RuntimeTypeHandle[] methodInstantiationContext) 在 System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,Type[] genericTypeArguments,Type[] genericMethodArguments) 在 System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord,MetadataImport 范围,Assembly& lastAptcaOkAssembly,RuntimeModule 装饰模块,MetadataToken 装饰令牌,RuntimeType attributeFilterType,Boolean mustBeInheritable,Object[] 属性,IListderivedAttributes,RuntimeType&attributeType,IRuntimeMethodInfo&ctor,Boolean&ctorHasParameters,Boolean&isVar 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule 装饰模块,Int32 装饰元数据令牌,Int32 pcaCount,RuntimeType attributeFilterType,布尔 mustBeInheritable,IList 派生属性,布尔 isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule 装饰模块,Int32 装饰元数据令牌,Int32 pcaCount,RuntimeType attributeFilterType,布尔 isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly 程序集,RuntimeType caType) 在 System.Reflection.RuntimeAssembly.GetCustomAttributes(类型属性类型,布尔继承) 在 System.Attribute.GetCustomAttributes(程序集元素,类型属性类型,布尔继承) 在 Microsoft.WindowsAzure.MobileServices.PlatformInformationExtensions.GetVersionFromAssemblyFileVersion(IPlatformInformation 平台信息) 在 Microsoft.WindowsAzure.MobileServices.PlatformInformation.get_Version() 在 Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.GetUserAgentHeader() 在 Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient..ctor(IEnumerable`1 处理程序,Uri applicationUri,String installationId) 在 Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor(Uri mobileAppUri,HttpMessageHandler[] 处理程序) 在 Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor(字符串 mobileAppUri,HttpMessageHandler[] 处理程序) 在 BC_Menu.App..ctor()
我没能解决这个问题。
额外
我可以使用 proposed code 对网络进行正常的 http 调用,在此处复制:
BackgroundTaskDeferral _deferral;
public async void Run(IBackgroundTaskInstance taskInstance)
{
_deferral = taskInstance.GetDeferral();
// your async code
_deferral.Complete();
}
根据 Adrian Halls 答案更新
代码有效,我的前端应用程序可以与服务器和一切通信。 backgroundTask,可以从设备中提取信息一切都很好,一切都编译并运行。
然后我将 NuGet 包添加到 backgroundTask,当我将此解决方案部署到客户端时,突然出现上述错误。
我正在运行 VS2015、Win10,并安装了 Microsoft.Azure.Mobile.Client v2.0.1。我在 win10 before 上看到了 Silverlight 项目的一些奇怪行为。
【问题讨论】:
标签: azure silverlight windows-phone-8 windows-phone-8.1 azure-mobile-services