问:
Android: How to hide the System UI properly
I'm developing a video player application and I've faced to a problem. I have a custom video controller which contains a fullscreen button and I want hide the System UI (navigation and status bars) when the user enters to fullscreen mode. I've tried to do something like this, but it doesn't work properly. My application is like the screenshot below:

When I click the fullscreen button, I change orientation to landscape and I hide the System UI, but my player doesn't get fullscreen. It looks like the screen below:

Also, when I tap the screen I want to show my video controller, but the System UI shows the below content, instead:

So, how can I implement this behavior? Below are my methods for fullscreen and hiding/showing the System UI:

```<code>@Override
public void toggleFullscreen() {
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mVideoContainer.getLayoutParams();
    if (!mFullscreen) {
             setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        hideSystemUI();
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        params.width = metrics.widthPixels;
        params.height = metrics.heightPixels;
        params.setMargins(0, 0, 0, 0);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        showSystemUI();
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        params.width = metrics.widthPixels;
        params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300, metrics);
            params.setMargins(0, 0, 0, 0);
    }
    mVideoContainer.setLayoutParams(params);
    mFullscreen = !mFullscreen;
}

private void hideSystemUI() {
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN)
    } else {
        uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }
    decorView.setSystemUiVisibility(uiOptions);
}

private void showSystemUI() {
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(0);
}
</code>```

Here's my layout:

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/video_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/videoSurfaceContainer"
        android:layout_width="match_parent"
        android:layout_height="300dp" >

        <SurfaceView
            android:id="@+id/videoSurface"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</LinearLayout>
</code>```

答:
Just call these methods when you want to hide/show the system UI. </p>

```<code>private void hideSystemUI() {
    View decorView = getActivity().getWindow().getDecorView();
    int uiOptions = decorView.getSystemUiVisibility();
    int newUiOptions = uiOptions;
    newUiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
    newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
    newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(newUiOptions);
}

private void showSystemUI() {
    View decorView = getActivity().getWindow().getDecorView();
    int uiOptions = decorView.getSystemUiVisibility();
    int newUiOptions = uiOptions;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(newUiOptions);
}
</code>```

Body:
I'm developing a video player application and I've faced to a problem. I have a custom video controller which contains a fullscreen button and I want hide the System UI (navigation and status bars) when the user enters to fullscreen mode. I've tried to do something like this, but it doesn't work properly. My application is like the screenshot below:

When I click the fullscreen button, I change orientation to landscape and I hide the System UI, but my player doesn't get fullscreen. It looks like the screen below:

Also, when I tap the screen I want to show my video controller, but the System UI shows the below content, instead:

So, how can I implement this behavior? Below are my methods for fullscreen and hiding/showing the System UI:

@Override
public void toggleFullscreen() {
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mVideoContainer.getLayoutParams();
    if (!mFullscreen) {
             setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        hideSystemUI();
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        params.width = metrics.widthPixels;
        params.height = metrics.heightPixels;
        params.setMargins(0, 0, 0, 0);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        showSystemUI();
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        params.width = metrics.widthPixels;
        params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300, metrics);
            params.setMargins(0, 0, 0, 0);
    }
    mVideoContainer.setLayoutParams(params);
    mFullscreen = !mFullscreen;
}

private void hideSystemUI() {
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN)
    } else {
        uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }
    decorView.setSystemUiVisibility(uiOptions);
}

private void showSystemUI() {
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(0);
}

Here's my layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/video_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/videoSurfaceContainer"
        android:layout_width="match_parent"
        android:layout_height="300dp" >

        <SurfaceView
            android:id="@+id/videoSurface"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</LinearLayout>

Body:
Just call these methods when you want to hide/show the system UI.

private void hideSystemUI() {
    View decorView = getActivity().getWindow().getDecorView();
    int uiOptions = decorView.getSystemUiVisibility();
    int newUiOptions = uiOptions;
    newUiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
    newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
    newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(newUiOptions);
}

private void showSystemUI() {
    View decorView = getActivity().getWindow().getDecorView();
    int uiOptions = decorView.getSystemUiVisibility();
    int newUiOptions = uiOptions;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE;
    newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(newUiOptions);
}


来源: stackexchange

问:
CredUIPromptForWindowsCredentials throws Microsoft C++ unhandled exception: winrt::hresult_error in background thread
Simplest C++ code that prompts user credential via CredUIPromptForWindowsCredentials API throws unhandled exception tied with XAML processing in background thread.

Code sample:

```<code>    CString me(_T("MYLOGING"));
    CString url(_T("Header"));
    CString message(_T("Enter credentials for ..."));

    CREDUI_INFOW credInfo;
    credInfo.pszCaptionText = url;
    credInfo.hbmBanner = nullptr;
    credInfo.hwndParent = m_hWnd;
    credInfo.pszMessageText = message;
    credInfo.cbSize = sizeof(CREDUI_INFOW);

    DWORD bufferSize = 1024;
    LPBYTE pBuffer = reinterpret_cast<LPBYTE>(CoTaskMemAlloc(bufferSize));
    CredPackAuthenticationBuffer(0, me.GetBuffer(), _T(""), pBuffer, &bufferSize);
    me.ReleaseBuffer();

    ULONG authPackage = 0;
    LPVOID outCredBuffer = nullptr;
    ULONG outCredSize = 0;
    BOOL save = false;

    auto result = CredUIPromptForWindowsCredentials(&credInfo,
        0,
        &authPackage,
        pBuffer,
        bufferSize,
        &outCredBuffer, &outCredSize, &save, CREDUIWIN_GENERIC | CREDUIWIN_ENUMERATE_CURRENT_USER | CREDUIWIN_CHECKBOX);
</code>```

It's native C++ ATL application. Main thread is initialized as OLE thread (STA).
Exception occurs in worker thread in SHCore.dll module.
Exception stack:

```<code>>   KernelBase.dll!RaiseException() Unknown Non-user code. Symbols loaded.
    ucrtbase.dll!_CxxThrowException()   Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::throw_hresult() Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::consume_Windows_ApplicationModel_Core_ICoreApplication<struct winrt::Windows::ApplicationModel::Core::ICoreApplication>::GetCurrentView(void) Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::factory_cache_entry<winrt::Windows::ApplicationModel::Core::CoreApplication,winrt::Windows::ApplicationModel::Core::ICoreApplication>::call<<lambda_bfab539c4ec1a908cc512cf8f1e69054> & __ptr64>()    Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!DispatcherHelper::InitializeFromUIThread() Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::produce<RevealBackgroundBrushFactory,winrt::Windows::UI::Xaml::Media::IRevealBackgroundBrushFactory>::CreateInstance()    Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::consume_Windows_UI_Xaml_Controls_IAppBarButtonFactory<struct winrt::Windows::UI::Xaml::Controls::IAppBarButtonFactory>::CreateInstance(struct winrt::Windows::Foundation::IInspectable const &,struct winrt::Windows::Foundation::IInspectable &) Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!Private::XamlRuntimeType::ActivateInstance()   Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.dll!00007ffc4c8084e2()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c80847c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9377f6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c97693b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d1466()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87e27a()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c829b41()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882ed5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c881d7c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882917()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c886ad5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88564b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884efe()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b52()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88505c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b9e()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e117f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e0e62()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4ca97f62()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d68ea()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d6212()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8821ec()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882917()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c886ad5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88564b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884efe()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b52()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88505c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b9e()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8c8fc1()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884cbd()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e117f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e0e62()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4ca98011()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d6793()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d5348()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d5024()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f3979()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8c1051()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f2b94()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f2c8d()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f60ab()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d6022()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d5f39()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88219f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882917()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c886ad5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88564b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8ef340()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f63d0()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d6022()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d5f39()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88219f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87dab6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c834e2f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c834d65()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8348f6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c834857()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c974b6c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c974c14()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c975388()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c974e55()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9ef2c8()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9ef1f7()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c976f05()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d117e()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c880617()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87e821()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c881d3b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87dab6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c95e3f1()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c994bdd()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c963967()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c963799()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c96368f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9635ea()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Cred.dll!Windows::UI::Xaml::Application::LoadComponent(class Platform::Object ^,class Windows::Foundation::Uri ^,enum Windows::UI::Xaml::Controls::Primitives::ComponentResourceLocation)    Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!CredUX::Frame::[CredUX::__IFramePublicNonVirtuals]::InitializeComponent(void)   Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!CredUX::Frame::Frame(class Platform::Object ^)  Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!PlatformExceptionNoThrowBoundaryCPlusPlus<<lambda_433453e7a9ea4a090df15fe007d36c45> >() Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!CredUXViewProviderImpl::GetView(struct IInspectable *,struct IInspectable * *)  Unknown Non-user code. Symbols loaded.
    Windows.UI.CredDialogController.dll!CredUXViewDefinition::v_GetRootElement(struct IInspectable *,struct _GUID const &,void * *) Unknown Non-user code. Symbols loaded.
    Windows.UI.CredDialogController.dll!ViewDefinitionBase::_EnsureViewInitialized(void)    Unknown Non-user code. Symbols loaded.
    Windows.UI.CredDialogController.dll!ViewDefinitionBase::get_RootUIElement(struct Windows::UI::Xaml::IUIElement * *) Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_InitializeXamlContent(void)    Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_CreateHostWindow(void) Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_Show(void) Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!DispatchableTaskWithContext<<lambda_c7ef36ba2d0f18b849cd80403bdd8ff8> >::Dispatch() Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!ASTAThreadHost::s_ASTAThreadHostStartThreadProc(void *) Unknown Non-user code. Symbols loaded.
    SHCore.dll!_WrapperThreadProc() Unknown Non-user code. Symbols loaded.
    kernel32.dll!BaseThreadInitThunk()  Unknown Non-user code. Symbols loaded.
    ntdll.dll!RtlUserThreadStart()  Unknown Non-user code. Symbols loaded.
