How to use LogonUser properly to impersonate domain user from workgroup client

Very few posts suggest using LOGON_TYPE_NEW_CREDENTIALS instead of LOGON_TYPE_NETWORK or LOGON_TYPE_INTERACTIVE. I had an impersonation issue with one machine connected to a domain and one not, and this fixed it. The last code snippet in this post suggests that impersonating across a forest does work, but it doesn’t specifically say anything about trust being set … Read more

C#: multiline text in DataGridView control

You should set DefaultCellStyle.WrapMode property of column to DataGridViewTriState.True. After that text in cells will be displayed correctly. Example (DataGridView with one column): dataGridView1.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dataGridView1.Rows.Add(“test” + Environment.NewLine + “test”); (Environment.NewLine = \r\n in Windows)

How to use WebBrowser control DocumentCompleted event in C#?

You might want to know the AJAX calls as well. Consider using this: private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { string url = e.Url.ToString(); if (!(url.StartsWith(“http://”) || url.StartsWith(“https://”))) { // in AJAX } if (e.Url.AbsolutePath != this.webBrowser.Url.AbsolutePath) { // IFRAME } else { // REAL DOCUMENT COMPLETE } }

How can I evaluate C# code dynamically?

Using the Roslyn scripting API (more samples here): // add NuGet package ‘Microsoft.CodeAnalysis.Scripting’ using Microsoft.CodeAnalysis.CSharp.Scripting; await CSharpScript.EvaluateAsync(“System.Math.Pow(2, 4)”) // returns 16 You can also run any piece of code: var script = await CSharpScript.RunAsync(@” class MyClass { public void Print() => System.Console.WriteLine(1); }”) And reference the code that was generated in previous runs: await script.ContinueWithAsync(“new … Read more