MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Rendering in console app not working if console app is starting as windows service child process
Open
@LiangTheDev is already working on this.
Since Dec 6, 2023.
bug
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Description
Rendering in console apps works if I start the console app in the context of the current logged in user.
If i start the console app as child process of a Windows service (no UI available) CreateCoreWebView2ControllerAsync does not return.
internal class Program
{
private static readonly IntPtr HWND_MESSAGE = new IntPtr(-3);
[STAThread]
static void Main(string[] args)
{
Test();
Application.Run();
}
static async void Test()
{
SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
await Task.Delay(1); // wait for the application loop to start
var browserEnv = await CoreWebView2Environment.CreateAsync();
var wvController = await browserEnv.CreateCoreWebView2ControllerAsync(HWND_MESSAGE); // not working in a Windows Service Childprocess
wvController.Bounds = new System.Drawing.Rectangle(0, 0, 100, 100);
wvController.CoreWebView2.Navigate("http://localhost/");
TaskCompletionSource<bool> tsc = new TaskCompletionSource<bool>();
wvController.CoreWebView2.NavigationCompleted += (s, e) =>
{
tsc.SetResult(true);
};
await tsc.Task;
using (FileStream stream = new FileStream("D:\\testImg.png", FileMode.Create))
{
await wvController.CoreWebView2.CapturePreviewAsync(CoreWebView2CapturePreviewImageFormat.Png, stream);
}
Application.Exit();
}
}
Version
SDK: 1.0.1518.46
Runtime: Evergreen 109.0.1518.70
OS: Win11 22H2
Framework: .NET 4.8 Console App
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.