</code>```

Does anybody know how fix it?
I can ignore this exception, in this case mentioned thread will be destroyed but Credential dialog is opened and looks like works fine.

I see this exception in Win10 1809 and 1903 builds. Older Win10 1803 build doesn't contain it.

UPDATE:
Windows 7 doesn't contain this bug also. So looks like as if it relates only Win10 builds with system components created with C++ WinRT.

UPDATE 2:
I've tried to debug place of crash (disassembled method winrt::impl::consume_Windows_ApplicationModel_Core_ICoreApplication<>()) and looks like HRESULT code from winrt::throw_hresult() exception is 80070490h.
What does it mean?
Trace output at exception moment:

```<code>'ME.exe' (Win32): Loaded 'D:\Proj\ME\x64\Debug\ME.exe'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\oleaut32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\mfc140ud.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.17763.737_none_05b6437c071e554b\comctl32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.17763.737_none_36a1366161b0cf19\GdiPlus.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\credui.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. Symbols loaded.
The thread 0x4b94 has exited with code 0 (0x0).
'ME.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\SHCore.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\windows.storage.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\profapi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\powrprof.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\crypt32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msasn1.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\TextInputFramework.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\CoreUIComponents.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\CoreMessaging.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ntmarta.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\WinTypes.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\WinTypes.dll'. Symbols loaded.
'ME.exe' (Win32): Unloaded 'C:\Windows\System32\WinTypes.dll'
'ME.exe' (Win32): Loaded 'C:\Windows\System32\wincredui.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\clbcatq.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.CredDialogController.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.XamlHost.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Cred.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\wincorlib.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\MrmCoreR.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\InputHost.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\d2d1.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\twinapi.appcore.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\d3d11.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\rmclient.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\dxgi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\propsys.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\LanguageOverlayUtil.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\BCP47mrm.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Xaml.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\BCP47Langs.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\iertutil.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\dcomp.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Immersive.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\urlmon.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ResourcePolicyClient.dll'. Symbols loaded.
onecore\base\appmodel\statemanager\apiset\lib\statespace.cpp(107)\kernelbase.dll!00007FFC6F439258: (caller: 00007FFC6F43910B) ReturnHr(1) tid(5204) 80073D54 Процесс не имеет идентификатора пакета.
onecore\base\appmodel\statemanager\apiset\lib\statemanager.cpp(53)\kernelbase.dll!00007FFC6F43914B: (caller: 00007FFC4C894AB5) ReturnHr(2) tid(5204) 80073D54 Процесс не имеет идентификатора пакета.
'ME.exe' (Win32): Unloaded 'C:\Windows\System32\ResourcePolicyClient.dll'
'ME.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_9172c4e962e5b3ee\nvldumdx.dll'. Cannot find or open the PDB file.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\wintrust.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\imagehlp.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_9172c4e962e5b3ee\nvwgf2umx.dll'. Cannot find or open the PDB file.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\winmmbase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\Ansel\Tools\NvCameraWhitelisting64.dll'. Cannot find or open the PDB file.
The thread 0x1248 has exited with code 0 (0x0).
'ME.exe' (Win32): Unloaded 'C:\Program Files\NVIDIA Corporation\Ansel\Tools\NvCameraWhitelisting64.dll'
'ME.exe' (Win32): Loaded 'C:\Windows\System32\DWrite.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Xaml.Controls.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.ApplicationModel.dll'. Symbols loaded.
The thread 0x2210 has exited with code 0 (0x0).
Exception thrown at 0x00007FFC6F469129 (KernelBase.dll) in ME.exe: 0x40080202: WinRT transform error (parameters: 0x000000008000000B, 0x0000000080070490, 0x0000000000000014, 0x00000091846FB080).
Exception thrown at 0x00007FFC6F469129 in ME.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x00000091846FB500.
</code>```

答:
After a long trial and error phase I set

```<code>credInfo.hwndParent = NULL;
</code>```

and it worked. The downside is that the dialog is not centered anymore. Until now I thought that this issue only occured whe using Qt.

ContentLicense: CC BY-SA 4.0

Body:
Simplest C++ code that prompts user credential via CredUIPromptForWindowsCredentials API throws unhandled exception tied with XAML processing in background thread.

Code sample:

    CString me(_T("MYLOGING"));
    CString url(_T("Header"));
    CString message(_T("Enter credentials for ..."));

    CREDUI_INFOW credInfo;
    credInfo.pszCaptionText = url;
    credInfo.hbmBanner = nullptr;
    credInfo.hwndParent = m_hWnd;
    credInfo.pszMessageText = message;
    credInfo.cbSize = sizeof(CREDUI_INFOW);

    DWORD bufferSize = 1024;
    LPBYTE pBuffer = reinterpret_cast<LPBYTE>(CoTaskMemAlloc(bufferSize));
    CredPackAuthenticationBuffer(0, me.GetBuffer(), _T(""), pBuffer, &bufferSize);
    me.ReleaseBuffer();

    ULONG authPackage = 0;
    LPVOID outCredBuffer = nullptr;
    ULONG outCredSize = 0;
    BOOL save = false;

    auto result = CredUIPromptForWindowsCredentials(&credInfo,
        0,
        &authPackage,
        pBuffer,
        bufferSize,
        &outCredBuffer, &outCredSize, &save, CREDUIWIN_GENERIC | CREDUIWIN_ENUMERATE_CURRENT_USER | CREDUIWIN_CHECKBOX);

It's native C++ ATL application. Main thread is initialized as OLE thread (STA).
Exception occurs in worker thread in SHCore.dll module.
Exception stack:

>   KernelBase.dll!RaiseException() Unknown Non-user code. Symbols loaded.
    ucrtbase.dll!_CxxThrowException()   Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::throw_hresult() Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::consume_Windows_ApplicationModel_Core_ICoreApplication<struct winrt::Windows::ApplicationModel::Core::ICoreApplication>::GetCurrentView(void) Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::factory_cache_entry<winrt::Windows::ApplicationModel::Core::CoreApplication,winrt::Windows::ApplicationModel::Core::ICoreApplication>::call<<lambda_bfab539c4ec1a908cc512cf8f1e69054> & __ptr64>()    Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!DispatcherHelper::InitializeFromUIThread() Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::produce<RevealBackgroundBrushFactory,winrt::Windows::UI::Xaml::Media::IRevealBackgroundBrushFactory>::CreateInstance()    Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!winrt::impl::consume_Windows_UI_Xaml_Controls_IAppBarButtonFactory<struct winrt::Windows::UI::Xaml::Controls::IAppBarButtonFactory>::CreateInstance(struct winrt::Windows::Foundation::IInspectable const &,struct winrt::Windows::Foundation::IInspectable &) Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.Controls.dll!Private::XamlRuntimeType::ActivateInstance()   Unknown Non-user code. Symbols loaded.
    Windows.UI.Xaml.dll!00007ffc4c8084e2()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c80847c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9377f6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c97693b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d1466()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87e27a()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c829b41()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882ed5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c881d7c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882917()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c886ad5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88564b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884efe()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b52()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88505c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b9e()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e117f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e0e62()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4ca97f62()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d68ea()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d6212()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8821ec()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882917()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c886ad5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88564b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884efe()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b52()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88505c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884b9e()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8c8fc1()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c884cbd()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e117f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8e0e62()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4ca98011()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d6793()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d5348()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d5024()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f3979()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8c1051()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f2b94()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f2c8d()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f60ab()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d6022()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d5f39()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88219f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c882917()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c886ad5()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88564b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8ef340()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8f63d0()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d6022()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9d5f39()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c88219f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87dab6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c834e2f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c834d65()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8348f6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c834857()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c974b6c()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c974c14()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c975388()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c974e55()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9ef2c8()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9ef1f7()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c976f05()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c8d117e()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c880617()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87e821()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c881d3b()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c87dab6()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c95e3f1()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c994bdd()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c963967()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c963799()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c96368f()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Xaml.dll!00007ffc4c9635ea()  Unknown Non-user code. Cannot find or open the PDB file.
    Windows.UI.Cred.dll!Windows::UI::Xaml::Application::LoadComponent(class Platform::Object ^,class Windows::Foundation::Uri ^,enum Windows::UI::Xaml::Controls::Primitives::ComponentResourceLocation)    Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!CredUX::Frame::[CredUX::__IFramePublicNonVirtuals]::InitializeComponent(void)   Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!CredUX::Frame::Frame(class Platform::Object ^)  Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!PlatformExceptionNoThrowBoundaryCPlusPlus<<lambda_433453e7a9ea4a090df15fe007d36c45> >() Unknown Non-user code. Symbols loaded.
    Windows.UI.Cred.dll!CredUXViewProviderImpl::GetView(struct IInspectable *,struct IInspectable * *)  Unknown Non-user code. Symbols loaded.
    Windows.UI.CredDialogController.dll!CredUXViewDefinition::v_GetRootElement(struct IInspectable *,struct _GUID const &,void * *) Unknown Non-user code. Symbols loaded.
    Windows.UI.CredDialogController.dll!ViewDefinitionBase::_EnsureViewInitialized(void)    Unknown Non-user code. Symbols loaded.
    Windows.UI.CredDialogController.dll!ViewDefinitionBase::get_RootUIElement(struct Windows::UI::Xaml::IUIElement * *) Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_InitializeXamlContent(void)    Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_CreateHostWindow(void) Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_Show(void) Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!DispatchableTaskWithContext<<lambda_c7ef36ba2d0f18b849cd80403bdd8ff8> >::Dispatch() Unknown Non-user code. Symbols loaded.
    Windows.UI.XamlHost.dll!ASTAThreadHost::s_ASTAThreadHostStartThreadProc(void *) Unknown Non-user code. Symbols loaded.
    SHCore.dll!_WrapperThreadProc() Unknown Non-user code. Symbols loaded.
    kernel32.dll!BaseThreadInitThunk()  Unknown Non-user code. Symbols loaded.
    ntdll.dll!RtlUserThreadStart()  Unknown Non-user code. Symbols loaded.

Does anybody know how fix it?
I can ignore this exception, in this case mentioned thread will be destroyed but Credential dialog is opened and looks like works fine.

I see this exception in Win10 1809 and 1903 builds. Older Win10 1803 build doesn't contain it.

UPDATE:
Windows 7 doesn't contain this bug also. So looks like as if it relates only Win10 builds with system components created with C++ WinRT.

UPDATE 2:
I've tried to debug place of crash (disassembled method winrt::impl::consume_Windows_ApplicationModel_Core_ICoreApplication<>()) and looks like HRESULT code from winrt::throw_hresult() exception is 80070490h.
What does it mean?
Trace output at exception moment:

'ME.exe' (Win32): Loaded 'D:\Proj\ME\x64\Debug\ME.exe'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\oleaut32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\mfc140ud.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.17763.737_none_05b6437c071e554b\comctl32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.17763.737_none_36a1366161b0cf19\GdiPlus.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\credui.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. Symbols loaded.
The thread 0x4b94 has exited with code 0 (0x0).
'ME.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\SHCore.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\windows.storage.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\profapi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\powrprof.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\crypt32.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\msasn1.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\TextInputFramework.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\CoreUIComponents.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\CoreMessaging.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ntmarta.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\WinTypes.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\WinTypes.dll'. Symbols loaded.
'ME.exe' (Win32): Unloaded 'C:\Windows\System32\WinTypes.dll'
'ME.exe' (Win32): Loaded 'C:\Windows\System32\wincredui.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\clbcatq.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.CredDialogController.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.XamlHost.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Cred.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\wincorlib.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\MrmCoreR.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\InputHost.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\d2d1.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\twinapi.appcore.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\d3d11.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\rmclient.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\dxgi.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\propsys.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\LanguageOverlayUtil.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\BCP47mrm.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Xaml.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\BCP47Langs.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\iertutil.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\dcomp.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Immersive.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\urlmon.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\ResourcePolicyClient.dll'. Symbols loaded.
onecore\base\appmodel\statemanager\apiset\lib\statespace.cpp(107)\kernelbase.dll!00007FFC6F439258: (caller: 00007FFC6F43910B) ReturnHr(1) tid(5204) 80073D54 Процесс не имеет идентификатора пакета.
onecore\base\appmodel\statemanager\apiset\lib\statemanager.cpp(53)\kernelbase.dll!00007FFC6F43914B: (caller: 00007FFC4C894AB5) ReturnHr(2) tid(5204) 80073D54 Процесс не имеет идентификатора пакета.
'ME.exe' (Win32): Unloaded 'C:\Windows\System32\ResourcePolicyClient.dll'
'ME.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_9172c4e962e5b3ee\nvldumdx.dll'. Cannot find or open the PDB file.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\wintrust.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\imagehlp.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_9172c4e962e5b3ee\nvwgf2umx.dll'. Cannot find or open the PDB file.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\winmmbase.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\Ansel\Tools\NvCameraWhitelisting64.dll'. Cannot find or open the PDB file.
The thread 0x1248 has exited with code 0 (0x0).
'ME.exe' (Win32): Unloaded 'C:\Program Files\NVIDIA Corporation\Ansel\Tools\NvCameraWhitelisting64.dll'
'ME.exe' (Win32): Loaded 'C:\Windows\System32\DWrite.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.UI.Xaml.Controls.dll'. Symbols loaded.
'ME.exe' (Win32): Loaded 'C:\Windows\System32\Windows.ApplicationModel.dll'. Symbols loaded.
The thread 0x2210 has exited with code 0 (0x0).
Exception thrown at 0x00007FFC6F469129 (KernelBase.dll) in ME.exe: 0x40080202: WinRT transform error (parameters: 0x000000008000000B, 0x0000000080070490, 0x0000000000000014, 0x00000091846FB080).
Exception thrown at 0x00007FFC6F469129 in ME.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x00000091846FB500.

Body:
After a long trial and error phase I set

credInfo.hwndParent = NULL;

and it worked. The downside is that the dialog is not centered anymore. Until now I thought that this issue only occured whe using Qt.


问:
Updating service [default] (this may take several minutes)...failed
This used to be working perfectly until a couple of days back exactly 4 days back. When i run gcloud app deploy now it complete the build and then straight after completing the build it hangs on Updating Service

Here is the output:

```<code>Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [13] Flex operation projects/just-sleek/regions/us-central1/operations/8260bef8-b882-4313-bf97-efff8d603c5f error [INTERNAL]: An internal error occurred while processing task /appengine-flex-v1/insert_flex_deployment/flex_create_resources>2020-05-26T05:20:44.032Z4316.jc.11: Deployment Manager operation just-sleek/operation-1590470444486-5a68641de8da1-5dfcfe5c-b041c398 errors: [
code: "RESOURCE_ERROR"
location: "/deployments/aef-default-20200526t070946/resources/aef-default-20200526t070946"
message: {
\"ResourceType\":\"compute.beta.regionAutoscaler\",
\"ResourceErrorCode\":\"403\",
\"ResourceErrorMessage\":{
\"code\":403,
\"errors\":[{
\"domain\":\"usageLimits\",
\"message\":\"Exceeded limit \'QUOTA_FOR_INSTANCES\' on resource \'aef-default-20200526t070946\'. Limit: 8.0\",
\"reason\":\"limitExceeded\"
}],
\"message\":\"Exceeded limit \'QUOTA_FOR_INSTANCES\' on resource \'aef-default-20200526t070946\'. Limit: 8.0\",
\"statusMessage\":\"Forbidden\",
\"requestPath\":\"https://compute.googleapis.com/compute/beta/projects/just-sleek/regions/us-central1/autoscalers\",
\"httpMethod\":\"POST\"
}
}"]
</code>```

I tried the following the ways to resolve the error:

I deleted all my previous version and left the running version

I ran gcloud components update still fails.

I create a new project, changed the region from [REGION1] to [REGION2] and deployed and m still getting the same error.

Also ran gcloud app deploy --verbosity=debug, does not give me any different result

I have no clue what is causing this issue and how to solve it please assist.

答:
I resolved this by adding this into my app.yaml

```<code>automatic_scaling:
  min_num_instances: 1
  max_num_instances: 7
