text:
👩💻📞 WinUI Community Call (Febuary 19, 2020)

Hi all -
The next WinUI Community Call will be on Wednesday Feb 19.
We'll be broadcasting live on the Windows Developer YouTube channel again - you can set a reminder here:
https://www.youtube.com/watch?v=tasbSc3771A
Details
Date: Wednesday February 19
Time: 17:00-18:00 UTC (9:00-10:00am Pacific)
Anyone and everyone is welcome - no pre-registration is required.
This will be an informal online call directly with members of our engineering team.
Please leave questions/topics/feedback!
We'd like to spend part of the time answering your questions again, so please leave comments in this issue if there are any questions or topics you'd like us to cover next week!
If you've tried out the new WinUI 3 Alpha Feb 2020 update then we'd also love to talk about any feedback you might have so far on WebView2 or anything else.
Agenda

We'll give a progress update on WinUI Desktop - Miguel (@marb2000) will be joining us in the studio to talk about topics like win32 support, desktop windowing, app model changes so that WinUI isn't dependent on UWP, etc.
Quick recap of other recent updates: WinUI 3 Alpha Feb 2020 update with WebView2, Windows 10X development
General status on WinUI 3 development - current challenges and what we're working on this month
Q&A - we'll answer your questions from this issue (leave a comment!) and anything that comes up during the call - good time to ask about WinUI Desktop or WebView2!

We'll also have a few dev team leads on the call this month to help comment or answer questions.

I have a question regarding the Windows 10X development. To develop for it I need the emulator, when will there be support for AMD processors (nested virtualization)? Can we count on the Windows 10 2003 version?

AMD Ryzen support is preventing me from running the Emulator, so any word on when that will be rectified will be good to hear.

@jp-weber @mdtauk
This is the official wording (https://docs.microsoft.com/en-us/dual-screen/windows/get-dev-tools):

AMD processors are not supported at this time. Nested virtualization is required to run Windows 10X in the emulator and Windows does not yet support this on AMD processors. Stay tuned!

If you want more info you should probably contact dualscreendev@microsoft.com. I doubt WinUI is the correct team.

Thanks @Felix-Dev - that's correct, the docs are the best place to get the latest status on the 10X emulator, and that email address is the best contact for other 10X questions that aren't specific to WinUI.

Fair enough, will have to wait until Microsoft are ready to talk about it.
Looking at Windows 10X, Win32 apps run in a VEIL container.  What about WinUI 3.0 non UWP apps?
Will they appear to run as native UWP apps do on 10X?

Since WinUI Desktop apps are not native UWP apps, I don't think they will run in the UWP container. I believe they will still run in the mentioned Win32 container (as they will have (all) the capabilities of Win32 apps.

I'm also interested to know what the plan is for WinUI app isolation going forward.  From an enterprise perspective, we need isolation/sandboxing and capability control (not user opt-in).  So, putting this out there as a topic for Miguel..

How hard would it be to add better overload resolution for functions inside {x:bind}? Right now:

Overloading is based on the number of arguments, not type, and it will try to match to the first overload with that many arguments
The argument types need to match the data being passed in – we don’t do narrowing conversions

The current approach makes working with methods like String.Format & String.Concat painful as although they have 8 - 10 overloads, you can only access a few of those, and whichever happened to of been defined first for however many parameters you want to provide.
An example of this issue is that the docs on the subject provide sample code that looks like it should work fine:
<TextBlock Text="{x:Bind sys:String.Format('{0} is now available in {1}', local:MyPage.personName, local:MyPage.location)}" />

But is actually invalid since the first overload of String.Format with 3 arguments wants an IFormatProvider for the first parameter, not a string.

@mdtauk Since WinUI Desktop apps are not native UWP apps, I don't think they will run in the UWP container. I believe they will run in the mentioned Win32 container as they will have (all) the capabilities of Win32 apps.

This is a little disappointing.  Win32 apps seem to exhibit different windowing behaviour, and darken the screen when they are in the foreground.  So switching also behaves differently.
Using a Xaml UI, is have hope a WinUI Desktop app would be a best of both worlds scenario at least on the surface to the user

@mdtauk As the current 10X emulator image released to us is still very early I'm pretty sure the issues/behavior you noticed (I did too in my tests) will be addressed/altered until release (i.e. I also have Win32 apps which just fail to load right now.)
That said, I will be happy to be corrected on the WinUI Desktop app container on 10X. My current thinking is based on what we've been told about WinUI Desktop so far (Win32 app model), the 10X presentation How Windows 10X runs UWP and Win32 apps and desktop bridge test apps. Unfortunately, my XAML Island test apps fail to load in the emulator currently (stuck at the App Launch Initialized stage) so I cannot check which container they will use. I would be surprised if it isn't the Win32 container though. All that leads me to think WinUI Desktop apps will run in the Win32 container on 10X.

@Felix-Dev according to the same video you mentioned (How Windows 10X runs UWP and Win32 apps) at minutes 20:18 says that hybrid apps (Win32/UWP) are not supported (yet) and my understanding is that an app which uses XAML Island is an hybrid app.

Why is WinUI desktop not running on UWP by now? People above are talking about WinUI having it's own container or worse - running on Win32 - what madness is this? Win32 is meant to be for backward compatibility - WinUI apps should be running inside the UWP container. I don't even know what .net 5 will be running in - if it's consuming WinRT shouldn't it be running in a UWP container?
I'm confused because the github page says that WinUI can be used in W10 UWP Xaml apps. What does it even mean for WinUI to run on Win32 - WinUI is a .net library isn't it? Has it been released for C++ now? I know the UI runs natively, but i didn't know WinUI lib was available for C++.

@leoniDEV Much of this is still speculation what exactly is meant by "hybrid apps". See this twitter thread for example where it is said that XAML Island apps don't belong into that category (Matteo Pagani works at Microsoft as a Windows AppConsult Engineer). A MS employee in the UWP Community said that support for UWP apps running a Win32 full-trust process won't be supported one day 1 but is planned to be added later.
@Gavin-Williams There will be two flavors of WinUI: WinUI UWP and WinUI Desktop. With WinUI UWP you will be able to create full UWP apps which will run in the UWP container on Windows 10X. Then there is WinUI Desktop which will enable Win32 apps to have full access to the UWP UI APIs (XAML, composition, input,...) too. These types of apps don't have to deal with the UWP sandbox or other design restrictions of the UWP.  As they are no UWP apps, however, your WinUI Desktop app won't be able to target the broad range of Windows 10 device categories an UWP app can.
See the image below taken from the WinUI roadmap for a good overview:

WinUI has been written in C++ from the ground up so it can be used in an unmanaged app context.
As I stressed above, my writing I believe they will run in the mentioned Win32 container is purely based on my current understanding of WinUI Desktop, the 10X video and desktop bridge test apps I ran on 10X. I have no insider knowledge. The WinUI team will surely let us know what is the the plan with WinUI Desktop apps and the 10X container used and I'm happy to be corrected here and be told that yes, WinUI Desktop apps will run in the UWP container on 10X.

I would like to hear more about any thoughts on potentially being able to use other programming languages, such as Java, Python, JavaScript etc, when building apps using WinUI / Microsoft UI.
I know there is a project called Xlang (cross-lang) - which essentially seems like what .NET should have been, a better COM.
How does that relate to WinUI?

xlang is essentially a cross-platform open source version of the Windows Runtime (WinRT), though it wasn't going to be fully compatible. The purpose of WinRT is what you said, interoperability between languages. WinUI's APIs are built on WinRT which is how it supports both C++ and C#. There are other languages with various levels of support for WinRT, including Python, Rust (this is one I've personally worked on) and JavaScript, but as far as I know none of them support WinUI - supporting WinUI is particularly difficult because its Composition and XAML APIs heavily depend on a type system feature called composable types (essentially a form of implementation inheritance) which other WinRT and UWP APIs don't use and which can be tricky to map to other languages' type systems.
Kenny Kerr, the creator of C++/WinRT, is working on a new Rust WinRT projection now.
I've actually been thinking a lot recently about how Rust could best support composable types (and thus WinUI). It's certainly possible but am not yet sure how natural I can get it to feel for developers. Basically, any language should be able to support WinRT if someone puts in the work to create a projection, but depending on the design of the language it can sometimes be tough to map WinRT type system constructs to the type system of the language in a way that feels natural.

xlang looks dead to me. C++/WinRT wasn't ever really finished - it was left with bugs and a very odd-ball usage story, making it undesirable for the average developer. I struggled for many, many hours to get C++/WinRT working, and failed to do what I did in 30 minutes with C++/CX. And C++/CX was easier to use by a long shot. If Microsoft want these cross language tools to be usable by the Average Joe, they need to put a team of people onto the problem.

For now UWP and it's successor WinUI is not ready for LOB applications
There are several problems we are facing

Poor performance. For example WinUI dependency property is 50 times slower than https://github.com/microsoft/microsoft-ui-xaml/issues/1633 .
Poor compilation performance. Several times slower than wpf
dotnet native
A lot of breaking changes between releases.
Sandboxing and permissions model
Limited customization ability for 3d party vendors compared to wpf

Do you think that WinUI can overcome this limitation and become next LOB ready framework for the next 10 years. Or it time to move forward to electron blazor app )

