1
我已經嘗試使用/ CLR加載使用反射VB.net負載DLL
Imports System.Reflection
一個DLL我有一個簡單的DLL文件用C++編寫(這是整個文件)
using namespace System;
namespace ASSEMBLE{
public class REM{
public:
int VALUE(){
return 100;
}
};
};
而且在我的VB.net比唐單擊事件我有
Dim dllPath As String = "C:\Users\richard\Documents\Visual Studio 2012\Projects\link\link\bin\Release\dlltest.dll"
' load the assembly
Dim assembly1 As System.Reflection.Assembly = Assembly.LoadFrom(dllPath)
' get the type
Dim t As Type = assembly1.GetType("ASSEMBLE.REM")
' create an instance and add it.
Dim c As Object = Activator.CreateInstance(t)
MsgBox(t.InvokeMember("VAULE", BindingFlags.Default Or BindingFlags.InvokeMethod, Nothing, c, {}))
當事件觸發(即我加載DLL)。我得到的錯誤:
Method 'ASSEMBLE.REM.VALUE' not found
使用:
<DllImport("DLL.dll")> Public Shared Function VALUE() As Integer
End Function
是不是一種選擇。我需要在運行時加載DLL。