简体   繁体   English

通过 C# 从 powerpoint 幻灯片创建视频 throws 远程过程调用失败。 (HRESULT 异常:0x800706BE)

[英]Create video from powerpoint slides via C# throws The remote procedure call failed. (Exception from HRESULT: 0x800706BE)

I have a Windows desktop C# app which is to export user's pptx to mp4 programmatically.我有一个 Windows 桌面 C# 应用程序,它以编程方式将用户的 pptx 导出到 mp4。

I have code here:我这里有代码:

try
{
    Application application = new Microsoft.Office.Interop.PowerPoint.Application();

    Presentation ppt = application.Presentations.Open("myppt.pptx", MsoTriState.msoFalse,  
    MsoTriState.msoFalse, MsoTriState.msoFalse);

    ppt.CreateVideo("myppt.mp4");

}
catch (Exception ex)
{
    logger.Error(ex.Message);
}

Everything works fine and video is created successfully with Powerpoint 2016 and older version Office 365 powerpoint.一切正常,使用 Powerpoint 2016 和旧版 Office 365 powerpoint 成功创建视频。 However after I upgraded Office 365 to latest version 2203 (15028.20160), CreateVideo() always failed and throws exception: "The remote procedure call failed"但是,在我将 Office 365 升级到最新版本 2203 (15028.20160) 后,CreateVideo() 总是失败并引发异常:“远程过程调用失败”

System.Runtime.InteropServices.COMException (0x800706BE): 遠端程序呼叫失敗。 (發生例外狀況於 HRESULT: 0x800706BE)
於 Microsoft.Office.Interop.PowerPoint._Presentation.CreateVideo(String FileName, Boolean UseTimingsAndNarrations, Int32 DefaultSlideDuration, Int32 VertResolution, Int32 FramesPerSecond, Int32 Quality) 

I have also tried Presentation.SaveCopyAs(...) and Presentation.Slides[x].Export(...) and these functions work fine.我也尝试过 Presentation.SaveCopyAs(...) 和 Presentation.Slides[x].Export(...) 并且这些函数工作正常。

Any help would be appreciated.任何帮助,将不胜感激。

Update:更新:

CreateVideo() works if set "WithWindow" parameter to true in Presentation ppt = application.Presentations.Open("myppt.pptx", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState. msoTrue )如果在 Presentation ppt = application.Presentations.Open("myppt.pptx", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue ) 中将“ WithWindow ”参数设置为 true,则 CreateVideo() 有效

But I don't know the reason...但是不知道是什么原因...

Use the Office Deployment Tool to roll back to a prior version of Office where the long-established behavior you're depending on worked. 使用 Office 部署工具回滚到以前版本的 Office,在该版本中,您所依赖的长期存在的行为有效。 They broke it in release 2203, so rolling back to 2202 or earlier will fix it.他们在版本 2203 中破坏了它,因此回滚到 2202 或更早版本将修复它。

This config.xml file works:这个config.xml文件有效:

<Configuration>
  <Updates Enabled="TRUE" TargetVersion="16.0.14931.20132"/>
</Configuration>

System.Runtime.InteropServices.COMException (0x800706BE) System.Runtime.InteropServices.COMException (0x800706BE)

This exception typically indicates that you trying to automate PowerPoint from a web service or ASP.NET application.此异常通常表示您试图通过 web 服务或 ASP.NET 应用程序自动执行 PowerPoint。

The Considerations for server-side Automation of Office article states the following for that scenario: 服务器端自动化 Office 文章的注意事项针对该场景陈述了以下内容:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment. Microsoft 目前不建议也不支持来自任何无人值守、非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务)的 Microsoft Office 应用程序自动化,因为 Office 可能表现出不稳定的行为和/或死锁当 Office 在此环境中运行时。

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution.如果您正在构建在服务器端上下文中运行的解决方案,您应该尝试使用已针对无人值守执行进行安全处理的组件。 Or, you should try to find alternatives that allow at least part of the code to run client-side.或者,您应该尝试找到至少允许部分代码在客户端运行的替代方案。 If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully.如果您使用来自服务器端解决方案的 Office 应用程序,该应用程序将缺少许多成功运行所必需的功能。 Additionally, you will be taking risks with the stability of your overall solution.此外,您将承担整体解决方案稳定性的风险。

