Unable to take control over MSIX updates for .net 6 WinForms application - winforms

I am trying to build MSIX setup for my WinForms application built on .net6. I want to give auto-update feature when the user clicks the "Update" button. I think originally developer didn't have control over updating MSIX and there was only way it was updated automatically when the application is restarted.
But there is a recent article on taking full control over MSIX updates I tried to follow it but I am facing the exception 'System.InvalidOperationException' while running the below line of code.
Package package = Package.Current;
I am using visual studio 2022 & WinForms application running on .net 6. I have kept other configurations as described in the above article but it is not working as expected. (I have tried in .net core 3.1 and it is working with it)

Package.Current only works in a packaged context, so you need to make sure to actually debug/launch the packaging project. An InvalidOperationException indicates that you are running your project unpackaged.
Make sure to select "Set as Startup Project" on the packaging project, likely named "MyApp (Packaging)" in the Solution Explorer. Then you can launch/debug your project as you normally do.

Related

Create installer for WPF core application

I have a WPF using .net core 5, I want to create an installer with "Visual Studio Installer Projects".
I followed the usual steps and install the created installer on my machine.
The problem is when I want to run the app from the shortcut on my desktop, I get always this error message :
The message box will close and nothing happen whether I click 'yes' or 'no'.
Any idea what can cause this problem ?
You have to add the prerequisites. In your case the correct .NET Version.
If you would like your installer to be able to install the necessary runtime for a framework-dependent .NET Core 3.1 app, you can do this using prerequisites. From the properties dialog of your installer project, open the Prerequisites... dialog and you'll see the following entries:
The .NET Core Runtime... option should be selected for console applications, .NET Desktop Runtime... should be selected for WPF/WinForms applications.

Properly package a Desktop Bridge UWP App with a Win32 App

We already have a working UWP app for x86, x64 and ARM. Everything is fine regarding store certification, all tests are passed, including with .NET native compilation.
We would like to use the Desktop Bridge (similar to what is specified here: https://blogs.msdn.microsoft.com/appconsult/2016/12/19/desktop-bridge-the-migrate-phase-invoking-a-win32-process-from-a-uwp-app/) to add a small .NET 4.6.1 WPF side-kick app to the main UWP (x86, x64) versions. The WPF app has three dependencies(x86 and x64) on some native dll's which are packaged together with the rest of the app.
We added the WPF.exe app and dll's to the existing UWP package (like specified in the above blog post - using xcopy) and built packages for HockeyApp. Locally and functionally, everything works fine for both x86 and x64. Once uploaded to the ms dev center, the Store certification unfortunately fails with the following error:
"Package acceptance validation error: Apps converted with the Desktop
Bridge and that require the .NET Native framework must be pre-compiled
by the .NET Native tool chain"
-- but native compilation is already enabled for UWP Release x86, x64.
We then tried to create a Windows Application Packaging Project (like described here: https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-packaging-dot-net#generate-packages-for-your-desktop-bridge-app) and add both the UWP app and the WPF as dependencies. Then we created a new app manifest and store association (unfortunately it does not seem possible to reuse the existing manifest from the UWP app). We built the app store packages for (x86 x64 Release) and successfully tested everything locally. We then uploaded the package to win dev center and got again the same errors as before
"Package acceptance validation error: Apps converted with the Desktop
Bridge and that require the .NET Native framework must be pre-compiled
by the .NET Native tool chain".
As a follow up we removed the UWP project from the Windows Application Packaging Project and set the WPF app as an entry point. We then built a store package, uploaded it and the .NET native compilation error disappeared. Which is very weird...
Somehow the combination of UWP and WPF (even with native compilation enabled for UWP) causes this certification error. We have a feeling that something is wrong with the packaging.
We would really want to get this combination working or we will have to fall back to having two separate apps: one pure UWP and one packaged WPF companion app which needs to be installed separately. We truly wish we wouldn't have to do this. I'm not sure what we are doing wrong and for the moment I have run out of ideas.
PS: We also know we need to fill and submit a form regarding the restricted capability: full trust. But before we do that we need to be sure that everything else is fine.
UPDATE 4/21/2018
The workaround explained below is no longer needed, and in fact will not be accepted by the Store anymore. The right way to properly package a UWP app with a Win32 extension is to use the new VS Packaging Project, and then create the store package off of that project in VS. Details are in this blog post, see example #3 for this specific case:
https://blogs.windows.com/buildingapps/2017/12/04/extend-desktop-application-windows-10-features-using-new-visual-studio-application-packaging-project/#uvfV1r7937WrSkX2.97
OUTDATED ANSWER BELOW
You are hitting a known flaw in the Store ingestion process for packages that contain a mix of UWP and Desktop .NET binaries. The Store team is actively working on resolving this, so it will work automatically for submissions of this type. In the meantime you can do the following to get unblocked:
Manually create your.appxupload as follows (see screenshots for clarity below):
Go to the output folder for the AppPackage
Select the .appxsym files and the .appxbundle file
Create a new .zip file from those
Rename the .zip file to .appxupload
Resubmit to the Store with the new .appxupload file

platform requirement not met error in wpf application

I am getting following error while browsing wpf application from windows 8.Its working in other machines .Do we need to do any configuration changes.
As mentioned here, the problem may happen because the target framework used on the dev machine is not installed on your client machine. Try installing .Net2.0 by clicking "Install .Net Framework" button.

Published application requires visual studio to run

I have developed a WPF application and I need to try it on other computers.
1- I change my project properties to build in release mode and rebuilt project. However, /bin/release folder is empty and it still generates /bin/debug folder.
2- I selected publish and install it on other computers. Funny thing is, the program is not running if that computer does not have Visual C# (.Net Framework, Sql server etc. does not cause a problem)
3- I added a installer and add project output(release) to this application. It says /bin/release/abc.exe couldn't be find.. Changed it to project output(debug) and it builds fine. However, this setup is not even working on my computer..
So my question is simple... How can I publish WPF application in release mode and how can I run them on other computers without installing Visual C#. Thank you in advance
Check properties of your project, and set output folder for Release configuration.
You need .NET 4 framework installed on PC, to run (simple) WPF application.
Should work, when you set your output folder, see 1.

compile error when creating a new SL4 navigation app

I created a new Silverlight Navigation Application using Visual Studio 2010. I didn't make any changes to the code. Just Pressed F5 to run. I get the following error message:
The type 'System.Windows.Navigation.NavigationEventArgs' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.Controls.Navigation.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll'
I right clicked the Silverlight Navigation Application folder in the solution explorer and changed its "Target Silverlight Version" from Silverlight 4 to Silverlight 3 and then ran the application (by pressing F5) and it works fine.
I've already spent a lot of time trying to fine a solution. I want to develop application using Silverlight 4.
Would really appreciate any help with this.
Regards,
Vivek
It sounds like you have Silverlight 4's runtime, but an older set of VS tools or an older SDK, or your project is somehow referencing the older SDK.
Basically, that type moved from the System.Windows.Controls.Navigation DLL (where it was in SL3) to System.Windows.dll (where it is in SL4). CLR type-forwarding should take care of this.
Since Silverlight version numbers on assemblies didn't change between SL3 and SL4 it can be somewhat hard to tell if you're in the situation where you have outdated tools/SDK. Check the last modified date on System.Windows.Controls.Navigation.dll and see if it looks like about the time SL4 was released, or check if the Frame control has a property called ContentLoader - if so, you have the updated bits (and my answer is thus not helping). If not, however, then try reinstalling the SL4 Tools and/or SDK and check that your project is referencing the v4 Navigation assembly.

Resources