私は、参照3 DLLのよう追加:今Imが例外を取得するTypeload例外は何ができますか?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Translator.translate(new TranslateInput());
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
エラー例外がある:私は1つのラインを持っているのForm1にGoogle.Apis、Google.Apis.Translate.v2、System.Runtime.Serialization
クラスの翻訳の最初の行に: エラーをスローラインは次のとおりです。var service = new TranslateService { Key = GetApiKey() };
クラスコードは次のとおりです。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Web;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using Google.Apis.Util;
using Google.Apis.Translate.v2;
using Google.Apis.Translate.v2.Data;
using TranslationsResource = Google.Apis.Translate.v2.Data.TranslationsResource;
public class Translator
{
public static string translate(TranslateInput input)
{
// Create the service.
var service = new TranslateService { Key = GetApiKey() };
string translationResult = "";
// Execute the first translation request.
Console.WriteLine("Translating to '" + input.TargetLanguage + "' ...");
TranslationsListResponse response = service.Translations.List(input.SourceText, input.TargetLanguage).Fetch();
var translations = new List<string>();
foreach (TranslationsResource translation in response.Translations)
{
translationResult = translation.TranslatedText;
}
return translationResult;
}
private static string GetApiKey()
{
return "AIzaSyCjxMe6RKHZzd7xSfSh2pEsBqUdXYm5tA8"; // Enter Your Key
}
}
/// <summary>
/// User input for this example.
/// </summary>
[Description("input")]
public class TranslateInput
{
[Description("text to translate")]
public string SourceText = "Who ate my candy?";
[Description("target language")]
public string TargetLanguage = "fr";
}
エラーは次のとおりです。
は 'Google.Apis、バージョン= 1.1.4497.35846、カルチャニュートラル、PublicKeyToken = = null' アセンブリから型 'Google.Apis.Discovery.FactoryParameterV1_0' をロードできませんでした。
Googleに助けを求めて、プロジェクトタイプをx64プラットフォームに変更しようとしましたが、それは助けになりませんでした。だから私はそれをx86に戻す
私はWindows 7 64bitビジュアルスタジオC#2010プロ.net 4.0プロファイルクライアントを持っています。
何がエラーなのですか?