I am making windows 8 , c#/xaml app. Is it possible to compile and run a java console program like " hello world"?
Since winRt apps cannot use System.Diagnostics.Process then it cannot figure how to compile and run it. Or if compile is not possible, just being able to run a .class file is fine.
I have tried useing System.Diagnostics.Process to open cmd to compile but that class isn't supported.
Thanks for any advice.
There's certainly not an elegant or intended (& documented) way to launch a process like you describe from a Windows Store application (it's intentionally locked down and there is no "command prompt for the new Windows store UI apps). There are some that suggest that there may be a way via CoCreateInstanceFromApp, but the documentation now reads as if that API only works for a limited number of Microsoft built COM objects.
While you can launch other installed Windows Store applications, the Java compiler will definitely not be one of those without a significant and unusual repackaging by Oracle (or some third party). While it's possible that someone is working on that, it would seem unlikely (given the limited need for such functionality).
Depending on the nature of the Java code, you may want to look for a Java interpreters that could be embedded within your application, and call it directly, especially if the Java code is trivial.
Your application requirements would suggest that a traditional Windows desktop application would be a better fit.
Related
I'm wondering if it's possible for a Xamarin application (all the platforms : Android, iOS, Windows Phone) to detect and load assemblies at runtime.
This is the kind of thing that I already did in WPF, and I'd like to use those modules (maybe with some modifications) in a Xamarin app.
I've spent yesterday looking for info online, and today I tried to implement a solution, but without success.
Prism seemed to be a way to do it, but it works only in WPF.
The restriction which makes this difficult is that I don't know at compile time any information about the assemblies. No names, no versions, no classes.
I can put the name and the version in the filename, and maybe find the classes by reflection. Using an interface as entry point (Prism use this), I should be able to do it.
Do you have any thoughts about this challenge ?
Thank you very much !
iOS: No
Apple does not allow code that was not bundled into the app at signing time to be executed, thus no on-the-fly Jit'ing of CIL allowed. The only exception to this is Javascript code that is run via their Nitro JavaScript Engine.
Android: Yes
Google allows just about anything you can think of, for better or worse ;-)
Windows Phone: No
All code must be signed as part of the Microsoft Store' App Ingestion process and thus you can not dynamically load assemblies later
Note: If this is a hard requirement for your app, you should look at hybrid mobile apps, like Cordova/Ionic, where you can perform a hot push to roll out new features, bugs fixes, etc... Besides self-hosting those hot pushes, various vendors support hosting of those, even Microsoft Azure has a full versioning publication system for this. Of course you would most likely be coding in JavaScript (or some trans-compiled variant).
I've read that applications which are being developed using Mono are deployed with a MonoRuntime that works similar as ART, interprets the C# code, executes them etc. I assume Unity and Xamarin both does this.
What is strange for me is that theoretically I could write a runtime and ship it with my app? But that is supposed to be next to the runtime, below the application framework? How can the sandboxing let this happen?
I assume this might be the solution to my confusion, but I struggle understanding it.
What am I missing here?
Thanks in advance
First think about how NDK/JNI apps work on Android. They are launched from standard Android Java code run via ART/Dalvik and use JNI calls into C/C++ code. The process is still within the standard Android 'sandbox' but has additional lower level access to libraries provided by Android NDK headers. As that code is written in C/C++ it can be performant/cross system compatible.
So to answer:
But that is supposed to be next to the runtime, below the application framework?
I would argue no, at least you aren't really below the Android application framework. The MonoRuntime is started from Android and can use any of the 'Standard Libraries' which are exposed either via a JNI wrapper to the Android Java side or by a NDK header.
If you look at the below diagram you'll see 'Standard Libraries' which can be OpenGL ES which has a Android Java API and OpenSL ES which exposes more detail in NDK than the Android Java media api.
I could write a runtime and ship it with my app?
Yes you could, although you may want to define clearly what you mean by 'runtime'. If you are pre-compiled you can strip out unnecessary classes/modules which I believe Mono does.
How can the sandboxing let this happen?
You are still in the sandbox. Nothing prevents you from writing your own interpreter / Virtual Machine written in C/C++, interfacing the Android framework through standard JNI/NDK calls, and adding it to your own APK. Regardless you are still limited to what the Android framework/runtime allows for apps along with same process restrictions and limitations.
Does anybody of you guys have experiences with including a C#-based Console Application in a C#-based Universal Windows App?
The reason why I'm asking: I've an already exsisting Console Application developed by another developer. This Application includes a database with all the queries which I need for my App.
The problem: When I try to include the CA in my UWA project many commands like
private global::System.Runtime.InteropServices.HandleRef
throw new global::System.ApplicationException
don't get identified by VS2015.
Is there a way to let the UWA project identify CA commands? For example with adding an external CA-library or something like that.
Thank you!
You can't combine full .NET (console, winforms, WPF) assemblies with an UWP app, as they're different .NET frameworks. For more details, please read this reply. Part of the code is shareable in a Portable Class Library (PCL), but most likely not all of the code you've written.
Possible solutions:
Create an API (yourself or with the other developer) to expose the functionality needed over a (preferably) REST api.
Find a way to cheat the system. Example: launch a file (associated to the console application) with the Launcher api and output the results to a text file on disk, which you then read from your UWP app.
The first one is guaranteed to work. You might find a way to cheat the system for the second 'solution', but there's no guarantee that it won't break in the future when Windows 10 gets updated (experienced that myself for another 'hack' on the upgrade between Windows 8 and 8.1).
Is it possible to generate any sort of executable from within Windows RT and .Net 4.5? In the desktop I know CSharpCodeProvider could be used, but it seems to not be allowed in Windows RT. The goal is to make an IDE for C#.
I haven't played with it myself, but I think Project Roslyn would be a good fit. You should be able to call those APIs from a WinRT front end, I think.
WinRT is not intended (as of today), to create such kind of applications, the closest is the eval function on Javascript, but it's the only one.
I'm a beginner in programming. I've just made a program called "Guessing Game". And it seems to work fine. Can I integrate it into a website? The CMS that I'm using is Mambo.
===
additional info's
Thanks for all your suggestions.
I still don't have any background about Silverlight, WPF and Java Script which I think sounds good. I'm using Windows and I programmed my "Guessing Game" from Microsoft Visual Studio 2008 and it's using Window application forms.
Yes I guess, for the moment I let it be and start to learn Silverlight or Java Script so that I can integrate it on my website:-)
Thanks for all your input guys:-)
Cheers
A standalone executable cannot be directly integrated into a website. You have a few choices though:
Allow your users to download the executable and run it locally for themselves
Rewrite your program in JavaScript to have it run directly inside of an HTML page, though this could obviously involve a fair amount of reworking
Use Microsoft's Silverlight technology, which allows you to code in C# and produce a web-based frontend similar to Adobe Flash. Your program logic should remain the same and you should only have to change the UI code. In fact if you're already using WPF for the front end, the transition will be even easier.
There are several questions that you still need to answer.
What is your server running? If its not Windows, your exe will not run at all unless it is compatible with Mono or a similar framework for your server's operating system.
How does your "Guessing game" interact with the user? If it is through a WinForms GUI, it will you will not be able to use that GUI on the web. If your game is a WPF application your easiest route may be to port it to Silverlight and serve it up on a web page.
It is typically not trivial to make a regular windows application run in a web environment since on on the web you are really running in the browser, not on Windows.
Yes - in general, when you're talking about software, anything is possible. The question is, how difficult will it be?
To understand that, you have to give us more details about "Guessing Game" including how it is designed, what it's interfaces are, how readily extensible it is, and how prepared you are to change or extend it.
For example, if it is a Windows Forms GUI app, then it will be diifficult to integrate into a web app. If it is a console app, then it will be a little easier. If you can modify it to run as a Windows Service, then a little easier. If you can modify it to accept input from the network (as opposed to getting input solely from the keyboard + mouse), still easier.
You may be able to use reflection to load your assembly into the web application, but most likely, the answer is no.
Your best solution is probably to re-write the game in javascript.
The short answer to your question is now. I'm presuming that since you're running Mambo you're web environment is a LAMP stack. However, you're "Guessing Game" is most likely a Windows application from the sound of it. For a beginner in programming, there is no integration path you're going to be able to take that will allow you to have your game running on your website.
However, here are avenues you can take, which will require a significant amount of time to learn. I'm not saying you shouldn't take time to learn, by all means you should! I'm simply trying to illustrate the fact that this is not something that is going to be doable in a couple of hours.
Silverlight - allows you to run C# code with a WPF like interface on your client's browser and can integrate with your web site through javascript.
Let your client download it from your website and run it off of their PC. This would actually be fairly trivial and would be your quickest option, but it sounds like it's not the kind of integration you were looking for.