Azure功能"无法找到程序集"

时间:2017-08-23 14:51:40

标签: c# .net azure nuget azure-functions

我一直在试用新的Visual Studio 2017 Azure功能工具,而且我遇到了问题。

尝试从Azure函数中的Nuget包PowerOfficeGoSDK初始化类时,我收到SerializationException:

var authorizationSettings = new AuthorizationSettings
{
    ApplicationKey = applicationKeyGuid,
    ClientKey = clientKeyGuid,
    TokenStore = new BasicTokenStore("my.tokenstore")
};

var goApi = new Go(authorizationSettings);
  

System.Runtime.Serialization.SerializationException:无法找到程序集' GoApi,Version = 1.5.1.0,Culture = neutral,PublicKeyToken = null'。

代码使用各种其他Nuget软件包,如Microsoft.Azure.KeyVault,没有任何问题。我已经使用Kudu检查了该函数的bin文件夹,并且GoApi.dll文件就在那里。

任何人都知道可能导致异常的原因吗?

1 个答案:

答案 0 :(得分:0)

我不熟悉PowerOfficeGoSDK,但根据我的测试,可以在Azure功能中加载PowerOfficeGoSDK。如果可能的话,请尝试重新发布或创建一个新功能应用程序再次测试。

以下是我的详细步骤:

1.使用Visual Studio 2017创建新的Azure功能项目

2.根据PowerOfficeGoSDK依赖关系,我们需要将newtonsoft.json和Microsoft.Data.Edm更新为以下版本

Microsoft.Data.Edm (>= 5.8.2) 
Newtonsoft.Json (>= 10.0.2) 

注意:在Azure功能中使用Newtonsoft.Json版本10+有an issue

3.添加timetrigger函数并在local.settings.json文件中配置存储连接字符串。

[FunctionName("AzureFunction")]
public static void Run([TimerTrigger("0 */2 * * * *")]TimerInfo myTimer, TraceWriter log)
{
    log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
    try
      {
         var authorizationSettings = new AuthorizationSettings
         {
            ApplicationKey = Guid.NewGuid().ToString(), //I have no application key
            ClientKey = Guid.NewGuid().ToString(), //I have no client key
            TokenStore = new BasicTokenStore("my.tokenstore")
          };
          var goApi = new Go(authorizationSettings);
        }
        catch (Exception e)
        {
           log.Info($"Exception:{e.Message}"); 
        }

        log.Info($"C# Timer trigger function Finished at: {DateTime.Now}");
}

4.使用Visual Studio将其发布到Azure,并检查Azure门户的结果。

注意:我没有应用程序和客户端密钥,因此我得到异常无效的ApplicationKey或ClientKey 它是预期

enter image description here