2017-11-10 6 views
0

次のように、V3のAPIを介してGoogleドライブにファイルをアップロードするプログラムのリリースでは、これを把握することはできません、スローです:GoogleドライブAPIによって発生したSystem.Net.Httpや依存関係が不足しています(GoogleドライブAPIによって発生)

にFileNotFoundException:ファイルまたはアセンブリ をロードできませんでした 'System.Net.Http、バージョン= 4.0.0.0、文化=中立、 なPublicKeyToken = b03f5f7f11d50a3a' またはその依存関係の1つ。 システムは、指定されたファイルを見つけることができません。

これはデバッグモードではなく、リリースモードと公開バージョンで発生します。私は削除し、更新してから、プロジェクトへのsystem.Net.Http参照を追加し直しました。私はGoogle APIを更新し、多数の設定と参照を無用に変更しました。

私には何が欠けているか、それを置き換える方法はわかりません。アップロードクラスの接続メソッドを呼び出すと、コードがこのメソッドを終了した後に例外がスローされます。

using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    using System.Threading.Tasks; 
    using System.Net; 
    using System.Net.Http; 
    using Google.Apis.Auth.OAuth2; 
    using Google.Apis.Drive.v3; 
    using Google.Apis.Drive.v3.Data; 
    using Google.Apis.Services; 
    using Google.Apis.Util.Store; 
    using System.IO; 
    using System.Threading; 
    //using Google.Apis.Vision.v1; 
    using System.Diagnostics; 
    using System.Runtime.InteropServices;  

    namespace Rohl 
    { 
     public class DriveManager 
     { 
      static string[] Scopes = { DriveService.Scope.Drive}; 
      static string ApplicationName = "Rohl - Drive Services"; 
      UserCredential credential; 

      public void connector() 
      { 
       using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) 
       { 
        string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); 
        credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json"); 


        credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
         GoogleClientSecrets.Load(stream).Secrets, 
         Scopes, 
         "user", 
         CancellationToken.None, 
         new FileDataStore(credPath, true)).Result; 

        Properties.Settings.Default.DebugWrite.Add(DateTime.Now.ToString("hh.mm.ss.ff") + " CREDENTIALS SAVED TO - " + credPath); 
       } 

       service = new DriveService(new BaseClientService.Initializer() 
       { 
        HttpClientInitializer = credential, 
        ApplicationName = ApplicationName, 
       }); 

      } 
} 
} 

私は、プログラムがアセンブリを見つけることができなくなる可能性があるのは何ですか?

+1

あなたは[SO post](https://stackoverflow.com/questions/20463119/the-system-cannot-find-the-file-specified)にアクセスしましたか?多分、これはあなたがエラーを排除するのを助けるかもしれません。 –

答えて

1

私のプロジェクトではまったく同じエラーがありました。リリース後、System.Net.Http.dllが.exeが存在するフォルダに見つからないことがわかりました。 bin \ Debug-folderからコピーし、これが役立つかどうか確認してください。 ご挨拶。

+0

これは鍵であり、リリースビルドにも使用できるようになりました。今すぐ公開されたoneclickアプリにそれを含める方法を理解する必要があります。 –