我正在嘗試從 vb.net 項目訪問 c# 方法。c#項目有以下代碼:using System;using System.Collections.Generic;using System.Linq;using System.Text;using MeF.Client;public class LoginClass{ // lines of code that are giving errors (when commented there’s no error) private ServiceContext context = new ServiceContext(); public string etin; public string appSysId; static void Main(string[] args) { LoginClass.CreateServiceContext(); } //bla, bla, bla}vb.net 項目有這個:Imports AimEFileCorePublic Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim Process As New AimEFileCore.LoginClass Process.CreateServiceContext() End Sub運行代碼時出現以下錯誤System.IO.FileNotFoundException:“無法加載文件或程序集“MeFWCFClient,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”或其依賴項之一。該系統找不到指定的文件引用了 Mef dll!當我評論上面三行時,它就像一個魅力。
3 回答

哈士奇WWW
TA貢獻1799條經驗 獲得超6個贊
看起來您調用的方法是靜態的。你在vb.net中試過這個嗎?
AimEFileCore.LoginClass.CreateServiceContext()
您正在實例化 LoginClass 但沒有定義公共方法 - 至少在您顯示的代碼中沒有定義,所以我假設它包含以下內容:
public static void CreateServiceContext(){ ... }
因為這就是 C# 代碼的建議。

慕的地6264312
TA貢獻1817條經驗 獲得超6個贊
我相信您需要轉到“項目屬性”,References
并檢查是否有引用的 MeFWCFClient(dll)的正確引用。您可以將其添加到此對話框中,您也許可以使用 Nuget,或者只需將其復制到二進制文件夾。
- 3 回答
- 0 關注
- 197 瀏覽
添加回答
舉報
0/150
提交
取消