Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将Google Admin SDK部署到Azure云服务_C#_Azure_Google Api_Google Admin Sdk_Google Api Dotnet Client - Fatal编程技术网

C# 如何将Google Admin SDK部署到Azure云服务

C# 如何将Google Admin SDK部署到Azure云服务,c#,azure,google-api,google-admin-sdk,google-api-dotnet-client,C#,Azure,Google Api,Google Admin Sdk,Google Api Dotnet Client,遵循ASP.NET MVC示例,我在web应用程序中实现了Google Admin SDK,这样我就可以使用目录服务获取与组织单位关联的组织单位和/或用户列表 在本地一切都很好(auth回调可以工作,因为我利用它来点击本地框),但是当我部署到MS Azure中的云服务时,应用程序将无法启动,并且我在事件日志中看到以下错误: 无法创建角色入口点:System.TypeLoadException:由于以下异常,无法加载角色入口点: --System.IO.FileLoadException:无法加载

遵循ASP.NET MVC示例,我在web应用程序中实现了Google Admin SDK,这样我就可以使用目录服务获取与组织单位关联的组织单位和/或用户列表

在本地一切都很好(auth回调可以工作,因为我利用它来点击本地框),但是当我部署到MS Azure中的云服务时,应用程序将无法启动,并且我在事件日志中看到以下错误:

无法创建角色入口点:System.TypeLoadException:由于以下异常,无法加载角色入口点: --System.IO.FileLoadException:无法加载文件或程序集“System.Web.Mvc,版本=4.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集清单定义与程序集引用不匹配。(来自HRESULT的异常:0x8013100) 文件名:“System.Web.Mvc,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”

我在.NET 4.5 web应用程序中使用ASP.NET MVC 5.2.3版,并在我的web.config中使用下面的设置。我不清楚4.0.0.0版的这个显式引用是从哪里来的,但是我已经重新部署了我的应用程序,有没有对Google API库的引用,以及错误 当我引用GoogleAPI库时肯定会发生

<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
有人知道Azure部署失败的原因以及引用System.Web.MVC Version=4.0.0.0的原因/位置吗

public class AppFlowMetadata : FlowMetadata
    {
        public AppFlowMetadata()
        {
        }

    private static readonly IAuthorizationCodeFlow flow =
    new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
    {
        ClientSecrets = new ClientSecrets
        {
            ClientId = "CLIENT-ID",
            ClientSecret = "CLIENT-SECRET"
        },
        Scopes = new[] { DirectoryService.Scope.AdminDirectoryOrgunit, DirectoryService.Scope.AdminDirectoryUser },
        DataStore = new GoogleDBDataStore()
    });

    public override string GetUserId(Controller controller)
    {
        var user = controller.Session["user"] as USER;

        if (user != null)
        {
            return user.UserID.ToString();
        }
        else
        {
            return null;
        }
    }

    public override IAuthorizationCodeFlow Flow
    {
        get { return flow; }
    }
}
你可以从中得到答案。阐述了其产生的根本原因和解决办法。以下是博客中的片段

解决方案:

1) 打开位于项目bin文件夹中的.dll.config

2) 检查是否存在所需的BindingRedirect条目。如果没有,请遵循以下两个选项之一:

  • 复制web.config或app.config内容(考虑以下内容之一) 这两个配置文件包含您需要的信息)和 将其粘贴到.dll.config文件中

  • 手动创建程序集绑定条目:

3) 将.dll.config文件添加到解决方案中(与web.config或app.config的级别相同),并将“复制到输出目录”属性设置为“始终复制”

根本原因

通常,当向项目中添加新程序集时,Visual Studio会自动在web.config(web角色)或app.config(工作者角色)中创建bindingRedirect条目,以避免出现错误的程序集版本问题

但是,在Azure云服务中,来自web.config和app.config的程序集绑定无效,因为WaIISHost(web角色)和WaWorkerHost(工作角色)无法读取这两个配置文件,而是读取.dll.config文件,这就是程序集绑定配置所需的文件

有人知道Azure部署失败的原因以及引用System.Web.MVC Version=4.0.0.0的原因/位置吗

public class AppFlowMetadata : FlowMetadata
    {
        public AppFlowMetadata()
        {
        }

    private static readonly IAuthorizationCodeFlow flow =
    new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
    {
        ClientSecrets = new ClientSecrets
        {
            ClientId = "CLIENT-ID",
            ClientSecret = "CLIENT-SECRET"
        },
        Scopes = new[] { DirectoryService.Scope.AdminDirectoryOrgunit, DirectoryService.Scope.AdminDirectoryUser },
        DataStore = new GoogleDBDataStore()
    });

    public override string GetUserId(Controller controller)
    {
        var user = controller.Session["user"] as USER;

        if (user != null)
        {
            return user.UserID.ToString();
        }
        else
        {
            return null;
        }
    }

    public override IAuthorizationCodeFlow Flow
    {
        get { return flow; }
    }
}
你可以从中得到答案。阐述了其产生的根本原因和解决办法。以下是博客中的片段

解决方案:

1) 打开位于项目bin文件夹中的.dll.config

2) 检查是否存在所需的BindingRedirect条目。如果没有,请遵循以下两个选项之一:

  • 复制web.config或app.config内容(考虑以下内容之一) 这两个配置文件包含您需要的信息)和 将其粘贴到.dll.config文件中

  • 手动创建程序集绑定条目:

3) 将.dll.config文件添加到解决方案中(与web.config或app.config的级别相同),并将“复制到输出目录”属性设置为“始终复制”

根本原因

通常,当向项目中添加新程序集时,Visual Studio会自动在web.config(web角色)或app.config(工作者角色)中创建bindingRedirect条目,以避免出现错误的程序集版本问题

但是,在Azure云服务中,来自web.config和app.config的程序集绑定无效,因为WaIISHost(web角色)和WaWorkerHost(工作角色)无法读取这两个配置文件,而是读取.dll.config文件,这就是程序集绑定配置所需的文件


绑定重定向出现在#2中(它看起来就像web.config),然后是上面的#3,一切都很好-很好的信息。绑定重定向出现在#2中(它看起来就像web.config),然后是上面的#3,一切都很好-很好的信息。