</code>```

I found the solution here:
https://issuetracker.google.com/issues/157449521

And I was also redirected to:

gcloud app deploy - updating service default fails with code 13 Quota for instances limit exceeded, and 401 unathorizeed

Body:
This used to be working perfectly until a couple of days back exactly 4 days back. When i run gcloud app deploy now it complete the build and then straight after completing the build it hangs on Updating Service

Here is the output:

Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [13] Flex operation projects/just-sleek/regions/us-central1/operations/8260bef8-b882-4313-bf97-efff8d603c5f error [INTERNAL]: An internal error occurred while processing task /appengine-flex-v1/insert_flex_deployment/flex_create_resources>2020-05-26T05:20:44.032Z4316.jc.11: Deployment Manager operation just-sleek/operation-1590470444486-5a68641de8da1-5dfcfe5c-b041c398 errors: [
code: "RESOURCE_ERROR"
location: "/deployments/aef-default-20200526t070946/resources/aef-default-20200526t070946"
message: {
\"ResourceType\":\"compute.beta.regionAutoscaler\",
\"ResourceErrorCode\":\"403\",
\"ResourceErrorMessage\":{
\"code\":403,
\"errors\":[{
\"domain\":\"usageLimits\",
\"message\":\"Exceeded limit \'QUOTA_FOR_INSTANCES\' on resource \'aef-default-20200526t070946\'. Limit: 8.0\",
\"reason\":\"limitExceeded\"
}],
\"message\":\"Exceeded limit \'QUOTA_FOR_INSTANCES\' on resource \'aef-default-20200526t070946\'. Limit: 8.0\",
\"statusMessage\":\"Forbidden\",
\"requestPath\":\"https://compute.googleapis.com/compute/beta/projects/just-sleek/regions/us-central1/autoscalers\",
\"httpMethod\":\"POST\"
}
}"]

I tried the following the ways to resolve the error:

I deleted all my previous version and left the running version

I ran gcloud components update still fails.

I create a new project, changed the region from [REGION1] to [REGION2] and deployed and m still getting the same error.

Also ran gcloud app deploy --verbosity=debug, does not give me any different result

I have no clue what is causing this issue and how to solve it please assist.

Body:
I resolved this by adding this into my app.yaml

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 7

I found the solution here:
https://issuetracker.google.com/issues/157449521

And I was also redirected to:

gcloud app deploy - updating service default fails with code 13 Quota for instances limit exceeded, and 401 unathorizeed


问:
Getting: unknown directive "js_import" when njs used with Nginx
I am making the following statement in the Nginx conf:

```<code>js_import http.js;
</code>```

But it seems to give me unknown directive "js_import"

I have verified whether the njs is installed. I can seem to get into the cli. Version of njs is 0.3.9

The below statement seems to be working and is placehttp block:

```<code>js_include http.js
</code>```

This also seem to work and is placed in the server block inside http block:

```<code>js_content hello
</code>```

Nginx seems to be the latest version.

I cannot seems to find what I am missing here.

Any help is greatly appreciated.

答:
reading this and putting

load_module /usr/lib/nginx/modules/ngx_http_js_module.so;

at the top of my nginx.conf solved my problem you may need to put something like this

load_module modules/ngx_http_js_module.so;

Body:
I am making the following statement in the Nginx conf:

js_import http.js;

But it seems to give me unknown directive "js_import"

I have verified whether the njs is installed. I can seem to get into the cli. Version of njs is 0.3.9

The below statement seems to be working and is placehttp block:

js_include http.js

This also seem to work and is placed in the server block inside http block:

js_content hello

Nginx seems to be the latest version.

I cannot seems to find what I am missing here.

Any help is greatly appreciated.


问:
django list_filter in html

How do i import this list_filter into my html? do you have any documentation that easy to follow and easy to understand? is it possible?

```<code>class ArticleListView(ListView):

    model = StudentsEnrollmentRecord
    s=StudentsEnrollmentRecord.objects.all()
    paginate_by = 50  # if pagination is desired
    searchable_fields = ["Student_Users", "id", "Section"]
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['now'] = timezone.now()
        return context
