找不到方法:'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)'

 星浪列兵_505_325 发布于 2023-02-12 12:11

我花了很多时间在我的开发盒上编写这个程序,把它移到我们的生产盒后我得到了下面的错误.仅仅是一个FYI我对安装的内容和安装的内容没有任何控制权,我该如何使其工作?在两台计算机的两个框架下,我们都有v1.0.3705,v1.1.4322,v2.0.50727,v3.0,v3.5,4.0.30319.我用来创建应用程序的程序也是Visual Studio 2013 Pro.

谢谢

有关调用实时(JIT)调试而不是此对话框的详细信息,请参阅此消息的结尾.

***** 例外文本 ******* System.MissingMethodException:找不到方法:'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)'.在
System.Windows.Forms.Button的System.Windows.Forms.Button.OnClick(EventArgs e)的System.Windows.Forms.Control.OnClick(EventArgs e)的C_Sharp_version.Form1.button4_Click(Object sender,EventArgs e)处. System.Windows.Forms.ButtonBase.WndProc上System.Windows.Forms.Control.WndProc(Message&m)的System.Windows.Forms.Control.WmMouseUp(Message&m,MouseButtons按钮,Int32单击)上的OnMouseUp(MouseEventArgs mevent)(消息&m)在System.Windows.Fornd.WandProc上的System.Windows.Forms.Button.WndProc(Message&m),在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&m)处的System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m) System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

***** 加载的程序集 ******* mscorlib汇编版本:4.0.0.0 Win32版本:4.0.30319.239(RTMGDR.030319-2300)CodeBase:file:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib .dll ---------------------------------------- C Sharp version Assembly Version:1.0. 0.0 Win32版本:1.0.0.0 CodeBase:file:/// gordonc $/Desktop/C%20Sharp%20version%20(2).exe ------------------- --------------------- System.Windows.Forms汇编版本:4.0.0.0 Win32版本:4.0.30319.235内置:RTMGDR CodeBase:file:/// C :/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ----------------- ----------------------- System.Drawing程序集版本:4.0.0.0 Win32版本:4.0.30319.1内置:RTMRel CodeBase:file:/// C :/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll --------------------- -------------------系统程序集版本:4.0.0.0 Win32版本:4.0.30319.236内置:RTMGDR CodeBase:fil E:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using Word = Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop.Word;


namespace C_Sharp_version
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void FindAndReplace(Microsoft.Office.Interop.Word.Application doc, object findText, object replaceWithText)
        {
            //options
            object matchCase = false;
            object matchWholeWord = true;
            object matchWildCards = false;
            object matchSoundsLike = false;
            object matchAllWordForms = false;
            object forward = true;
            object format = false;
            object matchKashida = false;
            object matchDiacritics = false;
            object matchAlefHamza = false;
            object matchControl = false;
            object read_only = false;
            object visible = true;
            object replace = 2;
            object wrap = 1;
            //execute find and replace
            doc.Selection.Find.Execute(ref findText, ref matchCase, ref matchWholeWord,
                ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward, ref wrap, ref format, ref replaceWithText, ref replace,
                ref matchKashida, ref matchDiacritics, ref matchAlefHamza, ref matchControl);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openInfDoc = new OpenFileDialog();

            if (openInfDoc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string strInfDocLocation = openInfDoc.FileName;

                MessageBox.Show(strInfDocLocation);
                InfDocLocationtxt.Text = strInfDocLocation; 
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog openNetdoc = new OpenFileDialog();
            if (openNetdoc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string strNetDocLocation = openNetdoc.FileName;

                MessageBox.Show(strNetDocLocation);
                NetDocLocationtxt.Text = strNetDocLocation;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog openChkdoc = new OpenFileDialog();
            if (openChkdoc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string strChkDocLocation = openChkdoc.FileName;

                MessageBox.Show(strChkDocLocation);
                ChkDocLocationtxt.Text = strChkDocLocation;
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            object fileName = Path.Combine(System.Windows.Forms.Application.StartupPath, InfDocLocationtxt.Text);
            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application { Visible = true };
            Microsoft.Office.Interop.Word.Document aDoc = wordApp.Documents.Open(ref fileName, ReadOnly: false, Visible: true);
            aDoc.Activate();
            FindAndReplace(wordApp, "", textBox1.Text);
            FindAndReplace(wordApp, "", textBox2.Text);
            FindAndReplace(wordApp, "", textBox3.Text);
            FindAndReplace(wordApp, "", textBox4.Text);
            FindAndReplace(wordApp, "", textBox5.Text);
            FindAndReplace(wordApp, "", textBox6.Text);
            FindAndReplace(wordApp, "", textBox7.Text);
            FindAndReplace(wordApp, "", textBox8.Text);
            FindAndReplace(wordApp, "", textBox9.Text);


        }

        private void button7_Click(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            object fileName = Path.Combine(System.Windows.Forms.Application.StartupPath, NetDocLocationtxt.Text);
            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application { Visible = true };
            Microsoft.Office.Interop.Word.Document aDoc = wordApp.Documents.Open(ref fileName, ReadOnly: false, Visible: true);
            aDoc.Activate();
            FindAndReplace(wordApp, "", textBox1.Text);
            FindAndReplace(wordApp, "", textBox2.Text);
            FindAndReplace(wordApp, "", textBox3.Text);
            FindAndReplace(wordApp, "", textBox4.Text);
            FindAndReplace(wordApp, "", textBox5.Text);
            FindAndReplace(wordApp, "", textBox6.Text);
            FindAndReplace(wordApp, "", textBox7.Text);
            FindAndReplace(wordApp, "", textBox8.Text);
            FindAndReplace(wordApp, "", textBox9.Text);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            object fileName = Path.Combine(System.Windows.Forms.Application.StartupPath, ChkDocLocationtxt.Text);
            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application { Visible = true };
            Microsoft.Office.Interop.Word.Document aDoc = wordApp.Documents.Open(ref fileName, ReadOnly: false, Visible: true);
            aDoc.Activate();
            FindAndReplace(wordApp, "", textBox1.Text);
            FindAndReplace(wordApp, "", textBox2.Text);
            FindAndReplace(wordApp, "", textBox3.Text);
            FindAndReplace(wordApp, "", textBox4.Text);
            FindAndReplace(wordApp, "", textBox5.Text);
            FindAndReplace(wordApp, "", textBox6.Text);
            FindAndReplace(wordApp, "", textBox7.Text);
            FindAndReplace(wordApp, "", textBox8.Text);
            FindAndReplace(wordApp, "", textBox9.Text);
        }


    }
}

Sudhakar Til.. 16

在我看来这是一个.NET Framework compatibility问题.

问题:您已在本地计算机上开发了应用程序,其版本较高,.NET Framework并在具有较低版本的远程PC上运行相同版本.NET Framework.

注意:如果您将应用程序定位为在其Heigher版本上.NET Framework运行,则不会在较低版本上运行.

解决方案:您需要将其定位到.NET Framework远程PC上可用的较低版本以在远程PC上运行.

第1步: 右键单击project- 选择properties

第2步:Target Frameworkfrom 更改.NET Framework x.x.NET Framework x.y.

注意:这里x.x是heigher和x.y更低版本的远程PC或更低版本.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有