I have an existing project for Windows 10 (UWP).
It creates an app that can go into Windows Store and be sideloaded, and that works fine.
... but now I would like to create a desktop-version (an exe-file) from the same code base (to avoid sideload-security issues in local network).
I created a VS 2015 4.5.2 WPF project and started to reference the components (dll's) used in the UWP project. But the importer states that some of the components depends on .Net-Core, and cannot be referenced.
So: Is it possible to mix .NET-Core and .NET-Framework components in the same WPF project?
Or: Can I create a .Net-Core console-app, create the used windows, use XAML, and export an exe (with dependencies) that can run standalone?
Thx!
Unfortunately what you are tying to achieve is not possible.
UWP and WPF are different stacks and unless you are using PCLs code cannot be shared between them.
Even then, the XAML layer is different and not compatible from one stack to another.
So no, you cannot reuse your code in a WPF application
As for the other solution, you cannot have your UWP app run as an .exe because Universal Apps run a different Application Model called appx which is fundamentally different than the exe application model.
There are ways to wrap an exe application in an appx (See the Desktop App Converter) but there is no converter/repackager to take you from appx to exe.
Related
I'm currently developing a UWP application that now needs access to APIs that are normally not accessible by apps in an AppContainer.
As I'm not (yet) able to migrate to WinUI3, I want to try using DesktopBridge to do the otherwise restricted work.
As both processes have to communicate with each other, I thought of COM as it should make things relatively seamless once everything has been set up.
According to this page this should be possible using "Packaged Com".
I now have...
An Out-of-Process Com Server (c# net5.0) that is accessible by non-packaged win32 apps (e.g., PowerShell) but not my own UWP App.
The UWP App with the main logic and UI.
A Packaging Project, which creates a package out of both projects.
(Manifest)
The code is on GitHub: Repo.
Does someone have an idea how to solve this problem or got an alternative for IPC?
PS: Tutorials I used
Packaged Com
Out-Of-Proc COM in c#
Packaging / DesktopBridge
So if I understand you correctly, you want to communicate between a UWP app and a Win32 app, and these two apps are packaged inside a Windows Application Package Project. Please let me know if it is not correct.
For your scenario, since the two apps are packaged together with desktop bridge, I'd suggest you use the App Service. App service could be used not only between UWP apps but also between the UWP app and desktop app.
These are the detailed steps:
You need to declare the AppService connection in the Manifest file of the package project.
You need to call the App service API in the win32 application.
You need to handle the connection in the App.xaml.cs in the UWP app
You could check the detailed code and sample from Stefan Wick's blog - UWP with Desktop Extension – Part 3.
I'm developing a WPF application, I added a custom WinRT component (implemented in UWP) and I'm hosting this win10 component in the WPF app, via XamlHost. I followed every step of the documentation, my custom controls are implemented in a UWP app project instead of a UWP class library. The app runs well and the UWP components are displayed properly in the WPF application. I could create the app package, but when I uploaded to the Microsoft Store (the .msixupload file), the following error was thrown:
Package acceptance validation error: You cannot submit pre-compiled .NET Native packages. Please upload the Microsoft Store appxupload file and try again.
What they mean pre-compiled .NET Native packages?
I also checked the sample application, which contains a winrthost.dll for different architectures. However the documentation doesn't mention this, I also added to my UWP project and configured as it is in the sample app's .csproj file. I tried to remove this dll file, but the store still doesn't accept the build.
As I removed the reference to the UWP App project, the Store accepted my build. As I re-added the reference (without using any component from it), the Store rejected. So I think the problem is in the custom UWP app, but what could be a pre-compiled .NET Native package here?
Update:
I added a new empty UWP app project to the solution, just set up the XamlApplication and referenced it from the WPF application. The UWP component shows in the WPF (I added just a green rectangle), but when I tried to upload to the store, it displayed the same error message.
As the documentation says, also tried to create a UWP class library instead of the UWP app. Created the build and the store accepted... What is the difference?
The documentation says:
You can alternatively define the custom control in the UWP app project
you created in the previous section. However, these steps do this in a
separate class library project for illustrative purposes because this
is typically how custom controls are implemented for portability.
So, theoretically it would be possible to publish a WPF app with a custom WinRT component hosted in a UWP app, right? Then why the store doesn't accepts?
After one day of investigation, I found that the solution is just to add the UWP app as a reference to the Packaging project (not just to the WPF app).
As I added to the references, the Store accepted the build. More details here.
In my VS2017 solution, I created a UWP and .NET Standard Library 2.0.3 projects. Referenced Library project from UWP. Library project is using a System.Diagnostics.Process to start a process. In debug mode, I get access denied error at line Process.Start(...) of the code inside Library project.
I thought the purpose of new .NET Standard Library project was to support various platforms (.NET, .NET Core, UWP etc) uniformly. But I guess, the sandbox nature of UWP apps is probably not allowing me to run Process.Start(...) albeit the process is running inside Library project. Question: What I may be missing and/or how can we resolve the above issue?
You cannot launch process directly from UWP, but there are some alternative ways to do that. The first one is using FullTrustProcessLauncher, if you need some example, check this post series. Another way is using a WPF or WinForms application to host UWP Controls with the Xaml Islands where there aren't restrictions to call any .NET APIs, but remember, through this way, your app will work only on Desktop devices.
According to this answer, you can't use Process.Start in a UWP app. There are some alternatives for launching other apps, but you can't execute arbitrary .exe or other processes.
I'm developing Windows Store Universal app that uses Azure to store data.
In Visual Studio, there is four projects (Windows, Windows Phone, Shared, Mobile Service).
In Shared projects there is a class ToDoItem.cs. I want it to be used by all projects to avoid code repetition.
The problem I have is that I cannot add a reference to ToDoNotes.Shared in MobileService project. If I do it the other way round, that is, if I have this class in MobileService and reference it in Windows and Windows Phone projects I hit the same problem.
Is it possible to share this class across all projects?
An Azure project can only reference a classic class library... Universal Apps can only reference portable class libraries so you can not reference the code in this manner... There is one trick left in the arsenal, that is to add the file to both the shared project and the azure project as a link. This will link the file to the azure project Instead of copying the file into the azure project folder directory. See Photo below
The hard part will be trying to use the same code because certain objects have been moved from one namespace to another between universal apps and standard.net such as the XmlDocument, httpclient etc. Your code may have quite a few ifdef statements and this might end up being more trouble than it is worth.
Assuming ToDoItem.cs is like a object model, it should be put in a strongly named class library that can be referenced to from any project
I am new to using Xamarin and have always used Visual Studio, however I now require to develop a desktop application which will run on both Mac and Windows, OR at least a package which will let me package for both.
I have created a GTK 2.0 Project, connected to a MySQL database etc and all is fine, however I can only see options to create a .exe and no .dmg file for OS X but the debugger lets me run it on my Mac.
Does anyone have any ideas or pointers?
We use Xamarin.Mac to enable us to develop a Windows and Mac client using c#.
We chose to re-build the core code in Xamarin Studio and use interfaces to abstract the OS dependent code.
We share 90% of our code in the Xamarin.Mac/VS solutions.
Do let me know if I'm helping... if so I can provide more detail if need be.
Check the following link on how to create an .app bundle with Xamarin:
How to set Xamarin MonoMac project so its build outputs .app package instead of .exe?
An app bundle is basically a special kind of folder structure that contains all app data, including e.g. graphical resources, configuration files, localisations, etc...
A .dmg file is used for distribution and can be created using other tools like Apple's own Disk Utility, once you've created the app.