</code>```

答:
You can use template tags to loop your object and populate your html:

https://docs.djangoproject.com/en/3.0/ref/templates/builtins/

To give you a kickstart:

```<code><ul>

{% for filter in s %}

<li>{{ filter.Student_Users }}</li>

{% endfor %}

</ul>
</code>```

This will basically create one
 per each item in your queryset.
Make sure that the required data is returned properly from your view via the context:

```<code>context = {
        'queryset': s,
    }
    return (context)
</code>```

Title: django list_filter in html

Body:
How do i import this list_filter into my html? do you have any documentation that easy to follow and easy to understand? is it possible?

class ArticleListView(ListView):

    model = StudentsEnrollmentRecord
    s=StudentsEnrollmentRecord.objects.all()
    paginate_by = 50  # if pagination is desired
    searchable_fields = ["Student_Users", "id", "Section"]
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['now'] = timezone.now()
        return context

Body:
You can use template tags to loop your object and populate your html:

https://docs.djangoproject.com/en/3.0/ref/templates/builtins/

To give you a kickstart:

<ul>

{% for filter in s %}

<li>{{ filter.Student_Users }}</li>

{% endfor %}

</ul>

This will basically create one <li> per each item in your queryset.
Make sure that the required data is returned properly from your view via the context:

context = {
        'queryset': s,
    }
    return (context)


问:
Command for loading postgres through docker?
Does anyone know the command for loading postgres through docker? Here is the recommended command on their documentation:

```<code>docker run -it --rm --network some-network postgres psql -h some-postgres -U postgres
</code>```

Forgive the naive question, how do you find what values for "some-network" are supposed to be and what values "some-postgres" is supposed to be?

答:
To be precise, each flag has a own meaning in the docker run command.

```<code>docker run -it --rm --network some-network postgres psql -h some-postgres -U postgres
</code>```

-i: Keep STDIN open even if not attached

-t: Allocate a pseudo-TTY

--rm: Automatically remove the container when it exits

--network: Connect a container to a network. You can ignore this if you are running a standalone postgress container or you can use host mode if you want the container to use host networking. For more information and modes. Check below article.

Ref:- https://docs.docker.com/network/

psql -h some-postgres -U postgres : Final command you are passing to postgres

Body:
Does anyone know the command for loading postgres through docker? Here is the recommended command on their documentation:

docker run -it --rm --network some-network postgres psql -h some-postgres -U postgres

Forgive the naive question, how do you find what values for "some-network" are supposed to be and what values "some-postgres" is supposed to be?

Body:
To be precise, each flag has a own meaning in the docker run command.

docker run -it --rm --network some-network postgres psql -h some-postgres -U postgres

-i: Keep STDIN open even if not attached

-t: Allocate a pseudo-TTY

--rm: Automatically remove the container when it exits

--network: Connect a container to a network. You can ignore this if you are running a standalone postgress container or you can use host mode if you want the container to use host networking. For more information and modes. Check below article.

Ref:- https://docs.docker.com/network/

psql -h some-postgres -U postgres : Final command you are passing to postgres


问:
How do you move a button up or down, left or right and enlarge or shrink it in html
I have looked all across the internet and all I have found is that you have to use CSS to do this. However, I don't know what CSS would move it left or right, down or up and enlarge or shrink it. Hopefully, someone knows how to do it. thanks.</p>

答:
For moving the button let's imagine that the Button's class is btn

```<code><button class='btn'>Click Me!</button>
</code>```

To move the button 5 to right 4 to left 2 to up and 4 to down the css would be

```<code>.btn {
  position:relative;
  right:5;
  left:4;
  top:2;
  bottom:4;
}
</code>```

And for shrinking the button you can set the padding accordingly

```<code>.btn{
  padding:5;
}
</code>```

Body:
For moving the button let's imagine that the Button's class is btn

<button class='btn'>Click Me!</button>

To move the button 5 to right 4 to left 2 to up and 4 to down the css would be

.btn {
  position:relative;
  right:5;
  left:4;
  top:2;
  bottom:4;
}

And for shrinking the button you can set the padding accordingly

.btn{
  padding:5;
}


问:
How to run multiple SQL queries?
I have a create table query, an update query ,and then drop table query. I need to run these three queries in one shot. What is the best way to do this?

```<code>Example
1st Query: Create table A.
2nd Query: Update value in table A
3rd Query: Drop table A.
</code>```

Instead of running these three queries one by one, I want to run them in on go either by PLSQL or some other way. Please help.

答: Simply put three queries one after the other in a .sql file, with semi-colons after each statement, then execute it as a script (either on a SQL*Plus prompt using @scriptname.sql or in TOAD/SQL Developer [or equivalent] using its script execution function).

ContentLicense: CC BY-SA 3.0

Title: How to run multiple SQL queries?

Body:
I have a create table query, an update query ,and then drop table query. I need to run these three queries in one shot. What is the best way to do this?

Example
1st Query: Create table A.
2nd Query: Update value in table A
3rd Query: Drop table A.

Instead of running these three queries one by one, I want to run them in on go either by PLSQL or some other way. Please help.


问:
Flutter Error : Exception: type 'int' is not a subtype of type 'String'
How it be happend ? i think it happend when i doin json mapping. it said Exception: type 'int' is not a subtype of type 'String'. I've tried using local json assets file but it not make different. Please help me with this problem.

```<code>class Product {
  int productId;
  String productName;
  String productPrice;

  Product({this.productId, this.productName, this.productPrice});

  Product.fromProduct(Product p) {
    this.productId = p.productId;
    this.productName = p.productName;
    this.productPrice = p.productPrice;
  }

  factory Product.fromJson(Map<String, dynamic> parsedJson) {
    return Product(
        productId: parsedJson['ID'],
        productName: parsedJson['Name'],
        productPrice: parsedJson['SellPrice']);
  }
}

