初始化介面的時候一直報錯,找了很久原因都弄不明白,希望有高手幫忙看看怎么回事。代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using yh_interface;
using System.Reflection;
namespace YH
{
public partial class ff : Form
{
// System.Type yh = Type.GetTypeFromProgID("YinHai.SCMYInterface");
// Object yhObject;
public ff()
{
InitializeComponent();
}
//業務介面函式
public static short li_appcode = -1;
public static string ls_appmsg = "";
public static string a = "";
//初始化介面
public static bool JK_Init()
{
COClass_n_yh_interface YH = new COClass_n_yh_interface();
// System.Type yh = Type.GetTypeFromProgID("YinHai.SCMYInterface");
YH.yh_interface_init(a, li_appcode, ls_appmsg);
if (ff.li_appcode >= 0)
{
return true;
}
return false;
}
#region 初始化
private void button1_Click(object sender, EventArgs e)
{
JK_Init();
}
#endregion
報錯的截圖:
uj5u.com熱心網友回復:
COClass_n_yh_interface里面內容是啥?是自己定義的還是參考的?uj5u.com熱心網友回復:
是參考的,里面的內容不知道。應該不是里面內容的問題,好像是少了一個引數
uj5u.com熱心網友回復:
如果這個dll是用C#寫的話,你用windows自帶的IL反匯編程式看一下里面的建構式方法uj5u.com熱心網友回復:
以管理員模式啟動vs試試…………這種無法創建一般都是權限錯誤導致的uj5u.com熱心網友回復:
你把yinhaisoft 下所有的檔案復制到debug目錄下就可以了,但是你會出現另一個報錯如下圖:
然后就沒有然后了,我被卡在這里進行不下去了,不知道你解決了沒有?
uj5u.com熱心網友回復:
dll是需要放到debug下或者同環境檔案夾下,但是COClass_n_yh_interface.init大概是指標,引數型別可能不對 ,你們這個應該有檔案把,不然不會讓你們做uj5u.com熱心網友回復:
專案要使用x86編譯就行,使用anyCPU就有這個問題,我也是這么解決的轉載請註明出處,本文鏈接:https://www.uj5u.com/net/175492.html
標籤:C#
