c#-2.0

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

﹥>﹥吖頭↗ 提交于 2019-11-27 11:13:13
ASP.NET: Impersonate against a domain on VMWare This question is what I am asking, but the answer does not provide details on how the _token is derived. It seems to only use WindowsIdentity.GetCurrent().Token so there's no impersonation happening. Can I impersonate a user on a different Active Directory domain in .NET? This next question has conflicting answers, with the accepted one bearing a comment "I'm beginning to suspect that my problem lies elsewhere." Not helpful. LogonUser works only for my domain This next question seems to imply it is not possible, but it deals with 2 domains so I

Is it possible to use the Task Parallel Library (TPL) in C# 2.0?

狂风中的少年 提交于 2019-11-27 08:36:46
问题 Currently stuck in C# 2, it would still be nice to use the parallel goodness of the TPL... is this possible? 回答1: No it's not possible. TPL requires .NET 3.5 (IIRC there was a separate download but it was a beta version) and is built in .NET 4.0. 来源: https://stackoverflow.com/questions/3500614/is-it-possible-to-use-the-task-parallel-library-tpl-in-c-sharp-2-0

How do I prevent print screen

老子叫甜甜 提交于 2019-11-27 08:28:17
I have a requirement that an application I am working on prevent the user from being able to easily capture the contents of the screen. I have communicated that there is no feasible way to completely prevent this from happening, but I'm looking for methods to introduce some hurdles to the process. I'm using C#/.NET 2.0 and WinForms You can't. The best you can do is render to a hardware accelerated device on an overlay, similar to what video players used to do. Basically, you paint your entire window blue, and render your graphics onto the video card, and internally the video card will replace

How cancel shutdown from a windows service C#

半世苍凉 提交于 2019-11-27 07:24:34
问题 I have a windows service started (written in C# .net2.0). I want to detect when the computer shutdown/reboot and cancel it. After the cancel I want do some actions and restart windows. I have tried it, but it not working using Microsoft.Win32; partial class MyService: ServiceBase { protected override void OnStart(string[] args) { SystemEvents.SessionEnding += new SessionEndingEventHandler(OnSessionEnding); } private void OnSessionEnding(object sender, SessionEndingEventArgs e) { e.Cancel =

Using C# MethodInvoker.Invoke() for a GUI app… is this good?

浪尽此生 提交于 2019-11-27 06:41:39
Using C# 2.0 and the MethodInvoker delegate, I have a GUI application receiving some event from either the GUI thread or from a worker thread. I use the following pattern for handling the event in the form: private void SomeEventHandler(object sender, EventArgs e) { MethodInvoker method = delegate { uiSomeTextBox.Text = "some text"; }; if (InvokeRequired) BeginInvoke(method); else method.Invoke(); } By using this pattern I do not duplicate the actual UI code but what I'm not sure about is if this method is good. In particular, the line method.Invoke() does it use another thread for invoking or

OnCheckedChanged event handler of asp:checkbox does not fire when checkbox is unchecked

穿精又带淫゛_ 提交于 2019-11-27 06:35:03
问题 I have a repeater, in each ItemTemplate of the repeater is an asp:checkbox with an OnCheckedChanged event handler set. The checkboxes have the AutoPostBack property set to true. When any of the checkboxes is checked, the event handler fires. When any is unchecked, the event handler does not fire. Any idea why the event does not fire, and how I mgiht make it fire? Thanks. Simplified repeater code: <asp:Repeater ID="rptLinkedItems" runat="server"> <ItemTemplate> <asp:CheckBox ID="chkLinked"

How to write to the stdin of another app?

≡放荡痞女 提交于 2019-11-27 06:13:17
问题 I have a module that reads the StandardError of a process. Everything works fine, but I want to do something different. I don't know how to redirect stdin like the native way: app1.exe -someargs | app2.exe -someargs Where app2 reads all the stdout of app1 in its stdin. 回答1: Have a look at the MSDN reference documentation for the following (both to be found in the System.Diagnostics namespace): Process.StandardInput ProcessStartInfo.RedirectStandardInput. There's an example showing how to

How to programmatically minimize opened window folders

≡放荡痞女 提交于 2019-11-27 03:54:19
问题 How can I get the list of opened of folders, enumerate through it and minimize each folder programmatically? At times some opened folders do steal focus from the tool when jumping from one form in the application to another. Preventing this is of high priority for our client. The customers are visually impaired people, so they access the machine only via screen readers. Minimizing other windows (folders) is not at all a problem, in fact a requirement. I tried this: foreach (Process p in

How to ignore a certificate error with c# 2.0 WebClient - without the certificate

蓝咒 提交于 2019-11-27 03:34:38
Using Visual Studio 2005 - C# 2.0, System.Net.WebClient.UploadData(Uri address, byte[] data) Windows Server 2003 So here's a stripped down version of the code: static string SO_method(String fullRequestString) { string theUriStringToUse = @"https://10.10.10.10:443"; // populated with real endpoint IP:port string proxyAddressAndPort = @"http://10.10.10.10:80/"; // populated with a real proxy IP:port Byte[] utf8EncodedResponse; // for the return data in utf8 string responseString; // for the return data in utf16 WebClient myWebClient = new WebClient(); // instantiate a web client WebProxy

Convert array of strings to List<string>

陌路散爱 提交于 2019-11-27 03:14:14
I've seen examples of this done using .ToList() on array types, this seems to be available only in .Net 3.5+ . I'm working with .NET Framework 2.0 on an ASP.NET project that can't be upgraded at this time, so I was wondering: is there another solution? One that is more elegant than looping through the array and adding each element to this List (which is no problem; I'm just wondering if there is a better solution for learning purposes)? string[] arr = { "Alpha", "Beta", "Gamma" }; List<string> openItems = new List<string>(); foreach (string arrItem in arr) { openItems.Add(arrItem); } If I have