Future<String> _loadAProductAsset() async {
  var res = await http.get(Uri.encodeFull("http://10.0.2.2:9155/product"));
  return json.encode(json.decode(res.body)["data"]);
}

List<Product> parseProduct(String myJson) {
  final parsed = json.decode(myJson).cast<Map<String, dynamic>>();
  return parsed.map<Product>((json) => Product.fromJson(json)).toList();
}

Future<List<Product>> fetchProduct() async {
  await wait(1);
  String jsonString = await _loadAProductAsset();
  return compute(parseProduct, jsonString);
}

Future wait(int s) {
  return new Future.delayed(Duration(seconds: s), () => {});
}

</code>```

this is my json from _loadAProductAsset() function

```<code>[
  {
    "ID": 2,
    "CreatedAt": "2020-01-06T03:56:32+07:00",
    "UpdatedAt": "2020-01-06T03:56:32+07:00",
    "DeletedAt": null,
    "Name": "Product A",
    "Category": "0",
    "Stock": "50",
    "StockUnit": "0",
    "BuyPrice": "20000",
    "SellPrice": "21000",
    "SupplierID": "1"
  }
]
</code>```

答:
For some reason I had this issue and I already did json.decode(response) earlier but I had to do it again just before doing MyModel.fromJson(response)

So what I typically recommend is

```<code>import 'dart:convert';
.
.
.
.
var decodedJson = json.decode(decode);
MyModel model = MyModel.fromJson(decodedJson);
</code>```

The above worked for me.

Body:
How it be happend ? i think it happend when i doin json mapping. it said Exception: type 'int' is not a subtype of type 'String'. I've tried using local json assets file but it not make different. Please help me with this problem.

class Product {
  int productId;
  String productName;
  String productPrice;

  Product({this.productId, this.productName, this.productPrice});

  Product.fromProduct(Product p) {
    this.productId = p.productId;
    this.productName = p.productName;
    this.productPrice = p.productPrice;
  }

  factory Product.fromJson(Map<String, dynamic> parsedJson) {
    return Product(
        productId: parsedJson['ID'],
        productName: parsedJson['Name'],
        productPrice: parsedJson['SellPrice']);
  }
}

Future<String> _loadAProductAsset() async {
  var res = await http.get(Uri.encodeFull("http://10.0.2.2:9155/product"));
  return json.encode(json.decode(res.body)["data"]);
}

List<Product> parseProduct(String myJson) {
  final parsed = json.decode(myJson).cast<Map<String, dynamic>>();
  return parsed.map<Product>((json) => Product.fromJson(json)).toList();
}

Future<List<Product>> fetchProduct() async {
  await wait(1);
  String jsonString = await _loadAProductAsset();
  return compute(parseProduct, jsonString);
}

Future wait(int s) {
  return new Future.delayed(Duration(seconds: s), () => {});
}

this is my json from _loadAProductAsset() function

[
  {
    "ID": 2,
    "CreatedAt": "2020-01-06T03:56:32+07:00",
    "UpdatedAt": "2020-01-06T03:56:32+07:00",
    "DeletedAt": null,
    "Name": "Product A",
    "Category": "0",
    "Stock": "50",
    "StockUnit": "0",
    "BuyPrice": "20000",
    "SellPrice": "21000",
    "SupplierID": "1"
  }
]

Body:
For some reason I had this issue and I already did json.decode(response) earlier but I had to do it again just before doing MyModel.fromJson(response)

So what I typically recommend is

import 'dart:convert';
.
.
.
.
var decodedJson = json.decode(decode);
MyModel model = MyModel.fromJson(decodedJson);

The above worked for me.


问:
How to call a function after closing a popover?
I hope someone can give a beginner some guidance, my problem is this:

I have a popover window
I open that popover with a segue from the mainViewController
I want to trigger a function in the mainViewController when the popover is closed
Inside the popover I have a button to close the popover with the following code:

```<code>@IBAction func closeButton(_ sender: Any) {

        dismiss(animated: true, completion: {checkIfPopoverDismissed()}) // I want to trigger this function in the mainView
    }
