Archestra Client Control导入dll文件

时间:2016-06-07 19:22:08

标签: c# dll wonderware

所以我有Wonderware Archestra IDE 4.1。基本上是2015年服务器上的最新和最好的

我有一个名为WordControls的C#类库,它是在我的笔记本电脑上的Visual Studio 2015中创建的。当我构建它时,该版本是一个同名的DLL文件。

我将dll文件复制并粘贴到服务器的Documents文件夹中,它应该像将鼠标移动到左上角并向下钻取一样简单: Galaxy - >导入 - >客户控制

然后从那里我选择我创建的dll文件并单击Ok。然后在默认值上再次单击“确定”。最后它经历了导入过程。除了不是导入文件,我得到的东西略有不同:

“处理文件WordControls.dll .... 从1个文件“

导入总共0个对象

它无法导入dll,我不知道为什么。我之前在2014 Archestra和Visual Studio 2013上的工作之前就完成了这些工作,所以我似乎无法弄清楚我做错了什么。

有没有人有过使用Archestra IDE的客户端控制方面的经验?

当我查看SMC记录器时,我收到以下两个警告:

Microsoft.Office.Interop.Word,Version = 15.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c Dependent File不存在。

在C:\ Users \ vegeto18 \ Documents \ WordControls.dll中找不到控件。

除了我的程序确实使用Microsoft.Office.Interop.Word处理MS文档并且服务器没有MS Office(终端服务器)之外,我不知道该怎么做第一个警告。与Intouch视图应用程序一起部署。

第二部分我不太确定如何解释,因为这是我从笔记本电脑复制并将其粘贴到该文件夹​​后dll所在的位置。

这将是我的代码:

    using System;
    using System.Windows.Forms;
    using Microsoft.Office.Interop.Word;
    using System.IO;

    namespace WordControls
    {
        public partial class DocBrowser : Form
        {
            private System.Windows.Forms.WebBrowser webBrowser1;
            delegate void ConvertDocumentDelegate(string fileName);

            public DocBrowser()
            {
                InitializeComponent();

                // Create the webBrowser control on the UserControl. 
                // This code was moved from the designer for cut and paste
                // ease. 
                webBrowser1 = new System.Windows.Forms.WebBrowser();

                webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
                webBrowser1.Location = new System.Drawing.Point(0, 0);
                webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
                webBrowser1.Name = "webBrowser1";
                webBrowser1.Size = new System.Drawing.Size(532, 514);
                webBrowser1.TabIndex = 0;

                Controls.Add(webBrowser1);

                // set up an event handler to delete our temp file when we're done with it. 
                webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;

            }

            private void Form1_Load(object sender, EventArgs e)
            {
                var url = "http://qualityworkbench/ivscripts/qwbcgi.dll/docfetchraw?db=live&id=1090";

                LoadDocument(url);
            }

            string tempFileName = null;

            public void LoadDocument(string fileName)
            {
                // Call ConvertDocument asynchronously. 
                ConvertDocumentDelegate del = new ConvertDocumentDelegate(ConvertDocument);

                // Call DocumentConversionComplete when the method has completed. 
                del.BeginInvoke(fileName, DocumentConversionComplete, null);
            }

            void ConvertDocument(string fileName)
            {
                object m = System.Reflection.Missing.Value;
                object oldFileName = (object)fileName;            
                object readOnly = (object)false;
                Microsoft.Office.Interop.Word.Application ac = null;

                try
                {
                    // First, create a new Microsoft.Office.Interop.Word.ApplicationClass.
                    ac = new Microsoft.Office.Interop.Word.Application();

                    // Now we open the document.
                    Document doc = ac.Documents.Open(ref oldFileName, ref m, ref readOnly,
                        ref m, ref m, ref m, ref m, ref m, ref m, ref m,
                         ref m, ref m, ref m, ref m, ref m, ref m);

                    // Create a temp file to save the HTML file to. 
                    tempFileName = GetTempFile("html");

                    // Cast these items to object.  The methods we're calling 
                    // only take object types in their method parameters. 
                    object newFileName = (object)tempFileName;

                    // We will be saving this file as HTML format. 
                    object fileType = (object)WdSaveFormat.wdFormatHTML;

                    // Save the file. 
                    doc.SaveAs(ref newFileName, ref fileType,
                        ref m, ref m, ref m, ref m, ref m, ref m, ref m,
                        ref m, ref m, ref m, ref m, ref m, ref m, ref m);

                }
                finally
                {
                    // Make sure we close the application class. 
                    if (ac != null)
                        ac.Quit(ref readOnly, ref m, ref m);
                }
            }

            void DocumentConversionComplete(IAsyncResult result)
            {
                // navigate to our temp file. 
                webBrowser1.Navigate(tempFileName);
            }

            void webBrowser1_DocumentCompleted(object sender,
                WebBrowserDocumentCompletedEventArgs e)
            {
                if (tempFileName != string.Empty)
                {
                    // delete the temp file we created. 
                    File.Delete(tempFileName);

                    // set the tempFileName to an empty string. 
                    tempFileName = string.Empty;
                }
            }

            string GetTempFile(string extension)
            {
                // Uses the Combine, GetTempPath, ChangeExtension, 
                // and GetRandomFile methods of Path to 
                // create a temp file of the extension we're looking for. 
                return Path.Combine(Path.GetTempPath(),
                    Path.ChangeExtension(Path.GetRandomFileName(), extension));
            }

        }
    }

1 个答案:

答案 0 :(得分:1)

我的代码没有任何问题,这是我的项目类型。我在Visual Studio上将其写为窗体应用程序。我原本应该使用Window Forms User Control。这最终解决了我的问题。