Get 'Normal' .NET Classes to work on Windows 8 - c#

I normally write a lot of C#/.NET applications, so I figured I'd try out that combination for writing a Windows Store app first. However, I've been having a lot of trouble lately seeing as the classes seem to have developed a habit of disappearing. I've currently tried to write a simple FTP app, but the FTPWebRequest class is missing, and when I tried to create a Metro-Style terminal for Cmd, I noticed the Process class is missing. Is there any way of getting these classes back?

In essence, you can't. There may be some related WinRT classes available, but WinRT apps are sandboxed and don't necessarily have the same flexibility as your normal desktop app.
See for more details: http://blogs.msdn.com/b/b8/archive/2012/05/17/delivering-reliable-and-trustworthy-metro-style-apps.aspx

No, you can't get them back because they aren't there. When you create a Windows Store app, you are targeting a different version of the framework. Another example is when you target the .NET compact framework, the same calls will not be available as in the "normal" framework.

Related

Is it possible to run a .Net UWP Class Library on Azure?

I thought up an idea for a website that would involve some video editing happening on the web server. Microsoft UWP has a library that does the video editing functions I'm looking to perform... Amazing!!
My problem is I don't know if it's possible to get my website to run UWP code on Azure. Web Jobs seem like what I'd prefer to use to kick off this code, but web jobs don't appear to be able to run UWP code and without UWP code I don't see a library that can perform the video editing I'd like to do. Does anybody know if it's possible to run UWP code on Azure? If so, how?
I don't think WebJobs are especially suited for this scenario. They are part of the WebApp platform as a service offering that abstracts the underlying operating system for you to be able to focus on building the code itself and deploy as easily as possible.
UWP on the other hand is a Windows-specific app platform which has many requirements including running on Windows 10. Because you don't know which concrete operating system the web app will run on, it is not easy to say if the APIs would work.
That said, you could theoretically use UWP APIs in a web app as well, because there is a UwpDesktop NuGet package that allows it mainly targeted for desktop apps. It is a long shot but you can certainly try it.
As a preferable solution, I would still look to find another library that suits your needs, as the choice on NuGet is pretty broad and one of those should be sufficient.
I would suggest taking a look at azure functions
These have about the same working as webjobs, however expand beyond the limitations of webjobs. These are also more versatile in what they can do and how they can be created.
webjobs vs functions

Windows UWP - Dynamically Load Assembly In Side Loaded App

It seems to be a deliberate security of Windows 10 Store apps that assemblies not be allowed to be loaded at runtime. I think that this feature is massive overkill and stops UWP development dead in its tracks. However, if it is a rock solid design decision by Microsoft, there is nothing we can do to argue with it.
Instead, I'd like to ask the question, assuming that you were not deploying your UWP app to the store, would it still be impossible to load an assembly dynamically? If it's possible, how?
Please see this feature request: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/18145291-dynamically-load-assembly
Regardless of what environment you deploy your UWP application to, the UWP API will be the same. Choosing to deploy your app internally instead of to the Windows Store will not enable non-supported API features, eg. Assembly.Load().
It seems as though the answer to this question is no.
The game has changed in UWP. UWP is a platform which is geared toward getting apps in to the store. It's a stripped down platform and doesn't appear to allow you to load assemblies at runtime. This was possible in .NET.
However, there does seem to be a way to run UWP style apps on top of the .NET runtime using the Desktop Bridge. I'm not really that familiar with it, but you can read more here as a starting my point. My guess is that if you want to load assemblies dynamically, the best approach would be to use this:
https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-root

Including C# ConsoleApplication in UWA

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).

Compile and run a external Java program in WinRT?

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.

use c# create web ActiveX to show image (without installing of .NET framework)

This is what I need to do.
I must create an ActiveX (IE add-on) in C# to show image(s) on client (load image(s) from Twain Scanner).
I have made Windows Form and use System.Windows.Forms.PictureBox but it need .NET framework installed on client PC.
Any ideas are appreciated. Thanks so much.
Everything written in C# requires .NET framework to run. Either the full framework or Silverlight.
If you want to write an ActiveX that is independent of the .NET Framework you have to write it in another language, such as C++ or Visual Basic 6.
I'd recommend that you really, really, really try to get out of the ActiveX requirement and instead use AJAX or Silverlight.
If you use C# to create an ActiveX control, then yes: it will require the .NET framework at the client. You cannot change that.
If you want a non-.NET control, VB6 (though obsolete) may be simplest. AFAIK Silverlight does not offer access to scanners, so is not an option.
I also suggest, however, that ActiveX itself is already imposing a lot of demands (mainly: IE). I wonder if something like a ClickOnce client application is more appropriate. Or: just provide upload (input type="file") controls.

Categories