</code>```

In the mainViewController I have the following function, that I want to be triggered by the closure of the above popover

```<code> func checkIfPopoverDismissed()
    {
      print("the function is triggered")
    }
</code>```

So with the above I get:

```<code> Use of unresolved identifier 'checkIfPopoverDismissed'
</code>```

Because obviously checkIfPopoverDismissed() is in the mainViewController and does not exist in the popover view.

Any idea how I can make this work simply?

答:
What you need is an unwind segue. A feature that seems to be missed often.

Check the official documentation here:
https://developer.apple.com/documentation/uikit/resource_management/dismissing_a_view_controller_with_an_unwind_segue

What the linked page does not show is that you can also control-drag from the "View Controller" icon directly to the "Exit" icon to create a manual segue you can call from code if you want to do some validation first.

In the above example, unwindHere was defined in the main view controller as:

```<code>@IBAction func unwindHere(unwindSegue: UIStoryboardSegue) {
    if let sourceVC = unwindSegue.source as? PopoverViewController {
        // Do stuff
    }
}
</code>```

EDIT: The action you'd use in PopoverViewController could look like this:

```<code>@IBAction func closeButtonTapped(_ sender: UIButton) {
    performSegue(withIdentifier: "ExitPopover", sender: self)
}
</code>```

Here, "ExitPopover" is the identifier of the unwind segue.

Body:
I hope someone can give a beginner some guidance, my problem is this:

I have a popover window
I open that popover with a segue from the mainViewController
I want to trigger a function in the mainViewController when the popover is closed
Inside the popover I have a button to close the popover with the following code:

@IBAction func closeButton(_ sender: Any) {

        dismiss(animated: true, completion: {checkIfPopoverDismissed()}) // I want to trigger this function in the mainView
    }

In the mainViewController I have the following function, that I want to be triggered by the closure of the above popover

 func checkIfPopoverDismissed()
    {
      print("the function is triggered")
    }

So with the above I get:

 Use of unresolved identifier 'checkIfPopoverDismissed'

Because obviously checkIfPopoverDismissed() is in the mainViewController and does not exist in the popover view.

Any idea how I can make this work simply?

Body:
What you need is an unwind segue. A feature that seems to be missed often.

Check the official documentation here:
https://developer.apple.com/documentation/uikit/resource_management/dismissing_a_view_controller_with_an_unwind_segue

What the linked page does not show is that you can also control-drag from the "View Controller" icon directly to the "Exit" icon to create a manual segue you can call from code if you want to do some validation first.

In the above example, unwindHere was defined in the main view controller as:

@IBAction func unwindHere(unwindSegue: UIStoryboardSegue) {
    if let sourceVC = unwindSegue.source as? PopoverViewController {
        // Do stuff
    }
}

EDIT: The action you'd use in PopoverViewController could look like this:

@IBAction func closeButtonTapped(_ sender: UIButton) {
    performSegue(withIdentifier: "ExitPopover", sender: self)
}

Here, "ExitPopover" is the identifier of the unwind segue.


问:
It is feasible to generate client-side scripts on the server in realtime?
I'm working on an application where there are a number of available resources that differ on an hour-by-hour basis, and loading all permutations in the client would result in a very, very large script.

I'm strongly considering having the server dynamically generate a minified script combining all currently optimal resources, preloaded with configuration and user-specific credentials (only loaded if logged in, of course), in realtime. The script isn't needed until after the user interacts with the page, so it can safely be loaded client-side with defer allowing the server the milliseconds it needs to do its thing, and round trip time on the network. I've considered that this does prevent caching the script, and I'm not sure this is a problem given how it's currently built. In other words, something like this:

```<code><script defer type="text/javascript" src="/dynamically-generated-script.js"></script>
</code>```

I figured this is the perfect type of question to ask the community here at Stack Overflow, given I've never tried realtime dynamic script generation like this, and I could definitely see it being a tried and tested (and possibly failed) practice that I'm just not aware of.

Is this a reasonable thing to do?

答:
It's feasible, but i would strongly recommend against it for the following reasons:

Once the script is dynamically generated, you will lose many layers of optimizations, starting from the browser caching the script, and up to hosting the script on a CDN.

The fact that the script can not be cached means that you are moving away from the most recent trends of Web development:  progressive web apps (PWA), and Accelerated mobile pages (AMP)

Error handling from the client side become an extremely hard issue, because basically you have a script for each user. error reporting services like sentry, will not be able to identify identical errors (since each error will be generated from a different file)

Security, performance, and even general code quality will be hard to measure and control, since again you have an extremely large number of different code.

You wont be able to do any static analysis on these generated files, so you lose access to many of the tools that help developers write better code - you may still be able to do static analysis on the code that generates these dynamic scripts, however that is another thing.

Analytics on usage might also suffer, depending on how advanced the analytics that you wanna do.

All that being said, i would strongly consider other solutions. I dont know the exact requirements, so its hard to tell exactly, however i noticed two things:

You said that you wanna move credentials and configurations to the client side, this is a bad practice, even if the customer need a large diverse number of configurations and credentials - especially credentials. These should be saved on the server side, and can be accessed by the client side once client is authorised based on one credential -usually a token stored in cookies. You may say i need these credentials to do some requests from the client to 3rd party services, if that is  the case then you should be doing these requests from your server side, and the client should be calling the server side instead of calling these 3rd party services directly.

code is often not a dynamic thing, because code itself enables you to do control flow - its the data that the code interacts with that is often dynamic. What  i'm trying to say here is that it is hard to imagine requirements that makes you need different code for each different user - in some cases you may want to have different versions of code but that is a different thing.

To expand upon the previous point, i think the solution to your problem, is that you load the script that has all the code that is needed, and then based on different conditions you execute certain paths of code. You may still want to load dynamic data based on dynamic conditions and this can be done by calling the server. Even if u really had to do certain functionality that is truly dynamic for each user, then such functionality should be exposed behind an api that will be called from the client.

Body:
I'm working on an application where there are a number of available resources that differ on an hour-by-hour basis, and loading all permutations in the client would result in a very, very large script.

I'm strongly considering having the server dynamically generate a minified script combining all currently optimal resources, preloaded with configuration and user-specific credentials (only loaded if logged in, of course), in realtime. The script isn't needed until after the user interacts with the page, so it can safely be loaded client-side with defer allowing the server the milliseconds it needs to do its thing, and round trip time on the network. I've considered that this does prevent caching the script, and I'm not sure this is a problem given how it's currently built. In other words, something like this:

I figured this is the perfect type of question to ask the community here at Stack Overflow, given I've never tried realtime dynamic script generation like this, and I could definitely see it being a tried and tested (and possibly failed) practice that I'm just not aware of.

Is this a reasonable thing to do?


问:
nuxt js "Failed to execute 'appendChild' on 'Node': This node type does not support this method" on mobile view port
found this error when trying to run my nuxtjs app with vuetify on mobile viewport, but everything runs well on desktop viewport.

error on local machine image : error on local machine :

The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside
, or missing
. Bailing hydration and performing full client-side render.

error on server with ubuntu and nginx running my nuxtjs app with pm2 using
yarn build then pm2 start yarn -- start
image : error on server

DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method.

both errors occur in the same scenario.

when i run it on desktop viewport, then switch to mobile viewport (without reloading the page) it runs well. but if i reload it on mobile viewport, these error occur.

not sure which page I should share because this error occur on all pages even on the nuxt+vuetify default homepage.

currently the same error also occur on desktop viewport, but it's fixed by wrapping my component inside <client-only></client-only>,and error gone from desktop viewport but still occur on mobile viewport.

答: If you use asyncData put the section of template that render it in <client-only> tag, If you add the code people can better help you


问:
Convert multiple columned dataframe to 3D matrix in R
I have a dataframe similar to the one below:

```<code>trial Card1_colour Card1_number Card1_shape Card2_colour Card2_number Card2_shape  ......
1        1                1           0           0           1            1
2        0                0           0           1           1            1
3        1                0           0           0           0            0
4        0                0           1           0           0            1
5        1                1           1           1           0            1
.
.
.
.

