【发布时间】:2014-01-11 20:05:51
【问题描述】:
我一直在尝试使用 Reflector 加载 DLL
Imports System.Reflection
我有一个使用 /CLR 用 C++ 编写的简单 DLL 文件(这是整个文件)
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。
【问题讨论】:
标签: vb.net dll load .net-assembly reflector