Assembly.Loadfrom throws an Arguement Exception

G

Greg Behrendt

I am writing an application for a mobile device (Pocket Pc
2002) which has a small "Loader Application" which loads
an assembly from a virtual directory on a web server. This
way I can update the application and it is automatically
distributed to the mobile devices.

I am using VS2003, I create a download application using a
Smart Device project and set the project type to "class
library". This class just shows a form with a lable on it.
I build the project and copy the DLL to a virtual
directory on my web server. I create another application
to load the download app, again I use the Smart Device
Project but this time I set the project type to "Windows
Application". The loader app has a form with a button, in
the button_click event I have put your code:-

Dim a As [Assembly]
Dim sURL As String
= "http://192.168.4.152/downloads/DownloadApp.dll"

Try
a = [Assembly].LoadFrom(sURL)

Catch ex As System.ArgumentNullException
MsgBox(ex.Message)
Exit Sub
Catch ex As System.ArgumentOutOfRangeException
MsgBox(ex.Message)
Exit Sub
Catch ex As System.ArgumentException
MsgBox(ex.Message)
Exit Sub
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try



Dim appForm As Form = a.CreateInstance
("DownloadApp.Form1")

appForm.Show()


When I launch the loader app in the emulator and the code
hits the loadfrom method I get the Arguement Exception.
If I launch IE on the emulator I can browse the virtual
directory where the dll is so the emulator can see the web
server.

This same code works great as a standard windows
application but not as a mobile application. Havs anyone
tried this with the Compact Framework?

Any help you can offer would be appreciated.

Greg Behrendt
 
A

Alex Feinman [MVP]

What you are trying to do will require CIFS that does not exist on CE
platform. The fact that IE can browse your vistual directory has nothing to
do with being or not being able to open web documents through filesystem
calls.

You need to download the assembly to the local directory using
HttpWebRequest class and then use local filesystem-based path
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top