You may consider using the Open XML SDK if you deal with open XML documents or consider using third-party components designed for the server-side execution.如果您处理打开的 XML 文档,您可以考虑使用Open XML SDK或考虑使用专为服务器端执行而设计的第三方组件。

It would be better if your app did not depend on MS Office.如果您的应用程序不依赖于 MS Office 会更好。 Aspose.Slides Cloud SDK for .NET can provide such a requirement. Aspose.Slides Cloud SDK for .NET可以提供这样的需求。 It does not require PowerPoint installed.它不需要安装 PowerPoint。 This product provides a REST-based API for presentation processing.本产品提供基于 REST 的 API 用于演示处理。 It is a paid product, but you can make 150 free API calls per month for experimentation, learning, and any other purpose.它是付费产品,但您每月可以免费拨打 150 次 API 电话,用于实验、学习和任何其他目的。

The following code example shows you how to convert a presentation to a video file using Aspose.Slides Cloud SDK for .NET:下面的代码示例向您展示了如何使用 Aspose.Slides Cloud SDK for .NET 将演示文稿转换为视频文件:

var slidesApi = new SlidesApi("my_client_id", "my_client_secret");

// Set options for the output video.
var videoOptions = new VideoExportOptions
{
    VideoResolutionType = VideoExportOptions.VideoResolutionTypeEnum.FullHD
};

// Convert a presentation file to a video file.
using var presentationStream = File.OpenRead("example.pptx");
using var videoStream = slidesApi.Convert(presentationStream, ExportFormat.Mpeg4, options: videoOptions);

// Save the result to a file.
using var outputStream = File.Create("output.mp4");
videoStream.CopyTo(outputStream);

Sometimes it is necessary to convert presentations to videos without any code.有时需要在没有任何代码的情况下将演示文稿转换为视频。 For such cases, you can use a free PowerPoint to Video Converter .对于这种情况,您可以使用免费的PowerPoint to Video Converter

I work as a Support Developer at Aspose.我在 Aspose 担任支持开发人员。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WMI:RPC服务器不可用。 (尝试连接到远程计算机时抛出HRESULT异常:0x800706BA) - WMI: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) throws when try to connect to remote machine RPC服务器不可用。 连接到远程计算机时(来自HRESULT的异常:0x800706BA) - The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) when connecting to remote computer LDAP 从域外重置密码。网络 C# 错误:RPC 服务器不可用。 (hresult 的异常:0x800706ba) - LDAP reset password from outside the domain network C# Error: RPC server is unavailable. (exception from hresult: 0x800706ba) System.Runtime.InteropServices.COMException(0x800706BA):RPC服务器不可用。 (HRESULT异常:0x800706BA) - System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 当我从C#调用存储过程时,它将引发异常 - When I call a stored procedure from C# it throws an exception WMI RPC服务器不可用。 (来自HRESULT的异常:0x800706BA) - WMI The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) RPC服务器不可用。 (来自HRESULT的异常:0x800706BA)-Excel - The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) - Excel 连接尝试失败来自HRESULT的异常:0x8007274C - A connection attempt failed Exception from HRESULT: 0x8007274C 如何解决异常:呼叫被被叫方拒绝。 (来自 HRESULT 的异常:0x80010001 (RPC_E_CALL_REJECTED))在 C# 中? - how to solve Exception:Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) in C#? HRESULT的C#Winforms异常:0x80040154 - C# Winforms Exception from HRESULT: 0x80040154
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM