Main Site Documentation

Is there a way to do LoadLibrary?


#1

Hey, since memory is short in most devices (USBizi mostly), and there is already a way to load and elf file (for RLP), I was thinking why not have something similar (if not identical) to LoadLibrary so that I could store .DLL with managed code on the SD and load use and dispose when fit?

I don’t mind spending cycles on that myself, if there is any relevant documentation.


#2

Check Pyxis 2 source code.


#3

Check out Pyxis

http://www.skewworks.com/products/Pyxis%202


#4

As always bet by ArchitectBot :wink:


#5

There is a class - AppLoader. Check how it loads apps.


#6

here is the wiki for loading assemblies from an SD Card.

http://wiki.tinyclr.com/index.php?title=Dynamic_Assembly_Loading

i think Moondragon used similar way to load an ELF file.

cheers,


#7

Note that you can dynamically LOAD, but unless you load in a separate AppDomain, you can’t dynamically UNLOAD. The code on the wiki doesn’t use a separate AppDomain, there’s a note there that it doesn’t work.

Also, even if you do use a separate AppDomain, there’s no guarantee that you can unload it on NETMF, that’s just how it works on the desktop FW.


#8

I actually got it to load to a new AppDomain and i was able to unload it so it woks BUT… I’m still investigating why it works on one of my Solution but not the other…
the only difference that i have noticed so far is that the pe image of the assembly I’m able to load into a separate AppDomain is a singleton.
maybe someone here can try it and let me know if they can dynamically load a singleton Class into the a new AppDomain…

please create a singleton class and compile it then try to load that using the code from the wiki…into a new AppDomain…
another note: while debugging you may notice that your code stops right after the load method is called, sort of pauses, to make it continue just put a break point anywhere in your code and VS2010 will continue the process… again another one of those things that i can’t explain how and why it happens… the only i was able to make continue is by putting a break after the Code pauses… so please report back if you see similar behavior so we can create a ticket on NETMF…

thank you.


#9

Look at some of the example apps for Pyxis 2 and Gadgetos. Depending on how the class is used it needs to be marked a certain way. If you’re not sure which type to use trial and error will let you know if it needs to be marked MarshalByRef and/or serializable or neither.


#10

The problem I encountered with unloading assemblies in different AppDomains is that my SD card stopped sending proper events for insert and eject. So, my file system never refreshed properly. I asked about this on NetMF forums, but never got an answer:

http://www.netmf.com/forum/default.aspx?g=posts&m=8705#post8705


#11

You’ve got to do things very carefully when working with multiple AppDomains in NETMF.

Whenever you start a new AppDomain, make sure a new thread calls it. Otherwise you’re going to lock up the initial calling thread, this could be your card event issue.