Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.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# 正在检索CLSID为的组件的COM类工厂(RPC\u E\u调用被拒绝)_C#_Asp.net Mvc_Powerpoint_Office Interop - Fatal编程技术网

C# 正在检索CLSID为的组件的COM类工厂(RPC\u E\u调用被拒绝)

C# 正在检索CLSID为的组件的COM类工厂(RPC\u E\u调用被拒绝),c#,asp.net-mvc,powerpoint,office-interop,C#,Asp.net Mvc,Powerpoint,Office Interop,我正在开发一个ASP.NET MVC网站,其中有一个页面可以下载Interop.PowePoint.dll创建的power point文件。当我在IIS中将网站的一个版本部署到我自己的机器上时,下载停止工作,并从描述中给出错误 这是我的密码: MessageFilter.Register(); // This registers the IOleMessageFilter to handle any threading // errors.

我正在开发一个ASP.NET MVC网站,其中有一个页面可以下载Interop.PowePoint.dll创建的power point文件。当我在IIS中将网站的一个版本部署到我自己的机器上时,下载停止工作,并从描述中给出错误

这是我的密码:

          MessageFilter.Register();
        // This registers the IOleMessageFilter to handle any threading 
        // errors.

        Thread.Sleep(3000);

        //creating powerpoint aaplication
        Application powerPointApplication = new Application();
        //powerPointApplication.Visible = MsoTriState.msoFalse;

        var pptPresentation = powerPointApplication.Presentations.Add(MsoTriState.msoFalse);
        Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout =
            pptPresentation.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];

        //Step5.Insert a slide by calling the Add method on the Presentation.Slides collection, and add some texts to the slide.

        var index = 1;

        var oSlides = pptPresentation.Slides;

        if (model.Configuration.Ratio == "4:3")
        {
            pptPresentation.PageSetup.SlideSize = PpSlideSizeType.ppSlideSizeOnScreen;
        }

        foreach (var slide in model.Slides)
        {
            var oSlide = oSlides.AddSlide(index, customLayout);

            oSlide.FollowMasterBackground = MsoTriState.msoFalse;
            //oSlide.Background.Fill.BackColor.RGB = Convert.ToInt32(ExtractHex(model.Configuration.Background), 16);
            oSlide.Background.Fill.BackColor.RGB = ColorTranslator.ToOle(HexToColor(model.Configuration.Background));

            //content
            var oShape = oSlide.Shapes[2];

            //oShape.LockAspectRatio = MsoTriState.msoTriStateToggle;

            var oTxtFrame = oShape.TextFrame;
            var oTxtRange = oTxtFrame.TextRange;
            oTxtRange.Text = FormatText(slide);
            //oTxtRange.Font.Size = model.Configuration.FontSize;

            oTxtRange.Font.Color.RGB = ColorTranslator.ToOle(HexToColor(model.Configuration.Forecolor));

            oTxtRange.Font.Size = GetFontSize(slide);

            if (model.Configuration.Font != null)
            {
                oTxtRange.Font.Name = model.Configuration.Font;
            }
            //oTxtRange.Font.Bold = MsoTriState.msoTrue;
            oShape.TextEffect.Alignment = MsoTextEffectAlignment.msoTextEffectAlignmentCentered;


            oTxtFrame.HorizontalAnchor = MsoHorizontalAnchor.msoAnchorCenter;
            //oTxtFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;

            var format = oTxtRange.Paragraphs().ParagraphFormat;
            format.Bullet.Type = PpBulletType.ppBulletNone;

            //format.Alignment = PpParagraphAlignment.ppAlignCenter;

            index++;
        }

        //Step6.Save the presentation as a pptx file and close it.
        model.Name = "Praiser.ppt";
        string fileFullPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + model.Name;

        pptPresentation.SaveAs(fileFullPath, PpSaveAsFileType.ppSaveAsOpenXMLPresentation, MsoTriState.msoTriStateMixed);
        pptPresentation.Close();

        powerPointApplication.Quit();

        MessageFilter.Revoke();

        return File(fileFullPath, "application/vnd.ms-powerpoint", model.Name); 

也许这是一个愚蠢的问题,但您是否在遇到此错误的计算机上安装了PowerPoint?Interop.Powerpoint.dll是应用程序和Powerpoint之间的桥梁。如果桥的另一端没有PowerPoint,你就要洗澡了。是的!我已经安装好了。调试应用程序一切正常,但当我发布到IIS时,会发生错误。好的,有时这对每个人来说都不明显。我不是服务员,所以在这里帮不了什么忙。很抱歉