Error on invoke a method from an assembly

  • Thread starter Thread starter Marcello G.
  • Start date Start date
M

Marcello G.

I'm begginin to works with the compact framework but I found a a
problem that's making me crazy

I need to invoke a metoth from ax external assembly (a .dll), I open
the assembly, create the object, retrive the proper method, but the
invoke command raise an error.
The stange thing i thate the, the same code (with the same external
assemby copied to the emulator) works porperly in .NET framewok.

Can you please help me!


Here is my code :

Private Sub ExecuteMenuCommand(ByVal DLLName As String, ByVal
PlugInName As String, ByVal MethodName As String)
' Esecuzione di un comando del menù
Dim PIType As Type
Dim OPlugIn As Object

Try

' Apre la DLL
Dim APlugIn As [Assembly] =
[Assembly].LoadFrom(DLLName)

' Estrae il tipo del plugin e lo istanzia
PIType = APlugIn.GetType(PlugInName)
OPlugIn = Activator.CreateInstance(PIType)

' Istanzia l'oggetto PlugIn
Dim mi As MethodInfo = PIType.GetMethod(MethodName)
mi.Invoke(OPlugIn, Nothing) <========= Here
is the error
Catch ex As Exception
MessageBox.Show("Errore nell'esecuzione del comando '"
& MethodName & "' nel PlugIn '" & "' : " & vbCrLf & ex.ToString())
End Try
End Sub

And here is the error desccription :

"System.MissingMethodException: File or assembly name
'Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=B03F5F7F11D50A3A', or one of its dependencies, was not
found.
at System.Reflection.RuntimeMethodInfo.InternalInvoke()
at System.Reflection.RuntimeMethodInfo.InternalInvoke()
at System.Reflection.RuntimeMethodInfo.Invoke()
at System.Reflection.MethodBase.Invoke()
at DynMenuItem.ExecuteMenuCommand()
at DynMenuItem.OnClick()
at System.Windows.Forms.Menu.ProcessMnuProc()
at System.Windows.Forms.Form.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at DeviceApplication1.Prova.Main()

Thanks


Marcello
 
You cannot run desktop dlls (compiled against the full framework) on the
compact framework. Create a *new* smart device project and add your code
files. Do the same for every dependency (dll) that the main project uses.

http://www.danielmoth.com/Blog/2004/09/share-code-if-fullframe_17.html

http://groups.google.com/group/micr....compactframework&q=typeloadexception+desktop

Cheers
Daniel
--
http://www.danielmoth.com/Blog/

I'm begginin to works with the compact framework but I found a a
problem that's making me crazy

I need to invoke a metoth from ax external assembly (a .dll), I open
the assembly, create the object, retrive the proper method, but the
invoke command raise an error.
The stange thing i thate the, the same code (with the same external
assemby copied to the emulator) works porperly in .NET framewok.

Can you please help me!


Here is my code :

Private Sub ExecuteMenuCommand(ByVal DLLName As String, ByVal
PlugInName As String, ByVal MethodName As String)
' Esecuzione di un comando del menù
Dim PIType As Type
Dim OPlugIn As Object

Try

' Apre la DLL
Dim APlugIn As [Assembly] =
[Assembly].LoadFrom(DLLName)

' Estrae il tipo del plugin e lo istanzia
PIType = APlugIn.GetType(PlugInName)
OPlugIn = Activator.CreateInstance(PIType)

' Istanzia l'oggetto PlugIn
Dim mi As MethodInfo = PIType.GetMethod(MethodName)
mi.Invoke(OPlugIn, Nothing) <========= Here
is the error
Catch ex As Exception
MessageBox.Show("Errore nell'esecuzione del comando '"
& MethodName & "' nel PlugIn '" & "' : " & vbCrLf & ex.ToString())
End Try
End Sub

And here is the error desccription :

"System.MissingMethodException: File or assembly name
'Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=B03F5F7F11D50A3A', or one of its dependencies, was not
found.
at System.Reflection.RuntimeMethodInfo.InternalInvoke()
at System.Reflection.RuntimeMethodInfo.InternalInvoke()
at System.Reflection.RuntimeMethodInfo.Invoke()
at System.Reflection.MethodBase.Invoke()
at DynMenuItem.ExecuteMenuCommand()
at DynMenuItem.OnClick()
at System.Windows.Forms.Menu.ProcessMnuProc()
at System.Windows.Forms.Form.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at DeviceApplication1.Prova.Main()

Thanks


Marcello
 
What I meant to say was check that the path of the dll in your
emulator.

If that is fine - then check to see if your dll has the correct
dependencies for the compact framework
 
Thank's Daniel you where right!
Recompling the DLL in the compact framework all started working.

Marcello
 
Back
Top