I have a couple of issues with the current state of WinUI.
C++/WinRT is still a very poor developer's experience compared with C++/CX tooling and overall developer experience. If we are expected to deal with WinUI components written in C++, having at very least 1:1 coverage for what C++/CX tooling is capable of is to be expected.
Being standard C++17 is of no use to me if my productivy suffers versus just using C++/CX, and it takes twice as long to write a UWP component or XAML based UI.
Which leads to my second question, the main reason to having to deal with C++ on UWP/WinUI, is because Microsoft has dropped the ball in any kind of DirectX bindings to .NET languages. So will WinUI ever provide support for XNA like replacement, or WPF 3D scenegraph? Apparently we only get radio silence here, and are forced to go into community projects like MonoGame or full blown engines like Unity.
When is Win2D finally be made part of WinUI? Currently it looks to be in maintainence mode with uncertain future.
Currently it is becoming very hard to still keep selling the UWP dream, as the amount of listners around my soap box keeps diminishing.

When will Windows 10X UI elements make their way to desktop Windows 10?

@carmellolb 2022-2025?

@Felix-Dev "WinUI Desktop .. will enable Win32 apps to have full access to the UWP UI APIs .. excluding a few APIs like CoreWindow.
Excluding CoreWindow? OMG - That's the first and most important API that should be pulled out of UWP. It's the most foundational API that provides the basic window functionality. It needs to be universal, inside and outside the UWP container. Until it's brought out we can't have a common code base for the application layer and we are stuck with legacy Win32 c code or whatever .net core is going to provide (another Window class again?)

About the call: why did you move away from Teams? YouTube didn't work out so well on the last one.

@Gavin-Williams
From comment https://github.com/microsoft/microsoft-ui-xaml/issues/1215#issuecomment-531994216:

Our approach is that WinUI 3 will use CoreWindow when running in UWP and Win32 Window(HWind) when running in Desktop (Win32).

WinUI 3 in UWP apps will be able to use AppWindow APIs. For Desktop, there will be needed to come out with something similar. We are still designing this, so I don't have more details so far.

The team also said it is looking to provide APIs like CoreApplicationViewTitleBar.ExtendViewIntoTitleBar for WinUI Desktop as well so we might be able to get the best of both worlds. The full power of Win32 windowing design (i.e. no titlebar/100% custom titlebar, app window < required minimum size, no taskbar button,...) and the new modern UWP customization APIs. (For UWP, we probably have to wait for AppWindow V2 to have windowing capabilities which are close to the current Win32 windowing ones.)
@jesbis Question regarding WinUI Desktop: In issue https://github.com/microsoft/microsoft-ui-xaml/issues/1939 it has been pointed out that toast notification activation does not work for MSIX packaged desktop apps on (at least) 1909 as mentioned in the docs:

For Desktop Bridge apps, just send toast notifications like a UWP app would. When the user clicks on your toast, your app will be command line launched with the launch args that you specified in the toast.

While I have to wait and see if the mentioned fix will be backported to affected OS versions for desktop bridge apps my question is: Will WinUI Desktop apps provide the out-of-the-box toast activation feature quoted above (so without having to use a COM Activator) on all of the WinUI targeted Windows 10 versions? (Or any similar toast activation concept.)

@Felix-Dev From the documentation seems that XAML Island don't strictly implies an hybrid app, you could call the UWP XAML hosting API directly from your Win32 app at the expense of loosing some functionality, like use of custom controls, if I understand correctly the docs (and the note in the docs):
Host a standard UWP control in a WPF app using XAML Islands

Required components

The project and source code for your app. Using the WindowsXamlHost control to host standard first-party UWP controls is supported in apps that target the .NET Framework or .NET Core 3.

A UWP app project that defines a root Application class that derives from XamlApplication. Your WPF or Windows Forms project must have access to an instance of the Microsoft.Toolkit.Win32.UI.XamlHost.XamlApplication class provided by the Windows Community Toolkit. This object acts as a root metadata provider for loading metadata for custom UWP XAML types in assemblies in the current directory of your application.
Note
Although this component isn't required for trivial XAML Island scenarios such as hosting a
first-party UWP control, your app needs this XamlApplication object to support the full
range of XAML Island scenarios, including hosting custom UWP controls.
Therefore, we recommend that you always define a XamlApplication object in any solution
in which you are using XAML Islands.

I struggled for many, many hours to get C++/WinRT working, and failed to do what I did in 30 minutes with C++/CX

If we are expected to deal with WinUI components written in C++, having at very least 1:1 coverage for what C++/CX tooling is capable of is to be expected.

@Gavin-Williams, @pjmlp have you opened issues in the cppwinrt repo for the issues you're finding? Or are they problems specific to WinUI that you could open issues for in this repo? We're actively working on C++/WinRT support so it would be great to hear any details on what's not working well for you. We're using it ourselves too - new WinUI features are all in C++/WinRT, as are our apps using it (e.g. calculator).

About the call: why did you move away from Teams? YouTube didn't work out so well on the last one.

If you mean the audio issues: we think we had a bad cable last month and are hoping it should be better tomorrow. YouTube seemed to be more accessible for most people, and the Channel9 studio has way better audio and video than the conference room we were using for Teams.

RE: CoreWindow, win32 support, containers - we'll talk about our current direction during the community call tomorrow with @marb2000 :)
We'll also try to get to the other questions so far (e.g. current status on SwapChainPanel timeline, Win2D/DirectX, islands, etc.) - thanks for the comments & questions so far!

@jesbis Thanks for getting back to us.
There are no issues to open, because C++/WinRT approach to development is completely backwards to the productivity offered by C++/CX.
With C++/CX I initially thought that Microsoft was finally selling Visual C++ the right way, 25 years later Visual C++ had caught on with the RAD experience of C++ Builder.
Instead what C++/WinRT gives me is a return to the ATL/WTL days, where I have to write MIDL boilerplate, even though MIDL 3.0 is somehow nicer that the original MIDL, have to manually write UWP bindings boilerplate that C++/CX handles for me.
Not that C++/CX is perfect, the way it handles event handlers still fails short of C#/VB.NET, or C++ Builder for that matter.
UWP is anyway tied to Windows, so having a pure C++ binding is not something that buys me into C++/Winrt, rather being able to do exactly the same as in C# or VB.NET, without having to deal with code that still feels like ATL/WTL.
And as mentioned, I am only busy with C++ because the appeals to expose DirectX as a set of UWP Runtime Components keeps being ignored.
So I don't feel opening issues on  cppwinrt  will improve the ability to use C++/CX across Blend and Visual Studio as easy as C++/CX, ideally as easy as C# and VB.NET, as I expect the cppwinrt team to shift the problem into the Visual Studio team, and traditionally (MFC/ATL/WTL) the C++ tooling team never cared to provide the same high level tooling as the .NET languages enjoy, even though other companies are able to do so with C++ (Qt, Embarcadero).

@pjmlp thanks for the details - I'm checking with some people to see if there's any more info to share on C++/WinRT tooling, although I probably won't have good answers by tomorrow. We're focused on C++/WinRT for new development, but we do have it on our roadmap to hopefully have C++/CX templates for WinUI 3 as well if that helps.

I'm also interested to know what the plan is for WinUI app isolation going forward. From an enterprise perspective, we need isolation/sandboxing and capability control (not user opt-in). So, putting this out there as a topic for Miguel..

@infoequipt could you elaborate on what you mean by isolation? E.g. like AppContainer support?

For now UWP and it's successor WinUI is not ready for LOB applications

A lot of breaking changes between releases.

@Xarlot what breaking changes were causing problems for you? With UWP APIs we try to maintain a high degree of compatibility every release.

@Gavin-Williams Regarding SharpDX being deprecated, you might want to look into Vortice.Windows, which is a great alternative for it. @Aminator is currently using it in his own fully UWP/C#/XAML DX12 game engine and editor, DX12GameEngine. Hopefully that suits your needs in your apps! 😄

@leoniDEV You can also host custom controls just fine I think or do you see any difference specifically between standard controls and custom controls regarding "hybrid app" in the docs? On first view I didn't notice an obvious difference important here.
Host a custom UWP control in a WPF app using XAML Islands
@jesbis Two more questions regarding WinUI Desktop (perhaps somewhat related):

Will WinUI Desktop apps have an in-built switch between multi-instance (Win32 standard) and single-instance (UWP standard)? Right now if we want Win32 app to be single-instance we have to implement this behavior ourselves. This might not just require an app lock (like a mutex to check if an instance is already running) but also Win32 API like SendMessage to pass operations from a second app instance to the primary app instance (see question 2). It would be great if we could get the option to have the single-instance behavior of UWP apps for WinUI Desktop apps.

Will WinUI Desktop apps be able to use the UWP Jumplist API? Currently, desktop bridge apps cannot effectively use them because the app seemingly can't be activated (see Windows Terminal issue https://github.com/microsoft/terminal/issues/576 for a breif overview of the problems). I would like full support of this API for WinUI Desktop apps because they are much easier to work with than the Win32/WPF APIs. For example, jumplist task icons can be easily set ising the ms-appx:/// or ms-appdata:///`` URI schemes instead of having to create an .exe or .dll containing the images, then set the path to that binary file and also an offset into the file for the specific icon.

The docs sum up the advantages of the UWP Jumplist API:

Alternatively, use the UWP Windows.UI.StartScreen.JumpList APIs instead, which allow you to reference string and image assets using the package-relative ms-resource URI scheme (which is also language, DPI, and high contrast aware).

The single-instance behavior of UWP apps also potentially makes working with jumplists much easier. If you have a jumplist task which should operate on the current running app instance, in WPF/Win32, a second app instance is launched which then needs to use the SendMessage Win32 API for example to send the requested behavior to the running app. Using single-instance behavior on UWP, the running app easily gets the invoked jump task instead.

@pjmlp another thing that might be of interest if you haven't seen it is this session by Kenny Kerr and Scott Jones from the last Build conference, particularly the last ~11 minutes where they talk about some prototyped improvements to bindings, and some C++ tech specifications for adding reflection and metaclass support that could completely remove the current IDL & metadata codegen requirements:
https://youtu.be/X41j_gzSwOY?t=2659
If we have time then we can talk about this a bit in the call tomorrow too.

