I have a simple desktop application which loads .cshtml view in a windows form. I build it and published on my remote machine for a specific folder on drive D. Everything works fine, if only 1 user from this machine runs the instance of this application on a target path. But if any other user try to run the same app, while the copy of that app is already running by another user it sees a blank form instead.
I've already covered the code with some logging and try{} catch{} blocks, but have no interesting info so far. The service which returns the desktop view runs at the same intranet and it returns the result all the time if you just go to URL against the browser.
What could be the problem and how can I find the true cause of its appearance?
I will be grateful for any advice.
Update 1: CoreWebView2InitializationCompleted contains an exception -> The requested resource is in use. (0x800700AA)
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.webView = new Microsoft.Web.WebView2.WinForms.WebView2();
((System.ComponentModel.ISupportInitialize)(this.webView)).BeginInit();
this.SuspendLayout();
//
// webView
//
this.webView.AllowExternalDrop = false;
this.webView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.webView.CreationProperties = null;
this.webView.DefaultBackgroundColor = System.Drawing.Color.White;
this.webView.Location = new System.Drawing.Point(10, 10);
this.webView.Name = "webView";
this.webView.Size = new System.Drawing.Size(690, 125);
this.webView.TabIndex = 0;
this.webView.ZoomFactor = 1D;
//
// MainForm
//
this.AccessibleDescription = "MessageBoard Wrapper";
this.AccessibleName = "MessageBoard Wrapper";
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(710, 145);
this.Controls.Add(this.webView);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(250, 100);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "MessageBoard Wrapper";
((System.ComponentModel.ISupportInitialize)(this.webView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private HttpClient GetClient()
{
var result = new HttpClient();
return result;
}
private Microsoft.Web.WebView2.WinForms.WebView2 webView;
private string _baseUrl = "here I have my service url";
public MainForm()
{
InitializeComponent();
FormBorderStyle = FormBorderStyle.None;
DoubleBuffered = true;
SetStyle(ControlStyles.ResizeRedraw, true);
var client = GetClient();
try
{
var targetmUrlForCustomBusinessLogic = "url address here";
var response = client.GetAsync(targetmUrlForCustomBusinessLogic).Result;
if (response.IsSuccessStatusCode)
{
var t = Task.Run(() => response.Content.ReadAsStringAsync()).Result;
//here I have some code too
}
}
catch (Exception ex)
{
var message = ex.Message;
//TODO: add logging here
}
finally
{
client.Dispose();
}
webView.Source = new Uri(_baseUrl);
webView.NavigationCompleted += WebView_NavigationCompleted;
ResizeEnd += (object sender, EventArgs e) => SaveFormSettings();
Move += (object sender, EventArgs e) => SaveFormSettings();
Shown += (object sender, EventArgs e) => LoadFormSettings();
}