</code>```

Except my actual dataframe has 12 'Card' variables, Card1_colour : Card4_shape.

```<code>#Code for generating example data

data<-matrix(rbinom(20*12, 1, .5), ncol=12)
trial<-seq(from = 1, to = 20)

data<-cbind(trial,data)
data<-as.data.frame(data)

colnames(data)[2] <- "Card1_colour"
colnames(data)[3] <- "Card1_number"
colnames(data)[4] <- "Card1_shape"
colnames(data)[5] <- "Card2_colour"
colnames(data)[6] <- "Card2_number"
colnames(data)[7] <- "Card2_shape"
colnames(data)[8] <- "Card3_colour"
colnames(data)[9] <- "Card3_number"
colnames(data)[10] <- "Card3_shape"
colnames(data)[11] <- "Card4_colour"
colnames(data)[12] <- "Card4_number"
colnames(data)[13] <- "Card4_shape"

</code>```

I want to reshape my data into an n(trial) x 4 x 3 matrix that would look something like this:

```<code>trial Card Colour Number Shape
1      1     1      1      0
1      2     0      1      1
1      3     0      1      0
1      4     1      1      1
2      1     1      0      0
2      2     1      1      0
2      3     0      1      1
2      4     1      1      0

</code>```

In other words, card 1 - card 4 per trial would become row variables, while colour, shape, and number remain column variables.

Any help is appreciated! Thanks.

答:
You can use pivot_longer from tidyr :

```<code>tidyr::pivot_longer(data, cols = -trial,
                    names_to = c('Card', '.value'),
                    names_pattern = 'Card(\\d+)_(.*)')

# A tibble: 80 x 5
#   trial Card  colour number shape
#   <int> <chr>  <int>  <int> <int>
# 1     1 1          0      1     1
# 2     1 2          0      1     1
# 3     1 3          0      0     0
# 4     1 4          0      0     0
# 5     2 1          1      0     1
# 6     2 2          0      1     0
# 7     2 3          1      0     1
# 8     2 4          0      1     0
# 9     3 1          0      1     1
#10     3 2          0      1     1
# … with 70 more rows
</code>```

Body:
I have a dataframe similar to the one below:

trial Card1_colour Card1_number Card1_shape Card2_colour Card2_number Card2_shape  ......
1        1                1           0           0           1            1
2        0                0           0           1           1            1
3        1                0           0           0           0            0
4        0                0           1           0           0            1
5        1                1           1           1           0            1
.
.
.
.

Except my actual dataframe has 12 'Card' variables, Card1_colour : Card4_shape.

#Code for generating example data

data<-matrix(rbinom(20*12, 1, .5), ncol=12)
trial<-seq(from = 1, to = 20)

data<-cbind(trial,data)
data<-as.data.frame(data)

colnames(data)[2] <- "Card1_colour"
colnames(data)[3] <- "Card1_number"
colnames(data)[4] <- "Card1_shape"
colnames(data)[5] <- "Card2_colour"
colnames(data)[6] <- "Card2_number"
colnames(data)[7] <- "Card2_shape"
colnames(data)[8] <- "Card3_colour"
colnames(data)[9] <- "Card3_number"
colnames(data)[10] <- "Card3_shape"
colnames(data)[11] <- "Card4_colour"
colnames(data)[12] <- "Card4_number"
colnames(data)[13] <- "Card4_shape"

I want to reshape my data into an n(trial) x 4 x 3 matrix that would look something like this:

trial Card Colour Number Shape
1      1     1      1      0
1      2     0      1      1
1      3     0      1      0
1      4     1      1      1
2      1     1      0      0
2      2     1      1      0
2      3     0      1      1
2      4     1      1      0

In other words, card 1 - card 4 per trial would become row variables, while colour, shape, and number remain column variables.

Any help is appreciated! Thanks.

Body:
You can use pivot_longer from tidyr :

tidyr::pivot_longer(data, cols = -trial,
                    names_to = c('Card', '.value'),
                    names_pattern = 'Card(\\d+)_(.*)')

# A tibble: 80 x 5
#   trial Card  colour number shape
#   <int> <chr>  <int>  <int> <int>
# 1     1 1          0      1     1
# 2     1 2          0      1     1
# 3     1 3          0      0     0
# 4     1 4          0      0     0
# 5     2 1          1      0     1
# 6     2 2          0      1     0
# 7     2 3          1      0     1
# 8     2 4          0      1     0
# 9     3 1          0      1     1
#10     3 2          0      1     1
# … with 70 more rows


问:
Accessing non static constant in static function of swift class
I am new to swift. I want to use none static member of swift class in a static function following is my code. I cannot access none static member of class in static function. Is there a way to access non static member in swift function?</p>

```<code>public class Test{
private let testString:String

init(test:String){
     testString = test
}

static func Get(url:String){
 //Here testString is not accessable..
}
}
</code>```

答:
There are two ways to achieve such a result. as stated by @Alexander you could create a static instance of the class like a singleton and use that.
Another way you can do is a simple trick like I did recently, you can have a static version of your variable. What I did was listen to the changes that my instance variable would go through using signals. you can do the same with KVO if you haven't overridden the getter for your variable (KVO compatible) or simply set the static variable whenever you change your instance variable although you must do it closure based (Block in OBJC) otherwise it's a whole big circle than never meets.
Whenever your instance variable's value changed you simply apply the same change to your static variable and when needed in static functions, you simply use the static one.

If you're not comfortable with using KVO or react you can also do something else. you can override the getter and setter for your instance variable and set them both to file or UserDefaults and also create a static method and override the getter to read the file with the same key as your instance variable so you don't have to set your static variable every time something changes.

Body:
I am new to swift. I want to use none static member of swift class in a static function following is my code. I cannot access none static member of class in static function. Is there a way to access non static member in swift function?

public class Test{
private let testString:String

init(test:String){
     testString = test
}

static func Get(url:String){
 //Here testString is not accessable..
}
}


问:
Why the debugging pointer stops at first line of 'server.php' in laravel?
I'm using PhpStorm and Laravel and when I want to debug my application, but the pointer stops at the first line of 'server.php' (you can see it in the below picture).

答:
1- Go to Settings > Languages & Frameworks > PHP > Debug

2- Uncheck  ' break at the first line...' options

3-In the Run menu, uncheck 'Break at the first line in PHP scripts'

see:

https://stackoverflow.com/a/19185093/10573560


问:
How do I clone an HTML element's style object using JavaScript or jQuery?
I'm trying to clone the style object of an element. This should allow me to reset the styles of said element after I change them.

For example:

```<code>el.style.left;      // 50px
curr_style.left;    // 50px;

