积极答复者
未能加载文件或程序集“System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。系统找不到指定的文件

问题
-
demo是这里下载的。http://code.msdn.microsoft.com/windowsapps/Upload-File-to-Windows-c9169190 之前按照网页教程走过一遍,运行通过没问题。可是后来因为做别的应用隔天再打开这个demo时,却报错了。
添加了引用System.Net.Http.Primitives后,F5后抛出异常。被这个问题折腾好久了,不晓得是哪出问题了。
答案
-
Hi,coolala
估计是您的MobileServiceClient 类型的对象初始化时出现了问题,您可以看一下是不是里面的成员的初始化抛出了NullReferenceException异常!
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 Anne JingModerator 2013年8月29日 2:08
全部回复
-
Hi,coolala
您的问题解决了吗。
如果没有您可以将你的解决方案先clean一下,然后再rebuild一下。
如果还出现错误的提示的话,你可以追踪具体的错误,然后针对这个错误进行改进。
如果您还需要帮助的话,请将您的具体问题贴出来,我们再进一步讨论!- 已编辑 Anne JingModerator 2013年8月19日 3:20 from
-
今天又看了另一个demo,出现同样的问题。又是扔出TypeInitializationException类型的异常。网上搜到说是静态变量初始化导致的 。 可是之前写的都没出错。不晓得是不是环境出错了还是怎么了。
以下是demo中app.xaml.cs中的代码
namespace MyTrivia { using System; using Microsoft.WindowsAzure.MobileServices; using MyTrivia.Model; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; /// <summary> /// Provides application-specific behavior to supplement the default Application class. /// </summary> public sealed partial class App : Application { private static MobileServiceClient mobileService = new MobileServiceClient( "{mobile-service-url}", "{mobile-service-key}"); /// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += this.OnSuspending; } public static MobileServiceClient MobileService { get { return mobileService; } } public static TriviaModel Data { get; set; } /// <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(MainPage), args.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); } /// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); //// TODO: Save application state and stop any background activity deferral.Complete(); } } }
-
Hi,coolala
估计是您的MobileServiceClient 类型的对象初始化时出现了问题,您可以看一下是不是里面的成员的初始化抛出了NullReferenceException异常!
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已标记为答案 Anne JingModerator 2013年8月29日 2:08