Framework 4.5 I am trying to load my DLL directly from my resources, i have very specific reasons on why i need my DLL loaded this way.
How can i get this method to work? & what am i doing wrong?
VB.net @ ApplicationEvents.vb source
Private Sub AppStart(ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf ResolveAssemblies
End Sub
Private Function ResolveAssemblies(sender As Object, e As System.ResolveEventArgs) As Reflection.Assembly
Dim desiredAssembly = New Reflection.AssemblyName(e.Name)
If desiredAssembly.Name = "ASSEMBLE.REM" Then
Dim assembly1 As System.Reflection.Assembly = Reflection.Assembly.Load(My.Resources.Attatch_standard)
Dim t As Type = assembly1.GetType("ASSEMBLE.REM")
Dim c As Object = Activator.CreateInstance(t)
MsgBox(desiredAssembly.Name)
Return Reflection.Assembly.Load(My.Resources.Attatch_standard) 'replace with your assembly's resource name
Else
Return Nothing
End If
End Function
C++ DLL source
#include <Windows.h>
namespace ASSEMBLE{
extern "C" __declspec(dllexport) class REM {
public:
int area() {
MessageBoxA(NULL, "Attached", "Attached!", MB_OK);
return 1;
}
};
}