Thanks @jesbis, I am aware of that talk. It is still too far in the future as I can tell.
Right now it looks more likely that I will port my existing DirectX code to something like the Vortice library, pointed out by @Sergio0694 than wait for such tooling to bare fruits.
I do admire your efforts, but here from the trenches, after Silverlight, XNA, WinRT, UAP, UWP, WinUI, .NET Framework, WCF, EF6, eventually we get tired to keep doing rewrites.
WinUI should be better than WPF in all senses, and if we are forced to use C++ because reasons, then its tooling should be at the same level that .NET developers have come to love, to actually be worth to move beyond WPF or making a point to avoid business wanting to go with Electron style apps.

As @Sergio0694 already asked, will WinUi 3.0 be used not only to switch namespaces but also contain other breaking changes, that are needed to fix bugs such as incorrectly applied spaces?
If so would there be a chance to rename the NavigationView.IsBackButtonVisible property to BackButtonVisibility as the name and type currently do not really line up (IsBackButtonVisible is an NavigationViewBackButtonVisible enum, not a bool). This was also discussed here.

@chingucoding I recall the team said that for WinUI 3.0 itself (breaking) changes should be minimal to make porting apps to it as straightforward as possible. I suspect these changes, if approved, will be implemented in subsequent WinUI 3.x releases.

Will WinUI Desktop enable desktop app devs to finally use AcrylicBrush with HostBackdrop? We previously used composition attribute WCA_ACCENT_POLICY with ACCENT_ENABLE_ACRYLICBLURBEHIND but Microsoft critically broke this in 19H1+ and our app has been suffering since. (It also affected things like the Emoji Picker but Microsoft serviced those components to use non-acrylic method instead.)

About WebView2:
https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2

"Developer preview is available for Win32 C++ on Windows 10, Windows 8.1, Windows 8, and Windows 7. In the future, we plan to support WebView2 on .NET, and XAML."

My question is .. Is it planned that the .NET Version of WebView2 SDK that applicable for Win8.1, 8 and 7?
I have a concern that parhaps WebView2 on .NET is supported only via WinUI3. In my understanding, WinUI3 WinForms app support is only applicable for .NET Core based and only for Win10.
Let me explain the my situation.. My client have many of WinForm desktop apps that use the IE BrowserControl. But IE is obsolte and want to migrate to modern browsers. And, these app SHOULD support the Win7, 8, 8.1. (don't blame me for old os support)

If possible:

Win32 ETA on a preview build for WinUI 3.0

If source code is not ready to share, maybe giving out a already complied demo exe of some UI elements running we could download and play with would be cool to show off to fellow co-workers.

Does WinUI 3.0 support custom shader effects like WPF/Silverlight did? If not are there any thoughts on adding them later? Is the rendering layer used by WinUI even capable of this?

@leoniDEV I went ahead and created a XAML Island project as you highlighted (so no separate UWP project). It contains a single UWP inbox control (a button) and works fine on 10X. No surprise for the container story...it runs in the Win32 container as expected.
So yeah, currently at least there is not yet full support for XAML Island apps consuming a separate UWP project. Whether that points to those type of Island app potentially using a different container we probably have to wait until at least today's community call.

I'm looking at doing v-next of a legacy WPF app.  I can probably use .NET Core WPF, but I really want to use WinUI.  I'm running into issues with libs like Prism still deriving from Windows.UI.Xaml (as opposed to Microsoft.UI.Xaml).  It feels like these types of issues are foundational. Is there solid PnP guidance for WinUI, yet, or is it too soon?

Is it possible to get someone from the shell team or inbox apps team on to talk about why the start menu and file explorer on Windows 10x are web-based instead of using WinUI?

How likely is it that WinUI 3.0 will be ready to launch when the first Windows 10X devices launch? I'm interested in jumping into the Windows dev world and I'm trying to decide what approach makes the most sense at this point.

Thanks everyone for the questions and for watching if you could make it!  The recording is live at the same link.
There were lots of questions we didn't get to - I'll try to summarize them and post some responses here soon.

Good show guys, thanks for taking my question and for Miguel presenting.

I'm looking at doing v-next of a legacy WPF app. I can probably use .NET Core WPF, but I really want to use WinUI. I'm running into issues with libs like Prism still deriving from Windows.UI.Xaml (as opposed to Microsoft.UI.Xaml). It feels like these types of issues are foundational. Is there solid PnP guidance for WinUI, yet, or is it too soon?

I'm thinking too much in terms of legacy,  I think....  I'm considering ReactiveUI as the MVVM framework, which I believe also gets me DI, plus the Observable pattern support.

I'll add a few more questions I'm left with in hopes that they'll be addressed.

Traditional Win32 apps draw to the screen in WM_PAINT.  XAML apps are retained mode. We draw WAY too many things to the screen to create individual objects/controls. Will there still be a WM_PAINT equivalent to allow me to draw to the window but with more modern API? Win2D or some other immediate-mode API?

Accessibility is handled differently in Win32 (COM APIs) vs, say, WPF (Automation Peers). If I write a Win32 + WinUI application, will I be able to augment or control the accessibility tree any easier? Or will I stick with the old COM APIs?  How would I blend my custom drawn content with accessible controls in the accessibility tree?

Today, we print by drawing into a printer DC. Is there a new printing with Win32+WinUI?

I'm still a bit baffled with regard to the relationship between a HWND, a CoreWindow and whatever comes next for WinUI.  Will HWNDs still exist or will we be replacing CreateWindow calls with something else? I assume so... but if that's the case I assume there must still be an underlying HWND for cases where we must hand one off to external components (parent HWND for example).

Will WebView2 use in a Win32+WinUI app have the airspace issues we encounter with the embedded IE control?

Starting to catch up on some questions:

Is WinUI just UWP development but a more modern spec? I see conversations about WinUI and I'm not 100% sure if they are talking about UWP dev, particular libs in UWP dev or something different entirely

WinUI is specifically the UI layer and doesn't include other aspects of the UWP app platform like the app model for suspend/resume, background tasks, etc.
For UWP apps, it can specifically replace Windows.UI.Xaml, Windows.UI.Composition and parts of Windows.UI.Input.

Will WinUI apps have an in-built switch between multi-instance (Win32 standard) and single-instance (UWP standard)?

@Felix-Dev we haven't explored the idea yet of better single-instance support for win32 apps yet - if you have a proposal then feel free to open an issue in this repo for it!

Will WinUI 3.x support AcrylicBrush with HostBackdrop? It's currently known broken in the alpha but am curious if it's on the roadmap to be fixed before release. Will WinUI Desktop enable desktop app devs to finally use AcrylicBrush with HostBackdrop?

@riverar this is unfortunately not in the plan for WinUI 3.0 RTM. There are challenges with supporting this in a UI platform that's decoupled from the OS, but we're planning to revisit this after 3.0.

About WebView2: My question is .. Is it planned that the .NET Version of WebView2 SDK that applicable for Win8.1, 8 and 7?
I have a concern that parhaps WebView2 on .NET is supported only via WinUI3.

pnp0a03 the WinUI Xaml control is only supported in WinUI 3, but there is a developer preview of the core WebView 2 SDK for Windows 7, 8 and 8.1 for win32 apps:
https://docs.microsoft.com/microsoft-edge/hosting/webview2

I'm running into issues with libs like Prism still deriving from Windows.UI.Xaml (as opposed to Microsoft.UI.Xaml). It feels like these types of issues are foundational. Is there solid PnP guidance for WinUI, yet, or is it too soon?

@GraniteStateHacker It's a bit too soon I think - WinUI 3 is still too new to have much ecosystem support (it's only in alpha) but @hassanuz is starting a workstream to investigate library compatibility/migration options.

Is WinUI only for Store apps?

No - you can use it in a variety of ways, for example:

include it in an existing win32 app (WPF, WinForms, MFC, etc.) using Xaml Islands
build an MSIX installer and deploy however you'd like
create an unpackaged app and distribute it via xcopy or other means (not supported for WinUI 3 yet but planned for RTM)

How likely is it that WinUI 3.0 will be ready to launch when the first Windows 10X devices launch? I'm interested in jumping into the Windows dev world and I'm trying to decide what approach makes the most sense at this point.

@dwalleck WinUI 3 already has an alpha out and should have a more functional preview around the Build conference timeframe, and both are targeting late 2020. If you start with UWP Xaml and/or WinUI then you should be on a good path for 10X development.

Traditional Win32 apps draw to the screen in WM_PAINT. XAML apps are retained mode. We draw WAY too many things to the screen to create individual objects/controls. Will there still be a WM_PAINT equivalent to allow me to draw to the window but with more modern API? Win2D or some other immediate-mode API?

@jschroedl Xaml element trees & brushes are retained-mode but you can use one or more of several options to include lighter-weight rendering primitives:

composition layer Visuals
composition layer Shapes which enable drawing very high-performance retained geometries - also used for things like the WinUI AnimatedVisualPlayer control which can play Lottie shapes/animation
DirectX interop with Xaml using SwapChainPanel, SurfaceImageSource or VirtualSurfaceImageSource (depending on whether you want a swap chain or virtualized/non-virtualized brush model)
Win2D, which abstracts the above DirectX interop for you (with Direct2D, DirectWrite) and provides a .NET API

Accessibility is handled differently in Win32 (COM APIs) vs, say, WPF (Automation Peers). If I write a Win32 + WinUI application, will I be able to augment or control the accessibility tree any easier? Or will I stick with the old COM APIs? How would I blend my custom drawn content with accessible controls in the accessibility tree?