/*
Modify the elements style.
The cloned style should still hold the original properties from when it was cloned.
*/
el.style.left = '20px';
curr_style.left // should still return 50px.
</code>```

I first tried to copy it by assigning a variable to the value of el.style. Unfortunately, this points to it by reference and any changes to the style are reflected in the cloned object.

My other attempt involved using jQuery's object extend method to create a copy as such:

```<code>var curr_style = $.extend( {}, el.style );
</code>```

This doesn't seem to work as curr_style.left etc. return undefined.

Any help would be appreciated!

I ended up doing this to retrieve each property: (based on advice from @Raynos)

```<code>$.fn.getStyle = function(){
    var style,
    el = this[0];

    // Fallbacks for old browsers.
    if (window.getComputedStyle) {
        style = window.getComputedStyle( el );
    } else if (el.currentStyle) {
        style = $.extend(true, {}, el.currentStyle);
    } else {
        style = $.extend(true, {}, el.style);
    }

    // Loop through styles and get each property. Add to object.
    var styles = {};
    for( var i=0; i<style.length; i++){
        styles[ style[i] ] = style[ style[i] ];
    }

    return styles;
};
</code>```

答:
```<code>var curr_style;
if (window.getComputedStyle) {
    curr_style = window.getComputedStyle(el);
} else if (el.currentStyle) {
    curr_style = $.extend(true, {}, el.currentStyle);
} else {
    throw "shit browser";
}
</code>```

style has non-enumerable properties which makes .extend fall over. You want to use the getComputedStyle method to get the styles of an element.

You also want to support older versions of IE by extending el.currentStyle which does have enumerable properties.

The first argument (when set to true) tells jQuery to do a deep clone.

Body:
I'm trying to clone the style object of an element. This should allow me to reset the styles of said element after I change them.

For example:

el.style.left;      // 50px
curr_style.left;    // 50px;

/*
Modify the elements style.
The cloned style should still hold the original properties from when it was cloned.
*/
el.style.left = '20px';
curr_style.left // should still return 50px.

I first tried to copy it by assigning a variable to the value of el.style. Unfortunately, this points to it by reference and any changes to the style are reflected in the cloned object.

My other attempt involved using jQuery's object extend method to create a copy as such:

var curr_style = $.extend( {}, el.style );

This doesn't seem to work as curr_style.left etc. return undefined.

Any help would be appreciated!

I ended up doing this to retrieve each property: (based on advice from @Raynos)

$.fn.getStyle = function(){
    var style,
    el = this[0];

    // Fallbacks for old browsers.
    if (window.getComputedStyle) {
        style = window.getComputedStyle( el );
    } else if (el.currentStyle) {
        style = $.extend(true, {}, el.currentStyle);
    } else {
        style = $.extend(true, {}, el.style);
    }

    // Loop through styles and get each property. Add to object.
    var styles = {};
    for( var i=0; i

Body:
var curr_style;
if (window.getComputedStyle) {
    curr_style = window.getComputedStyle(el);
} else if (el.currentStyle) {
    curr_style = $.extend(true, {}, el.currentStyle);
} else {
    throw "shit browser";
}

style has non-enumerable properties which makes .extend fall over. You want to use the getComputedStyle method to get the styles of an element.

You also want to support older versions of IE by extending el.currentStyle which does have enumerable properties.

The first argument (when set to true) tells jQuery to do a deep clone.


问:
How can I hide a specific method in swagger-ui?
I am currently using version 2.9.2 of swagger-ui in Spring Boot 2. The methods I want to show for each operating environment are different, so I wonder how to do it. (env ex: test, dev, prod...)

For example, i want to show the A method in the dev environment, but i don't want to show it in the prod environment.

Using @Profile("dev"), the configuration of swagger-ui itself can be set differently for each environment, but what i want to do is show swagger, but i want to show specific methods differently for each environment..

Thank you in advance for the answers.

Added :

```<code>@EnableSwagger2
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket testApi() {
        String apiDomain = "test";
        String apiName = apiDomain + " API";

        ApiInfo apiInfo = new ApiInfoBuilder()
                .title(apiName)
                .description(apiName + " Document Prototype")
                .version("0.0.1")
                .build();

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(apiDomain)
                .apiInfo(apiInfo)
                .select()
                .apis(getSelector(API_BASE_PACKAGE + "." + apiDomain))
                .paths(PathSelectors.any())
                .build();
    }

    private Predicate<RequestHandler> getSelector(String basePackage){

        // Profiles is a custom class util
        return Profiles.isProd() ? Predicates.and(RequestHandlerSelectors.basePackage(basePackage), handler -> !handler.isAnnotatedWith(IgnoreForProd.class))
                : RequestHandlerSelectors.basePackage(basePackage);
    }
}
</code>```

答:
For this you need to spring @Profile annotation to create custom Docket instances for the Swagger UI.

Lets say you want to ignore a specific controller method in the production environment.

First, you need to create a custom annotation. You can do so without it but this will have the cleanest solution.

```<code>@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface IgnoreForProd {
}
</code>```

Then annotate the method of controller that you want to ignore in production.

```<code>//..Spring and swagger annotations
@IgnoreForProd
public Pet postTestPetForSale(Pet pet) {
   //...controller code
}
</code>```

Finally, you need to set up the docket instance for production.

```<code>@Profile("prod")
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket postsApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("public-api")
                .apiInfo(apiInfo())
                .select()
                     // This is the part that will ignore the method
                    .apis((handler) -> !handler.isAnnotatedWith(IgnoreForProd.class))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("API")
                .description("API reference for developers")
                .build();
    }

}
</code>```

Body:
I am currently using version 2.9.2 of swagger-ui in Spring Boot 2. The methods I want to show for each operating environment are different, so I wonder how to do it. (env ex: test, dev, prod...)

For example, i want to show the A method in the dev environment, but i don't want to show it in the prod environment.

Using @Profile("dev"), the configuration of swagger-ui itself can be set differently for each environment, but what i want to do is show swagger, but i want to show specific methods differently for each environment..

Thank you in advance for the answers.

Added :

@EnableSwagger2
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket testApi() {
        String apiDomain = "test";
        String apiName = apiDomain + " API";

        ApiInfo apiInfo = new ApiInfoBuilder()
                .title(apiName)
                .description(apiName + " Document Prototype")
                .version("0.0.1")
                .build();

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(apiDomain)
                .apiInfo(apiInfo)
                .select()
                .apis(getSelector(API_BASE_PACKAGE + "." + apiDomain))
                .paths(PathSelectors.any())
                .build();
    }

    private Predicate<RequestHandler> getSelector(String basePackage){

        // Profiles is a custom class util
        return Profiles.isProd() ? Predicates.and(RequestHandlerSelectors.basePackage(basePackage), handler -> !handler.isAnnotatedWith(IgnoreForProd.class))
                : RequestHandlerSelectors.basePackage(basePackage);
    }
}

Body:
For this you need to spring @Profile annotation to create custom Docket instances for the Swagger UI.

Lets say you want to ignore a specific controller method in the production environment.

First, you need to create a custom annotation. You can do so without it but this will have the cleanest solution.

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface IgnoreForProd {
}

Then annotate the method of controller that you want to ignore in production.

//..Spring and swagger annotations
@IgnoreForProd
public Pet postTestPetForSale(Pet pet) {
   //...controller code
}

Finally, you need to set up the docket instance for production.

@Profile("prod")
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket postsApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("public-api")
                .apiInfo(apiInfo())
                .select()
                     // This is the part that will ignore the method
                    .apis((handler) -> !handler.isAnnotatedWith(IgnoreForProd.class))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("API")
                .description("API reference for developers")
                .build();
    }

}


问:
How to make properties file in Spring boot Primary and secondary
Hi I am using Spring 4.3.7, java 8 and spring boot, My requirement is I have 2 properties file one inside the classpath and another outside. I was able to load both. using

```<code>@PropertySources({ @PropertySource("classpath:common.properties"), @PropertySource("classpath:anotherFile.properties") })
@PropertySource(value = {"file:${external.config.location}/config_one.properties"},  ignoreResourceNotFound = true)
</code>```

the input  values of both the file will be almost same eg file naming convention or file create location (besides db details and few other token details)
    what has to be done is if external property file exist read the property value from it or else read from one inside the classpath. is this possible via any annotation in Spring boot?

答:
It works out of the box. The difference is that it does not "alternatively" read prop from one or another source, but it rather reads all properties from the first source, then reads all properties from another (and overrides eventual duplicates), than moves to the third source... and so on and on

There are in total 17 "default" sources and all have its own precedence over the others. See more in docs

https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config

Please bare in mind, that those sources are read "from bottom to top", so eg key from internal application.properties #15 will be overriden by key from external appication.properties #14 and so on.

Body:
Hi I am using Spring 4.3.7, java 8 and spring boot, My requirement is I have 2 properties file one inside the classpath and another outside. I was able to load both. using

@PropertySources({ @PropertySource("classpath:common.properties"), @PropertySource("classpath:anotherFile.properties") })
@PropertySource(value = {"file:${external.config.location}/config_one.properties"},  ignoreResourceNotFound = true)

the input  values of both the file will be almost same eg file naming convention or file create location (besides db details and few other token details)
    what has to be done is if external property file exist read the property value from it or else read from one inside the classpath. is this possible via any annotation in Spring boot?