4

こんにちは私はゲームであるWP8.1用のSilverlightプロジェクトを持っています。私はバックグラウンドタスクを使用して、彼が最後にプレイした時を知らせ、遅すぎてそれを遵守することができない場合、bagroundタスクからサーバーを呼び出してゲームから辞退したいと思います。WP Silverlight BackgroundTask Azureとの通信

backgroundTaskは、backgroundTaskの基本的な実装であるstackoverflowthis blogを使用して作成されています。

NuGetパッケージMicrosoft.Azure.Mobile.Clientをインストールしても問題ありません。次にコンパイルを実行してすべて成功します。

アプリをインストールし、スプラッシュスクリーンが表示され、その後、私はApp.xaml.cs

MobileServiceClientの初期化時にメインプロジェクトでエラーが発生します
public MobileServiceClient MobileService = new MobileServiceClient(
     "https://xxxxx.azurewebsites.net" 
    ); 

上記の行で例外状態:

例外mscorlib.ni.dllで 'System.IO.FileNotFoundException'型が発生しましたが、ユーザーコード で処理されませんでした。追加情報:ファイルまたはアセンブリ 'System.Runtime.InteropServices、Version = 4.0.10.0、Culture = neutralを読み込めませんでした。 PublicKeyToken = b03f5f7f11d50a3a 'またはその依存関係の1つ。システムは、指定されたファイルを見つけることができません。

唯一の変更は、backgroundTaskプロジェクトでのNuGetパッケージのインストールでした。上の例外に対するスタックトレース出力。 System.ModuleHandle.ResolveType System.ModuleHandle.ResolveTypeHandleInternalで(RuntimeModuleモジュールのInt32 typeToken、のIntPtr * typeInstArgs、のInt32 typeInstCount、のIntPtr * methodInstArgs、のInt32 methodInstCount、ObjectHandleOnStack型) (RuntimeModuleモジュールのInt32 typeToken、で

RuntimeTypeHandle [] typeInstantiationContext、System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord、MetadataImportスコープ、組み立て時RuntimeTypeHandle System.Reflection.RuntimeModule.ResolveTypeで[] methodInstantiationContext) (のInt32 metadataToken、[] genericTypeArgumentsを入力し、[] genericMethodArguments型) & lastAptcaOkAssembly、RuntimeModule decoratedModule、MetadataT王研decoratedToken、RuntimeType attributeFilterType、ブールmustBeInheritable、[]属性のIList derivedAttributes、RuntimeType &とattributeType、IRuntimeMethodInfo & CTOR、ブール& ctorHasParameters、ブール& isVarArg)System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule、のInt32 decoratedMetadataToken、のInt32に オブジェクトpcaCount、RuntimeType attributeFilterType、ブールmustBeInheritable、IListのderivedAttributes、ブールisDecoratedTargetSecurityTransparent)System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule、のInt32 decoratedMetadataToken、のInt32 pcaCount、RuntimeType attributeFilterType、ブールisDecoratedTargetSecurityTransparent)System.Reflection.CustomAttribute.GetCustomAttributesで で(RuntimeAss Microsoft.WindowsAzure.MobileServices.PlatformInformationExtensions.GetVersionFromAssemblyFileVersionでSystem.Attribute.GetCustomAttributesでemblyアセンブリ、RuntimeType caType)System.Reflection.RuntimeAssembly.GetCustomAttributesで (タイプとattributeType、ブール継承) (組立要素、種類とattributeType、ブール継承) (IPlatformInformation platformInformation) 、Microsoft.WindowsAzure.MobileServices.PlatformInformation.get_Version() 、Microsoft.WindowsAzure.MobileServicesにあります。Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor(URI mobileAppUri、HttpMessageHandler []ハンドラ)でMobileServiceHttpClient.GetUserAgentHeader()Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient..ctor(IEnumerable`1ハンドラ、ウリapplicationUri、ストリングinstallationId)で BC_Menu.App..ctorでMicrosoft.WindowsAzure.MobileServices.MobileServiceClient..ctor(文字列mobileAppUri、HttpMessageHandler []ハンドラ) ()

で 私はこの問題を解決することができていません。

エクストラ

私はここで、複製、proposed codeを使用してウェブに通常のHTTP呼び出しを行うことができる午前:

BackgroundTaskDeferral _deferral; 

public async void Run(IBackgroundTaskInstance taskInstance) 
{ 
    _deferral = taskInstance.GetDeferral(); 
    // your async code 
    _deferral.Complete(); 
} 

エイドリアン・ホールの回答

に基づいて更新コードが動作し、私の前のアプリケーションはサーバーやすべてと通信することができます。 backgroundTaskは、デバイスからすべての情報を抽出でき、すべてがコンパイルされ実行されます。

次に、NuGetパッケージをbackgroundTaskに追加します。このソリューションをクライアントに展開すると、突然上記のエラーが表示されます。

私はVS2015、Win10を実行しており、Microsoft.Azure.Mobile.Clientのv2.0.1をインストールしています。私はwin10 beforeに銀色のプロジェクトでいくつかの奇妙な行動を見てきました。

答えて

2

エラーは、.NETセットアップに問題があることを示します。エラーはmscorlib(.NETの基本ライブラリ)にあります。必要な特定のライブラリへの参照を追加してください。また、v2.0.1(またはそれ以降)またはMicrosoft.Azure.Mobile.Clientライブラリもインストール済みであることを確認してください。

+0

インストールされているバージョンで、これを試して修正します。したがって、あるプロジェクトにパッケージをインストールすると、別のプロジェクトの依存関係に影響が及ぶでしょうか?ただ明確にする? – JTIM

+0

あなたの答えをもう一度読んだので少し不安です。コードは機能し、私の前のアプリケーションはサーバーやすべてと通信できます。 backgroundTaskは、デバイスからすべての情報を抽出でき、すべてがコンパイルされ実行されます。その後、backgroundTaskにNuGetパッケージを追加すると、突然上記のエラーが表示されます。私はVS2015、Win10を実行しており、Microsoft.Azure.Mobile.Clientのv2.0.1をインストールしています。 – JTIM

+0

@JTIM私は、バックグラウンドタスクは常にSilverlightでなくWPAでなければならないと考えましたか?あなたはそれを別のアセンブリに入れて、ターゲットを非Silverlightに変更できますか? –

関連する問題