使用 "Microsoft Office Document Imaging" 在 Azure Web App 上获取错误

Getting error on Azure Web App using "Microsoft Office Document Imaging"

我正在开发 ASP.net 网络 api (.NET Framework) 并使用 "Microsoft Office Document Imaging" v12。 在我的本地系统上,它工作正常。但后来我将它推送到我的 azure web 应用程序上,我得到了以下错误:

Could not load file or assembly 'Interop.MODI, Version=12.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

我确定,我必须安装 "Microsoft Office Document Imaging"。但是,当我只使用 Azure Web 应用程序 时,我该如何做到这一点?


编辑: 我找到了一个更好的方法来解决我的问题:https://azure.microsoft.com/de-de/services/cognitive-services/computer-vision/

据我所知,我们无权在 Azure Web 应用程序中安装 "Microsoft Office Document Imaging"(使用 sharepoint 安装包)。

Azure web app env作为sanbox,有几个严格的限制和限制,我们不能将它用作azure VM。更详细的可以参考这个article.

如果你还想使用"Microsoft Office Document Imaging",我建议你可以考虑使用我们有完全权限更改环境的azure VM。

此外,我猜你想将文档转换为图像。我建议您可以尝试使用 Aspose.Words for .NET 将文档转换为图像或 PDF。

这个包可以安装在 Nuget 包中。

更多细节,您可以参考下面的测试演示代码。

        string location = Server.MapPath("/exe/");
        Document document = new Document(Server.MapPath("/exe/bbbb.docx"));
        ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
        options.PageCount = 1;

        // Save each page of the document as Png.
        for (int i = 0; i < document.PageCount; i++)
        {
            options.PageIndex = i;
            document.Save(string.Format(location+ @"\out_{0}.png", i), options);
        }

结果: