C++ to bytecode compiler for Silverlight CLR?
I'd like to be able to compile a C/C++ library so that it runs within a safe managed runtime in the Silverlight CLR.
There are several tools for doing this with the JVM that allows C++ code to run within a CRT emulation layer (see NestedVM, LLJVM, etc), which effectively allows C++ code to be run within a Java Applet. There's even a tool for this for the Adobe Flash VM (see Alchemy).
However, I can't seem to find any tools like this for the CLR. fyi, the MSVC tools don't seem to allow for this: The /clr:pure
flag will create C++ code that runs in the CLR, but it isn't safe (because the CRT isn't safe) and /clr:safe
requires massive code changes 开发者_高级运维(no native types, etc).
Then I think you are plain out of luck. If your code can't use the /clr:safe flag then it won't be compilable into something that can run in Silverlight. If the C++ is doing something that the CLR does not allow or support, then there is no way around this directly.
Depending what your code does, you could possibly execute it on the server and call that from Silverlight via a web service?
What you're looking for is not inherently possible. The problem is that native C++ types allow direct access to pointers. With pointer access, you can circumvent the .NET security model and compromise the execution environment. It's not just because the CRT is unsafe, it's because pointers are unsafe.
What the original poster wants to do sounds fine to me... but perhaps not possible.
I take it you basically want to be able to run your C++ code in silverlight, without porting it to /clr:safe
A fine and noble pursuit. i'd like to do the same. But as far as I can tell you can't do it :(
The closest method I've seen mentions perhaps targetting the mono clr... and then using that in the clr? That's your nested CRT.
I don't particularly care about if the code runs natively, or not. What I don't want to do is port a muli-million line C/C++ code base to /clr:safe, just so it can run in silverlight.
I think that's what the OP wants :)
I wish him luck :(
精彩评论