Does WinRT under windows 8 metro allow you to dynamically load and execute code? For example, is it possible to download a dll into memory or to isolated storage and run code from it? Could code that JIT compiles a scripting language to native assembly language (e.g. third party browsers) be able to do the same in WinRT, or is it prohibited as an "unsafe" operation?
Is the answer to this question different for "managed" code running in WinRT? For example, in managed code, could you download an assembly from the internet and have it be discoverable in MEF or otherwise be able to load it at runtime? Can you use Reflection.Emit in some form? In C++, can you run assembly code generated at runtime by your application, or dynamically load a DLL at runtime (presumably some form of WinRT DLL)?
Actually, Metro style apps CAN dynamically load and execute code. There are some restrictions; Metro and Desktop apps work a bit differently in key ways.
The mechanisms vary a bit, depending on the caller (LoadPackagedLibrary() Assembly.Load(), etc). One key difference between Metro and Desktop - Metro apps can only dynamically load what's in your app's package graph (your package and s) and system code (that could be otherwise loaded statically).
See my post for some more details http://social.msdn.microsoft.com/Forums/en-US/wingameswithdirectx/thread/d1ebe727-2d10-430e-96af-46964dda8225
Example of dynamic assembly loading from AppX package directory (from MSDN Forums):
The assemblies must be added to the application package. You can't download them from external source.
However, this approach does not work in .NET Native, because everything is merged into a single DLL. You should save a list of assembly names somewhere (in a simple file inside Assets) and call
Assembly.Load
for each item.Example of dynamic assembly listing in debug mode and predefined array of assembly names in release mode (.NET Native tool chain).
No.
No.
It would be prohibited.
No.
No.
No.
No.
Everything you described would allow the safety guarantees of WinRT to be circumvented.
You question is a bit unclear... so some general pointers:
.NET app using among other things WinRT (but NOT the new UI model!)
In this case everything is possible that you today (perhaps not OLEDB) but Reflection etc.
.NET app built for Metro UI
AFAIK this is not possible (see http://blogs.microsoft.co.il/blogs/sasha/archive/2011/09/17/metro-net-framework-profile-windows-tailored.aspx and http://tirania.org/blog/) at least as long as you want to sell via Windows Store... outside of this scope (Windows Store) there might some tricks to circumvent that restriction as already demonstrated by some... but I wouldn't count on that... MAYBE you can use some JavaScript (
eval
etc.) to do something dynamic but I am not sure currentlyTo make it more interesting, IE 10 does in fact do JIT on its js code, so the API is clearly there to allow it.
In general, you cannot load and execute new code in a Metro style app. What you can access is what you ship with the app.
LoadLibrary and GetProcAddress are missing so C++ can't dynamically load code.
Likewise, C# cannot because there is no Assembly.Load.
JavaScript can, but only in the web container and not in the fuller trust portions of the code.
The reason for all this is that the store's security/malware protection would be moot if an app could just load and run arbitrary code.