Great question! Paging @marb2000 to make sure this is covered and give the latest updates. In general the WinUI Xaml trees should use AutomationPeers but I'm not sure yet if that will extend any new functionality to non-WinUI win32 content.

Today, we print by drawing into a printer DC. Is there a new printing with Win32+WinUI?

The main printing functionality for WinUI content should be through a WinUI verison of the WinRT PrintDocument API.

I'm still a bit baffled with regard to the relationship between a HWND, a CoreWindow and whatever comes next for WinUI. Will HWNDs still exist or will we be replacing CreateWindow calls with something else? I assume so... but if that's the case I assume there must still be an underlying HWND for cases where we must hand one off to external components (parent HWND for example

WinUI isn't replacing hwnds but the goal is to abstract away their usage for common use cases by providing a Xaml API - sort of similar to how WPF works. The Xaml API will indeed still use hwnds/CoreWindows as an underlying implementation detail, and we'll likely have "backdoor"/"escape-hatch" APIs to get direct access to hwnds when needed. We should have a proposal draft in a few weeks which will make this clearer.

@jesbis Thank you for your answer, but my concern was not solved unfortunately.
Currently, WebView2 SDK Win32 "C++" SDK (preview) version is released from this site. It supports Win7, 8 and 8.1.
https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2
My question is about .NET version. Currently, .NET version is only supported by WinUI 3, But, as you know, we can't use WinUI 3 on Win7, 8, and 8.1 ( is this right? ).
Thus, I've post my question as below.

My question is .. Is it planned that the .NET Version of WebView2 SDK that applicable for Win8.1, 8 and 7?

@jesbis Thanks for replying to my questions, although it felt demotivating.
Trying to be constructive here.
So the best that Microsoft can offer regarding C++/WinRT tooling is to point out to some up in the air proposals, that with luck might land on ISO somewhere between C++23 or C++26, if at all. And then wait for Visual Studio team to eventually rebuild C++/CX on top of them, which makes it about 6 years from now.
If I want great C++ UI tooling, WinUI definitely isn't it, rather Qt or C++ Builder, with the added benefit of platform portability.
So after watching the presentation, and still wearing scars from XNA (have rewrite in C++ with DirectXTK), WinRT 8.0, WinRT UAP 8.1, UWP W10, C++ Direct2D instead of System. Drawing (until Win2D came along, now stagnant), WinUI is definitely something that I will put on hold.
Going forward I will advise my customers to go WPF when using .NET, Qt when using C++, or focus on PWAs if doable with Web technologies.
WinUI 3.0 roadmap doesn't inspire any confidence that yet another reboot is around the corner, if selling UWP keeps failing on the desktop market.
In a sense what I want to point out is that Microsoft management should think it through how to sell us the idea of adopting WinUI, after failing us so many times since Windows 8 release.

@pjmlp general C++/WinRT feedback is probably best directed to the cppwinrt repo. ISO standard updates take time but I hope it'd be less than the timeframes you mentioned - reflection support is a top priority and they were just discussing it at the C++ conference in Prague last week.
DirectXTK is still in development has been getting regular updates.
In terms of Xaml framework APIs, WinUI is the path forward and has a fairly unbroken compatibility lineage back to Windows 8 - we spend a lot of time trying to maintain a high degree of compatibility 🙂 There are a few changes (due to shell integration, VS project structure, etc.) but for the most part you could likely port Windows 8 Xaml to a current Windows 10 app, recompile it and run it on the latest insider flight and it would work.
Some of the high-level benefits of WinUI will include removing the barriers between UWP WinRT APIs and win32 APIs, supporting .NET 5, enabling immediate downlevel support for new features, removing the need to do many conditional OS version checks, enabling OSS contributions and enabling incremental updates to existing win32 apps using Xaml islands.

@pnp0a03 there are efforts to bring .NET elements to market as well. I cannot give specific dates, but we are aware of the demand for this and are working out the details.

@jesbis As mentioned I don't believe complaining on cppwinrt will do anything, I rather complain by not adopting C++/WinRT unless for the use cases I am cannot avoid, specifically because the roadmap is to adopt feature that might not even be accepted into ISO.
Regarding DirectXTK, I was giving yet another example on how Microsoft has forced us to rewrite our C# code into C++, with less capable tooling, by dropping XNA and providing DirectXTK as "alternative".
Thankfully the open source community managed to come up with MonoGame and do the work Microsoft refused to pursue with XNA.
I saw it during the presentation and in some of the comments here, how C++ is great and fun, how WinDev (once more since Longhorn's take over) keeps selling C++ first, .NET later.
If I want great C++ tooling, Qt and C++ Builder are my environments of choice, not Visual C++.
You really should ask mangement to allow your team to have a look at what is possible today in the competition, instead of expecting some metaclasses and reflection ideas to be accepted at ISO.
No only do we have to bother with the APIs and third party libraries that won't carry over from .NET Framework into .NET Core, we also have to deal with all the migration issues from WPF/UWP into WinUI and the "just write it in C++/WinRT, it is cool and it is be better in a couple of years" mentality.
Microsoft management really has to think it through, how to sell this rewrite to burned .NET developers, otherwise we won't move away from stacks that already do their job.

@pjmlp Speaking of DirectX, I'm actively working on a portable and agnostic C# graphics, audio and input framework in my free time that will be capable of running D3D12/11 etc in a WinUI view.... among many other things.
It supports a much more modern and performance focused approach of rendering vs something like XNA. Its not ready for use but is something many people have wanted including myself... so I'm making it.  D3D12 and Vulkan will be the first targets supported.  You will also be able to write shaders in C# instead of HLSL or GLSL etc.
When its ready to use I will share more but because this is a framework and not some massive SDK or game-engine, it will be very portable and lightweight yet powerful and easy to use. Perfect to render 3D content in WinUI, WPF, or some native C# Win32 app.
https://github.com/reignstudios/Orbital-Framework

@zezba9000  Thank you for the information, lots of impressive stuff you have done, kudos!
I guess in what concerns managed support for DirectX we can only count on community efforts like yours, after tanking Managed DirectX and XNA, the C++ MS crowd took over DirectX development efforts.
At very least any of these projects can count with my advocacy, as marketing to show others that it doesn't need to be only "C++ or the high road" as WinDev likes to push it. Here they could take a lesson from  OpenGL ES/Metal with Swift, or OpenGL ES/Vulkan with Java/Kotlin. Apparently using managed languages for 3D programming wasn't an issue for mobile platforms to win over Windows (sadly, WP was a great experience).
Good look for your efforts, writing shaders in C# looks really appealing and I wasn't aware of CS2X.

@pjmlp Ya the CS2X part is what will allow for writing agnostic GPU shaders in C# (which is cool because you will be able to Unit-Test your shaders in theory).  For targets that can make use of a C# subset, CS2X allows me/others to target platforms outside what current .NET runtimes support with an very lightweight runtime as CS2X can compile C# to a C89 runtime.  Because the Orbital-Framework can target the CS2X => C89 runtime, it in turn can target these platforms as well.
Big project but its what I care about and I'm dedicated to making it happen.

Is it going to be possible to use HwndHost with WinUI 2.4
I tried at prerelease version and this didn't work.
Also  is it going to be possible with WinUI3 with all this new planned Windowing (XAML Window) and Application (XAML Application) and if yes when we can expect first preview to see that.
Actually if it is going to be possible in WinUI3, will this functionality be added to WinUI 2 new releases, or WinUI 2 will just work in Uwp apps.
For example right now, we have WPF app, that uses lot of C++ code through HwndHost, and because we are planing to move everything to WinUI, this part is very critical to us to decide to go with WinUI or something else. Also even WinUI 2 looks good for us, XAML part is so easy to transfer, Composition Api work great, Uwp Community Toolkit works great, only we can't use HwndHost and c++ Win32 code. So is and when WinUI3 is going to solve this? Also I like a lot x:Bind but this is even at risk for WinUI3 release.

@zezba9000

Speaking of DirectX, I'm actively working on a portable and agnostic C# graphics, audio and input framework in my free time that will be capable of running D3D12/11 etc in a WinUI view.... among many other things.

Good luck with this! It's an insane amount of work!

Will WinUI 3 improve on the processing of videos?
(side note: what UWP has right now, IMO are some things you can't tweak much, and you pretty much need to start off from preexisting examples, and pray they'll eventually suit your needs. the Media.Editing documentation is severely lacking)
The following may seem convoluted, please let me know if it doesn't make sense. Long story short, what I want to do is this - load specific video frames from an .mp4 video.
I need to do this as efficient as possible, using MediaPlayerElement is way too slow. So I do a trick - namely, apply a video effect on the video, which gives me access to each video frame.
This is waaay faster, but has some pitfalls - to process each frame, I need to create a MediaComposition, add a video clip, and call .RenderToFileAsync. Clearly, I don't need to save the resulting video to a file, but I don't know how to do it otherwise.
Say I do this
var composition = new MediaComposition();
...
var save = composition.RenderToFileAsync(dummy_file, MediaTrimmingPreference.Precise, encoding_profile);

This will use its own Direct3DSurface (I would like to be able to specify my own, see below). I am applying a video effect on the video, and I'd like to copy the results somewhere else.
I have a callback to be called for each frame.
private void on_in_frame(VideoFrame frame)

If I want to copy the original frame to my own Direct3DSurface, and I'll do:
var bmp_src = CanvasBitmap.CreateFromDirect3D11Surface(frame_temp_device_, frame.Direct3DSurface, 96, CanvasAlphaMode.Premultiplied);
var bmp = CanvasBitmap.CreateFromBytes(canvas_device_, dummy_bytes_, (int)bmp_src.SizeInPixels.Width, (int)bmp_src.SizeInPixels.Height, bmp_src.Format);
bmp.CopyPixelsFromBitmap(bmp_src);
bmp_src.Dispose();

This is very costly - copying from one Direct3D surface to another, and at this time, I simply can't avoid it. Had I been able to specify my Direct3D surface for rendering, all would be simple and fast.
So, I would need one of two things:

be able to specify my own Direct3D surface, when using RenderToFileAsync (hopefully this)
either fast copy between two Direct3D surfaces

Would this be something that could make it into WinUI 3 ?

Is it going to be possible to use HwndHost with WinUI 2.4
I tried at prerelease version and this didn't work.
Also  is it going to be possible with WinUI3 with all this new planned Windowing (XAML Window) and Application (XAML Application) and if yes when we can expect first preview to see that.
Actually if it is going to be possible in WinUI3, will this functionality be added to WinUI 2 new releases, or WinUI 2 will just work in Uwp apps.
For example right now, we have WPF app, that uses lot of C++ code through HwndHost, and because we are planing to move everything to WinUI, this part is very critical to us to decide to go with WinUI or something else.

There's an issue open for a way to host user32/comctl or WPF UI inside WinUI XAML: https://github.com/microsoft/microsoft-ui-xaml/issues/1833
It looks like it won't be made until after 3.0, if it is made.

I post this to #1833
https://github.com/microsoft/microsoft-ui-xaml/issues/1833 but I ll copy
it here too:  Right now we have WPF app that uses lot of c++ code through
HwndHost control. We are planing to move Wpf app to WinUI and moving Xaml
works great without problems, but what about HwndHost, is this going to be
possible with WinUI3.  In our case we are doing interoperability with
DirectShow through HwndHost and right now in WinUI 2 , this is not
possible. What will be realistic date to use HwndHost in WinUI3? Also is
this new Xaml Window and Application like discussed at latest February
WinUI Community call, could help or not?
El dom., 23 de feb. de 2020 a la(s) 13:42, Max Strini (
notifications@github.com) escribió:

Is it going to be possible to use HwndHost with WinUI 2.4
I tried at prerelease version and this didn't work.
Also is it going to be possible with WinUI3 with all this new planned
Windowing (XAML Window) and Application (XAML Application) and if yes when
we can expect first preview to see that.
Actually if it is going to be possible in WinUI3, will this functionality
be added to WinUI 2 new releases, or WinUI 2 will just work in Uwp apps.
For example right now, we have WPF app, that uses lot of C++ code through
HwndHost, and because we are planing to move everything to WinUI, this part
is very critical to us to decide to go with WinUI or something else.
There's an issue open for a way to host user32/comctl or WPF UI inside
WinUI XAML: #1833
https://github.com/microsoft/microsoft-ui-xaml/issues/1833
It looks like it won't be made until after 3.0, if it is made.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/microsoft-ui-xaml/issues/1972?email_source=notifications&email_token=AG66BVVOQ6W3Z6LBVYZVJ63REJVLPA5CNFSM4KUFQ6MKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMV2ZRQ#issuecomment-590064838,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AG66BVRWNTNC7FUIBBP5C6DREJVLPANCNFSM4KUFQ6MA
.

--
Mario Rancic
Software Engineer
Microsoft Certified Professional

Really good WinUI Community call last week! The content was very interesting and detailed/technical enough to provide a lot of insight. The roadmap/development status updates are also extremely valuable for consumers of WinUI and our own development roadmaps. I look forward to the next call!

About HwndHost in WinUI 3.
HwndHost allows to host  Win32 content inside of WPF.  Unfortunately there is no plan in WinUI 3.0 to support this, including in WinUI 3.0 Desktop or WinUI Islands. About the scenario @mariorancic01 described, did you evaluate UWP MediaPlayer APIs instead of DirectShow?

Well Uwp Camera looks better, but not sure can we use it in our scenario.
We are using camera as virtual camera with DirectShow and we need it show
video, to grab the camera stream for a photo and also with PjSip in the
same time, before we could just do it with DirectShow.  Can we use this Uwp
MediaPlayer with PjSip.
El mié., 26 de feb. de 2020 a la(s) 23:47, Miguel Ramos (
notifications@github.com) escribió:

About HwndHost in WinUI 3.
HwndHost allows to host Win32 content inside of WPF. Unfortunately there
is no plan in WinUI 3.0 to support this, including in WinUI 3.0 Desktop or
WinUI Islands. About the scenario @mariorancic01
https://github.com/mariorancic01 described, did you evaluate UWP
MediaPlayer APIs instead of DirectShow?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/microsoft-ui-xaml/issues/1972?email_source=notifications&email_token=AG66BVR4ABZ7KA3S2RQVHELRE3WOJA5CNFSM4KUFQ6MKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENCGCSY#issuecomment-591683915,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AG66BVSBFMKZMD3TD5RGDKTRE3WOJANCNFSM4KUFQ6MA
.

--
Mario Rancic
Software Engineer
Microsoft Certified Professional

I have question about Windows Store for Business, this looks very cool and very useful for LOB apps, but I read this might be abandoned. Can anybody say something about plans about this .

@marionrancic01 It is not really necessary since you can now distribute UWP apps via MSIX packaging.

sad, like @mariorancic01 also I find the Windows Store for Business useful 😞

@leoniDEV I am honestly curious why you would need Windows Store for Business, when you can simply publish as msix, as @kmgallahan said

Most likely because of of package singing issues.

@kmgallahan @jtorjo I suppose what they are looking for is to have a private application catalog. MSIX does not offer that I believe? Unless you build a website where you list the MSIX your company provides, or use some management tool to deploy things to your users?
In a similar way, the old MSI installers do not provide a way to discover apps as well.

Publishing to Windows Store is not a walk in the park - it's waay more complex than you think. First off, you need to wait for a certificate from MS - the one that you'll use to publish (I don't remember the exact steps right now). Then, you need to make sure your app doesn't violate any Store requirements. Then, any update you make can take days to be accepted (or it can be rejected), and you would rely on the store's algorithm for people to find your app.
But if you deploy yourself, it will be a bit hard to set it up (I would know), but once that is done, it will be easy peasy. But yeah, you'll be in charge of showing your app to the world.

As someone who has multiple apps on the Microsoft Store, including the store for business I can tell you that publishing to the Microsoft store has gotten much easier in the past few months. Certification for regular updates sometimes happens as fast a few hours. The store guidelines or also pretty easy to meet.
On the other hand, disturbing a standalone msix can be complicated. Unlike the store which signs packages for you, if you distribute your app outside the store, you need to sign it on your own.

@jtorjo You do not need any certs.

To be clear, there are issues with the store and the developer dashboard does go down from time to time, but my point above was that it is pretty convenient to have the store for business apps.

As someone who has multiple apps on the Microsoft Store, including the store for business I can tell you that publishing to the Microsoft store has gotten much better in the past few months. Certification for regular updates sometimes happens as fast a few hours. The store guidelines are also pretty easy to meet.

@yaichenbaum That's definitely good to know. When I was publishing (2 years ago or so), it was waay harder. Yes, you do need to sign it on your own - in fact, you buy a certificate, and sign it as part of the "Publish" process. So once you've set it up, you can forget about it.
@riverar When I was publishing (2 years ago or so), I remember you need to reserve a name, and then you need to wait for something that MS will use to sign your app (which is what I meant, by a certificate -> one that MS will issue for you).

authors: Felix-Dev Gavin-Williams GraniteStateHacker Sergio0694 Xarlot adambarlow carmellolb chingucoding contextfree dwalleck hansmbakker infoequipt jesbis jp-weber jschroedl jtorjo kmgallahan leoniDEV marb2000 mariorancic01 matthew4850 mdtauk myokeeh pjmlp pnp0a03 riverar robertsundstrom robloo yaichenbaum zezba9000

repo: microsoft/microsoft-ui-xaml


text:
Implementing a control to display animated WebP files

I'd like to implement a control, a codec, or anything that will let me render animated WebP files within a C# Windows App SDK application. The solution needs to be performant; on par with the animated GIF rendering natively available via the Image control.
I've been scouring all the resources I can find for some kind of guidance on this. I've come across WIC, Win2D, the Windows.Graphics.Imaging namepsace, several outdated libraries (such as the Lumia Imaging SDK), and this blog post. I don't really have experience with Windows graphics systems, so all of the new knowledge is a little overwhelming, and I'm having a hard time trying to determine which avenue would be the most modern and best starting point. I'm honestly not even sure if this is the right place to ask, but I saw an issue that was closed about adding animated WebP support to the Image control that made me think it might be.
Would someone please help point me in the right direction on this, or offer any advice to help focus my effort? Thanks!

You can use the WebView2 control, which supports animated Webp files

I can give that a shot, but I don't expect that a WebView2 will support virtualization? I'd like to support displaying a large number of files in a staggered layout.

Animated WebP still not supported.

I just tested with WIC (IWICBitmapDecoder) and it works on my Windows 10 OS (22H2)
although WebP is not in Native decoders

I uploaded a test  : WinUI3_WIC_WebP
for a control using a SwapChainPanel (Direct2D) and MMIO functions to read WebP attributes
I tested with WebP files I found on Google or others I created from GIF/MPEG

I have the same issue and it would be great if BitmapImage supports animated webp images, not only gif

I have the same issue and it would be great if BitmapImage supports animated webp images, not only gif

Actually I just found about Magick.NET and decided to convert webp to gif in my application which worked for me.

I have the same issue and it would be great if BitmapImage supports animated webp images, not only gif

Did you test the "WebPControl" control ?

I have the same issue and it would be great if BitmapImage supports animated webp images, not only gif

Did you test the "WebPControl" control ?

I just tried it but the image in WebPControl doesn't seem to enlarge when I increase the height or width of the control. Is it possible to resize the image when the control's size changes?

I just tried it but the image in WebPControl doesn't seem to enlarge when I increase the height or width of the control. Is it possible to resize the image when the control's size changes?

Yes, I have voluntarily put it inside a ScrollViewer to get Scrollbars when the image is too big
You can remove the ScrollViewer and for example use
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
for the control in XAML
And I have fixed its size and centered it to avoid stretching, at lines :
   //this.Width = m_nCanvasWidth;
   //this.Height = m_nCanvasHeight;

and
 //destRect.left = (nWidth - nFrameWidth) / 2.0f;
 //destRect.top = (nHeight - nFrameHeight) / 2.0f;
 //destRect.right = destRect.left + (float)nFrameWidth;
 //destRect.bottom = destRect.top + (float)nFrameHeight;

then it will be stretched, but it is not great for the resolution :

@castorix I really appreciate your help and your suggested change works without any problem.
However, meanwhile, I also tried using WebView2 as you have mentioned before and I think that control is potentially more suitable for my project.
So I will try using it first and see if it works out.
Thanks for your help.

source: gharchive/issue

authors: Wufus castorix dustincleveland kaismic

license: MIT

license_type: permissive

license_source: github-api


text:
Controls in ListView.Header may end up in unload state after changing the ListView.ItemsPanel

Describe the bug
When changing the ItemsPanel value of a given ListView, the control child of the ListView.Header will be unload and reload again reusing the same instance.
Issue is that often a race condition occurs and the ListView.Header control child receive the load event first and then unload one, meaning we end up with controls in an unload state in the ListView.Header.
Steps to reproduce the bug
Create a UWP project with the following:
.xaml:
    <Page.Resources>
        <ItemsPanelTemplate x:Name="GridDisplayModeItemsPanelTemplate">
            <ItemsWrapGrid Orientation="Horizontal" />
        </ItemsPanelTemplate>

        <ItemsPanelTemplate x:Name="ListDisplayModeItemsPanelTemplate">
            <ItemsStackPanel />
        </ItemsPanelTemplate>
    </Page.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <ListView
            x:Name="list"
            ItemsPanel="{StaticResource GridDisplayModeItemsPanelTemplate}"
            ItemsSource="{x:Bind Items}">
            <ListView.Header>
                <muxc:ProgressRing
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    IsActive="True"
                    Loaded="ProgressRing_Loaded"
                    Unloaded="ProgressRing_Unloaded" />
            </ListView.Header>
        </ListView>

        <Button
            Grid.Row="1"
            Click="ChangeItemsPanel"
            Content="Change ItemsPanel" />

        <TextBlock
            x:Name="Status"
            Grid.Row="2"
            Padding="12"
            Foreground="Red"
            TextWrapping="Wrap" />
    </Grid>

.xaml.cs:
        public IEnumerable<string> Items { get => new[] { "Item1", "Item2", "Item3" }; }

        private void ChangeItemsPanel(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Status.Text += "ItemsPanel: Changing\n";

            // Switching ItemsPanel
            list.ItemsPanel = list.ItemsPanel == ListDisplayModeItemsPanelTemplate
                ? GridDisplayModeItemsPanelTemplate
                : ListDisplayModeItemsPanelTemplate;

            Status.Text += "ItemsPanel: Changed\n";
        }

        private void ProgressRing_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
            => Status.Text += $"ProgressRing#{sender.GetHashCode()}: Loaded\n";

        private void ProgressRing_Unloaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
            => Status.Text += $"ProgressRing#{sender.GetHashCode()}: Unloaded\n";

To repro, just click on the Button until the ProgressRing is no longer visible.
Expected behavior
While changing a ListView.ItemsPanel value the ListView.Header control child must always receive the unload and load event in the right order.
Screenshots

As you can see, based on its hashcode 23318221, the ProgressRing control instance is reused after updating the ListView.ItemsPanel. It also received the second load event before the unload event, which explains why the ProgressRing is not animated anymore due to its unloaded state.
NuGet package version
Microsoft.UI.Xaml 2.8.0
Windows app type

[ ] UWP
[ ] Win32

Device form factor
Desktop
Windows version
Windows 11 (21H2): Build 22000
Additional context
No response

Any update regarding this issue?

This is likely a dup of the issue mentioned here - https://github.com/microsoft/microsoft-ui-xaml/issues/1900

authors: acouvert-msft ranjeshj


text:
Add RadioMenuFlyoutSubItemStyle

This change does two main things:
Adds the RadioMenuFlyoutSubItemStyle, which -- if applied to a MenuFlyoutSubItem -- will show a radio dot if a RadioMenuFlyoutItem in the menu is checked. It does this by setting the new attached property AreCheckStatesEnabled, which runs a check when the item is Loaded and sets the appropriate visual state.
Also, the change in code to RadioMenuFlyoutItem makes it so that items don't have to be together in a menu in order to be grouped together. Instead of going through the visual tree to find siblings, it just keeps track of which item is currently checked, and unchecks it when a new item gets checked.

/azp run

/azp run

/azp run

/azp run

/azp run

source: gharchive/pull-request

authors: ranjeshj teaP


text:
Provide several fixes around OS X zone overrides

This series of patches fixes several glitches around OS X zone implementation:

Signature of malloc_size is corrected
Zone implementation is added into static object
zone_size function is implemented, otherwise free does not know which zone to use in order to free the pointer (see find_registered_zone in https://opensource.apple.com/source/Libc/Libc-594.1.4/gen/malloc.c)

Awesome. I will pull this in; I have limited ability to test on macOSX so please report any issues if these come up. There is a long discussion at #50.

Right. This is exactly what was written in https://github.com/microsoft/mimalloc/issues/50#issuecomment-518265693 :)

* `zone_size` function is implemented, otherwise free does not know which zone to use in order to free the pointer (see `find_registered_zone` in https://opensource.apple.com/source/Libc/Libc-594.1.4/gen/malloc.c)

Wow -- great info! I wonder this is why I couldn't get the zone's to work by themselves (and use interpose as well). Need to investigate this when I have access to mac system again. We can perhaps simplify the code further.

Right. This is exactly what was written in #50 (comment) :)

Ha, I somehow just missed the main point there!

authors: asl daanx

repo: microsoft/mimalloc


text:
ERROR in renderer.js from Terser

When I try to build it to a electron application, it raise error below:
ERROR in renderer.js from Terser
"o" is redeclared [renderer.js:1,260743]

HERE is my code: https://github.com/PeterlitsZo/Mini_Manoca_error
HERE is a copy of that code's README.md:

README
Op

sudo npm install -g vue-cli

I try to install the Vue's cli application.

vue init simulatedgreg/electron-vue

Use the template to init it, you can see more infomation by following this
link: https://simulatedgreg.gitbooks.io/electron-vue/content/.

Enter a lot of enter, so I get it by default setting.
npm install

Install other node library to make it can run.

npm run dev

It show that HTML Webpack Plugin: ReferenceError: pocess is not defined.

I follow https://github.com/SimulatedGREG/electron-vue/issues/871#issuecomment-490370237 to fix the bug.

Now I edit .electron-vue/webpack.web.config.js and .electron-vue/webpack.render.config.js,
by add a function templateParameters in HtmlWebpackPlugin.
Now it can run dev.
It show Vue.js: 2.6.12, Electron: 2.0.18, Node: 8.9.3 and Platform: linux.

npm run build

Use 7m42s to download electron.zip... >_<, but run well.

Add the Manoco.

You can find the source at ./src/renderer/components/LandingPage.vue.

npm install monaco-editor-webpack-plugin.
npm install monaco-editor
npm run dev

looks great! There is a Monaco editor at here.

npm run build

Very slow... but why? And it raise a error like before...
This article says that I need to use monaco-editor-webpack-plugin,
I'd like to try:
https://zhuanlan.zhihu.com/p/47746336

Sad to see that:ERROR in renderer.js from Terser
"o" is redeclared [renderer.js:1,260743]

So the question is: how to fix? Is there something I did wrong? I work for it for two days and nights.
Thanks.

We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding, and happy coding!

authors: PeterlitsZo hediet

repo: microsoft/monaco-editor


text:
[Bug] setExtraLibs not working in some cases related to spelling fix suggestions

Reproducible in vscode.dev or in VS Code Desktop?

[X] Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

[X] Not reproducible in the monaco editor playground

Repro Repo Link
This issue is not reproducible in the monaco editor playground because it does not expose an interface for calling setExtraLibs. However, I have created a very minimal monaco application which reproduces the issue here: https://github.com/suchipi/monaco-extralib-bug-repro/tree/625f2943d6c9e4bfabe48d243c05c7733b74dee2
Relevant Code Loaded into Monaco
// extra lib file "v1.ts" contains:
interface api {
  version: "1"
  something(): boolean;
}
declare const api: api;

// extra lib file "v2.ts" contains:
interface api {
  version: "2",
  something(): boolean;
  somethingElse(): boolean;
}
declare const api: api;

// the default monaco editor in the app contains:
type VERSION = typeof api.version;
const blah = api.somethingElse();

// and the app sets the extra libs to "v1.ts" at app launch.

Reproduction Steps
There is a repro repo with more detailed instructions, but the high-level steps are:

Use monaco.languages.typescript.typescriptDefaults.setExtraLibs to load a type definition for a variable named "something".
Attempt to reference the non-existent variable "somethingElse". A diagnostic error will be shown, with a spelling fix suggestion.
Use monaco.languages.typescript.typescriptDefaults.setExtraLibs again, to replace the loaded type definitions with new ones which define both something and somethingElse.

Actual (Problematic) Behavior
The diagnostic error does not go away, and the new extra libs are not used.
Expected Behavior
The diagnostic error goes away, and the new extra libs are used elsewhere in the program.
Additional Context
At work, I embed the monaco editor to allow users to author scripts. There are different versions of our API which they can develop against. We use setExtraLibs to change the loaded type definitions for our API depending on which API version the user's script targets (which they can change with a drop-down). We recently added a new API version which includes new functions, one of which whose name starts with the name of an older, existing function. Ever since that change, changing the selected API version has not been functioning properly due to the described problematic behavior.

I am very sure setExtraLibs is available in the monaco editor playground (please also check other issues).
I'll close for now, but feel free to reopen/create a new issue with an example for the playground.
Without the example we cannot debug this unfortunately.

My mistake; here it is in the editor playground: https://microsoft.github.io/monaco-editor/playground.html?source=v0.45.0#XQAAAAK7BQAAAAAAAABBqQkHQ5NjdzmeoQhbELdK4LJ3dVhQNmdymDlXD9sGVgT1xF3OY4smV0Qv_H8uUJC4shpDcmYB-4MKcwIrhJEGTbIOEGTE4SOD_zwYVEpAKtd-TB3N_LKKIXnCXY0gIfnuVI0sqTEHDB97Mc56k0-jnqJmsJVahlVh2UYdFswhmY2jY4hOq2bwbwN79ghDMHtbkcMC5XqpbqXoV8yOHBE8vtoYTAygJI87VLu693TID-Vea_MLAH7ZGypyzheM8U-44eYswUE8sJgz6FLPHegxx6y4cPKLrlASjujjMc3zhchFxJWaLw4A9AkjO7QnvSZtU5MaSDosGWubOr7NTHIMwujRZbSR5X_bG6KLvA13Y6t3yyO09pzOAmBjyXX2HthP1G-DFLbuvALqxjE5HEjMr8IwT-VMQucaYHanmdy3kFsDogtyeIc00jLriyWF6cD1fhm3x_MFXWiZlHeH7JG9p6GTtKrJxZIqV5uVBYsQHRbAf6DLNGP6vgis44dc9jjGgKEwwgUqK8NalxCheObC4ogJxVTiYFJTdMxgLPZoPQsRlWBtfTclyJf-d9Lp0QQ13fM-7lk2UfAVJ7TUpPkIN1lgA8lZflb2MVDIhf5YTgXTjEoG2DFtiCgnz6iKCftIkdC3k_9gEiZUsyNDZxMwiZput3PBUDuesbeJqzADCPXjm2haXlo-cAa-fiOKzYgnkYMpVA1PocdxYMElizcsxXYyRjFWSwB8i19uV3lzgOiwBH1NU-vZ5OMUDekMBQkHH2LSeQz9LrfJkrovLeKKf8EiKjfUQahG8TA2sYS8hZQIfLU7oUw4tt4daUj0sDdAnnQeO4pULuaLwmfdyXAY0WHMClHjkIQUsYqzs67ZKUDvM2Pbo_YwE5PhTfhn5F_VAOzynP8DSgwA
Could you reopen this issue, please?

authors: hediet suchipi


text:
New-BCContainer fails to create container if using artifact (instead of image) with Transparent network

Issue: New-BCContainer fails midway, when creating container with Transparent network using artifact
Troubleshooting step:

Running New-BCContainer with default NAT network: no issue
Running New-BCContainer using image, instead of artifact with both Transparent and NAT networks: works in both scenarios
The output of the scripts suggests it fails at restoring database (New-NAVDatabase at line 182 of C:\run\navinstall.ps1 script)

Determining Database Collation from c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak
Restoring CRONUS Demo Database
The database restore operation failed due to the following error returned by SQL Server:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (
provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
at <ScriptBlock>, C:\Run\navinstall.ps1: line 182
at <ScriptBlock>, C:\Run\start.ps1: line 202
at <ScriptBlock>, <No file>: line 1Error

With that information, I logged into the container (using docker exec) and manually run the New-NAVDatabase command:

Exactly same error:

New-NAVDatabase -DatabaseServer "localhost" -DatabaseInstance "SQLEXPRESS" -DatabaseName "CRONUS" -FilePath "c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak" -DestinationPath "c:\databases" -Timeout 300

New-NAVDatabase : The database restore operation failed due to the following error returned by SQL Server:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL
Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
At line:1 char:1
+ New-NAVDatabase -DatabaseServer "localhost" -DatabaseInstance "SQLEXP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : NotSpecified: (0:Int32) [New-NAVDatabase], NavCommandException
     + FullyQualifiedErrorId : gMSAnavnst,Microsoft.Dynamics.Nav.Management.Cmdlets.NewNavDatabase

HOWEVER, The command works when I manually specify the DatabaseServer parameter as localhost\SQLEXPRESS

New-NAVDatabase -DatabaseServer "localhost\SQLEXPRESS" -DatabaseName "CRONUS" -FilePath "c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak" -DestinationPath "c:\databases" -Timeout 300

DatabaseServer       DatabaseInstance DatabaseName
--------------       ---------------- ------------
localhost\SQLEXPRESS                  CRONUS

Conclusion In Transparent Network, New-NAVDatabase command can only connect to SQL server when specifying server name and instance in DatabaseServer parameter as localhost\SQLEXPRESS.
Additional information with a bit further testing, I found out that this issue also applies to image method. We never caught it because image method does not have database restore process through New-NAVdatabase command.
Scripts used to create container and cause the issue
$artifactUrl=Get-BCArtifactUrl -type sandbox -country us -select Latest
Write-Host -ForegroundColor Yellow "Using this artifact $artifactUrl to create container"

New-BCContainer -accept_eula -accept_outdated -containerName TEST -memoryLimit 8G `
-artifactUrl $artifactUrl `
-alwaysPull -doNotCheckHealth -auth Windows  -restart unless-stopped `
-shortcuts Desktop -doNotExportObjectsToText `
-additionalParameters @('--network=TransparentNet --security-opt "credentialspec=file://gMSAnavnst.json"')

Full output of scripts (please look at the last 15 lines)
Using this artifact https://bcartifacts.azureedge.net/sandbox/16.3.14085.15298/us to create container
NavContainerHelper is version 0.7.0.23
NavContainerHelper is running as administrator
Host is Microsoft Windows Server 2019 Standard - ltsc2019
Docker Client Version is 19.03.5
Docker Server Version is 19.03.5
Fetching all docker images
Pulling image mcr.microsoft.com/dynamicsnav:10.0.17763.1339-generic
10.0.17763.1339-generic: Pulling from dynamicsnav
Using image mcr.microsoft.com/dynamicsnav:10.0.17763.1339-generic
Disabling Health Check (always report healthy)
Creating Container TEST
Version: 16.3.14085.15298-US
Style: sandbox
Platform: 16.0.14073.15236
Generic Tag: 0.1.0.13
Container OS Version: 10.0.17763.1339 (ltsc2019)
Host OS Version: 10.0.17763.1339 (ltsc2019)
Using locale en-US
Using process isolation
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Additional Parameters:
--network=TransparentNet --security-opt "credentialspec=file://gMSAnavnst.json"
Files in C:\ProgramData\NavContainerHelper\Extensions\TEST\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container TEST from image mcr.microsoft.com/dynamicsnav:10.0.17763.1339-generic
28f2330544d7b0f17a0d2346bb8c06fa4472e578bb152dac25fe4d25d5b46389
Waiting for container TEST to be ready
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/16.3.14085.15298/us
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
Copying PowerShell Scripts
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation from c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak
Restoring CRONUS Demo Database
The database restore operation failed due to the following error returned by SQL Server:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (
provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
at <ScriptBlock>, C:\Run\navinstall.ps1: line 182
at <ScriptBlock>, C:\Run\start.ps1: line 202
at <ScriptBlock>, <No file>: line 1Error
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/16.3.14085.15298/us
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
Copying PowerShell Scripts
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation from c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak
Restoring CRONUS Demo Database
The database restore operation failed due to the following error returned by SQL Server:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (
provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
at <ScriptBlock>, C:\Run\navinstall.ps1: line 182
at <ScriptBlock>, C:\Run\start.ps1: line 202
at <ScriptBlock>, <No file>: line 1
Initialization of container TEST failed
At C:\Program Files\WindowsPowerShell\Modules\navcontainerhelper\0.7.0.23\ContainerHandling\Wait-NavContainerReady.ps1:44 char:17
+ ...             throw "Initialization of container $containerName failed" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Initialization of container TEST failed:String) [], RuntimeException
    + FullyQualifiedErrorId : Initialization of container TEST failed

Could you try to add
-imageName myimg
to the command to make containerhelper create an image on the fly and run that.

Thank you for the fast response, Fred. Using imageName fixes the issue.
I guess this is because during the creation of the image, the temp container is spun up using NAT network and is able to restore the database. After the image has been created, the command builds the real container using the normal image method, hence no issue.
This does not fix the root cause (New-NAVDatabase) though. Could you escalate this to your internal team to see if they have any idea?

Could it be that the issue is not the network but the gMSA setting?
This is kind of the same problem as is reported here: https://github.com/microsoft/nav-docker/issues/478

Hi Freddy, It is indeed related to the use of gMSA. If I do not use that switch, the database restore step runs fine.
However, my situation is a bit different from the one in microsoft/nav-docker#478. The SQL service in my container does not stop after the collation change. It runs all the time.
In my case, the root issue is in the New-NAVDatabase command. The command is only able to connect to the SQL server using -DatabaseServer localhost\SQLEXPRESS (default setting in navinstall.ps1 script is -DatabaseServer localhost)

Update: New-NAVDatabase command also works with -DatabaseServer "localhost,1433" -DatabaseInstance "SQLEXPRESS" (i.e. specifying the default SQL port, 1433).

Update: using -Verbose switch for New-NAVDatabase command, I found out that, if we use localhost for -DatabaseServer switch, somehow, the command converts it to the gMSA account name when executing:
New-NAVDatabase -DatabaseServer "localhost" -DatabaseInstance "SQLEXPRESS" -Verbose
VERBOSE: Performing the operation "New-NAVDatabase" on target "DatabaseServer = gMSAnavnst, DatabaseInstance = SQLEXPRESS, DatabaseName = CRONUS".

That is not the case for localhost,1433 or localhost\SQLEXPRESS
New-NAVDatabase -DatabaseServer "localhost,1433" -DatabaseInstance "SQLEXPRESS" -Verbose
VERBOSE: Performing the operation "New-NAVDatabase" on target "DatabaseServer = localhost,1433, DatabaseInstance = SQLEXPRESS, DatabaseName = CRONUS".
VERBOSE: Restoring database 'CRONUS' from backup file: 'c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak'...
VERBOSE: Restore of database 'CRONUS' from file 'c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak' completed
successfully.

New-NAVDatabase -DatabaseServer "localhost\SQLEXPRESS" -Verbose
VERBOSE: Performing the operation "New-NAVDatabase" on target "DatabaseServer = localhost\SQLEXPRESS, DatabaseInstance = , DatabaseName = CRONUS".
VERBOSE: Restoring database 'CRONUS' from backup file: 'c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak'...
VERBOSE: Restore of database 'CRONUS' from file 'c:\dl\sandbox\16.3.14085.15298\us\BusinessCentral-US.bak' completed successfully.

That is really interresting.
If you do not use gMSA, then I assume that New-NavDatabase won't use the hostname right?
My assumption is that this is a problem with gMSA and not with New-NavDatabase, right?

Hi Freddy,
Regardless of using gMSA or not, the New-NAVDatabase always uses hostname if specify localhost in DatabaseServer switch.
The reason why the command works when not using gMSA is because in this situation, the hostname is the same as the container's name, not the gMSA's account name.
For example below, I created a container named TEST without gMSA. In this case, the hostname of the container is also TEST. When I ping this hostname from within the container, it is ping-able since it is equal to localhost (127.0.0.1) internally.
New-NAVDatabase -DatabaseServer "localhost" -DatabaseInstance "SQLEXPRESS" -DatabaseName "CRONUS" -Verbose
VERBOSE: Performing the operation "New-NAVDatabase" on target "DatabaseServer = TEST, DatabaseInstance = SQLEXPRESS, DatabaseName = CRONUS".

C:\Windows\system32> docker exec -it TEST powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
   Host Name . . . . . . . . . . . . : TEST

PS C:\Program Files\Microsoft Dynamics NAV\160\Service> ping TEST

Pinging TEST [fe80::e4cd:d17f:aa3e:f4d7%46] with 32 bytes of data:
Reply from fe80::e4cd:d17f:aa3e:f4d7%46: time<1ms
Reply from fe80::e4cd:d17f:aa3e:f4d7%46: time<1ms
Reply from fe80::e4cd:d17f:aa3e:f4d7%46: time<1ms
Reply from fe80::e4cd:d17f:aa3e:f4d7%46: time<1ms

When using gMSA, the hostname inside the container is gMSAnavnst (the gMSA account name). This hostname is just a virtual one, (I think) used by the container to create relationship with our domain. When you try to ping it from within the container, it could not resolve it. This is why New-NAVDatabase command fails.
New-NAVDatabase -DatabaseServer "localhost" -DatabaseInstance "SQLEXPRESS" -DatabaseName "CRONUS" -Verbose
VERBOSE: Performing the operation "New-NAVDatabase" on target "DatabaseServer = gMSAnavnst, DatabaseInstance = SQLEXPRESS, DatabaseName = CRONUS".

PS C:\Program Files\Microsoft Dynamics NAV\160\Service> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : gMSAnavnst

PS C:\Program Files\Microsoft Dynamics NAV\160\Service> ping gMSAnavnst
Ping request could not find host gMSAnavnst. Please check the name and try again.

Looked in the source code for New-NavDatabase and you are right - the switch happens there.
But - it happens deep down in helper files used by lots of other things and New-NavDatabase behaves differently if it determines that the database is on a local server.
This means that there might be other places, where this switch happens and/or it might have other consequences to make the switch.
Could you try this:
I assume, that if you run
[System.Net.Dns]::GetHostEntry('localhost')
Inside the container, it returns your gMSAnavst.
Could you insert this (before the call to new-navdatabase):
set-content -Path 'c:\windows\system32\drivers\etc\hosts' -Value "127.0.0.1 $([System.Net.Dns]::GetHostEntry('localhost').HostName)"
Just as a test to see whether this fixes the issue.
This should cause all commands to know that this is localhost - and it would also cause other commands using the same low level function to resolve.

Hi Freddy,
Thank you for your suggestion. Modifying hosts file was my first thought as well, but I do not know how to do that during the creation of container, specifically, before the database restore step. I can do that manually by running PowerShell inside the container and it fixes the issue with New-NAVDatabase. However I have to wait for New-BCContainer command to fail and exit out.
I even tried to create a DNS record to point gMSAnavnst to 127.0.0.1 in our internal DNS server, but the container did not pick it up (it prioritizes its own internal record I guess).
Also, New-NAVDatabase gets the "localhost" data from the same source as ipconfig /all command, not from hostname or [System.Net.Dns]::GetHostEntry('localhost'). In normal scenario (i.e. no gMSA), all of these return the same result, TEST. However, in gMSA setup, ipconfig/all returns gMSAnavnst, while hostname or [System.Net.Dns]::GetHostEntry('localhost') returns TEST
PS C:\> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : gMSAnavnst
   Primary Dns Suffix  . . . . . . . : ourdomain.com

PS C:\> hostname
TEST2

PS C:\> [System.Net.Dns]::GetHostEntry('localhost')

HostName Aliases AddressList
-------- ------- -----------
TEST2    {}      {::1, 127.0.0.1}

Download https://raw.githubusercontent.com/microsoft/nav-docker/master/generic/Run/150-new/navinstall.ps1 and place it on your machine (ex. c:\temp\navinstall.ps1)
Insert the line above in the beginning.
run new-bcContainer with -myscripts @("c:\temp\navinstall.ps1")
You could insert a Write-Host to see that your file gets executed.

Awesome! I will try this.
Thank you for the suggestion.

Let me know if this worked, then I will add this line in the generic image if the host name starts with gmsa.

Hi Freddy,
It works! I put the command (to modify the host file) right after line 10 and 11 of navinstall.ps1 file.
This is the command I used:
set-content -Path 'c:\windows\system32\drivers\etc\hosts' -Value "127.0.0.1 $env:computername"

You should not rely on the host name starts with gMSA condition, simply because people can name their gMSA account in whatever way they want. It does not have to start with gMSA. Example: BCgMSAaccount, which makes the host name starts with BC, not gMSA
I think you can just hardcode this command without any condition (i.e. it always runs), because it gets the host name from $env:computername, which:

returns the gMSA account name if you use gMSA

PS C:\> $env:computername
gMSAnavnst

PS C:\> hostname
TEST
PS C:\>

returns the normal host name if you do not use gMSA.

PS C:\> $env:computername
TEST

PS C:\> hostname
TEST

In other word, it works with both situations and do not have any negative consequence.

I don't want to just always add the line - it will probably break something we don't think about right here.
But I could test whether computername is different from hostname - and if that is the case - then add computername to hosts like you do here.
Thanks for the investigations.

That is a good point!
Thank you very much for all the prompt and informative responses. Please let me know when you have implemented the change.
Have a good weekend!

Generic image 0.1.0.14 has been released and the code is added to start.ps1 (not navinstall.ps1)

Hi Freddy,
Could you also seed the change to onprem artifacts? It only works with sandbox at the moment.
Thank you in advance!

@freddydk
Hi Freddy,
Could you also seed the change to onprem artifacts? It only works with sandbox at the moment.
Thank you in advance!

This bug fix was not in the artifacts - it was in the generic image.
If something is wrong in onprem containers - either you have a cached image or something else is wrong.

@freddydk I just realized that as well. Turns out, I am now having exact same issue with this one: https://github.com/microsoft/nav-docker/issues/478. The SQL service just crashed after changing Collation. This only occurs for onprem image. I will follow up with you through that issue 478 from now on.
Determining Database Collation from c:\dl\onprem\16.4.14693.15445\na\database\Demo Database NAV (16-0).bak
Changing Database Server Collation to Latin1_General_100_CI_AS
Restoring CRONUS Demo Database
The database restore operation failed due to the following error returned by SQL Server:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allo
w remote connections. (provider: TCP Provider, error: 0 - The remote computer refused the network connection.)
at <ScriptBlock>, C:\Run\navinstall.ps1: line 182
at <ScriptBlock>, C:\Run\start.ps1: line 213
at <ScriptBlock>, <No file>: line 1

PS C:\> Get-Service *SQL*

Status   Name               DisplayName
------   ----               -----------
Stopped  MSSQL$SQLEXPRESS   SQL Server (SQLEXPRESS)

It will probably happen if you use a sandbox image, which uses a different collation than the original.

repo: microsoft/navcontainerhelper