.net-2.0

Fastest way to get a random value from a string array in C#?

ぃ、小莉子 提交于 2019-12-06 06:20:34
问题 What's the fastest way to get a random value from a string array in C# on the .net 2.0 framework? I figured they might have had this: string[] fileLines = File.ReadAllLines(filePath); fileLines.GetRandomValue(); Yes, I know GetRandomValue() is not an actual method, is there something similar that's more or less equally short and sweet? 回答1: Not built in, but easy enough to add... static readonly Random rand = new Random(); public static T GetRandomValue<T>(T[] values) { lock(rand) { return

Password Recovery without sending password via email

浪子不回头ぞ 提交于 2019-12-06 05:43:24
问题 So, I've been playing with asp:PasswordRecovery and discovered I really don't like it, for several reasons: 1) Alice's password can be reset even without having access to Alice's email. A security question for password resets mitigates this, but does not really satisfy me. 2) Alice's new password is sent back to her in cleartext. I would rather send her a special link to my page (e.g. a page like example.com/recovery.aspx?P=lfaj0831uefjc), which would let her change her password. I imagine I

Unable to add Rhino Mocks 3.5 to a .NET 2.0 project in Visual Studio 2010

梦想的初衷 提交于 2019-12-06 05:33:11
问题 We're upgrading from Dev Studio 2005 to Dev Studio 2010. I opened my 2005 solution in Visual Studio 2010 and went through the conversion process keeping all projects targeted at .NET 2.0. When I try to build the project, my references to Rhino.Mocks.dll are failing to be used. I see errors like this: DalDiscoveryTest.cs(7,7): error CS0246: The type or namespace name 'Rhino' could not be found (are you missing a using directive or an assembly reference?) I went into my project and removed the

.NET (WinForms) Grid Control with Collapse/Expand Capabilities

房东的猫 提交于 2019-12-06 05:06:48
问题 Anybody purchased/used a DataGrid/GridView control that allows Collapsing/Expanding Parent-Child relationships? The standard DataGrid control, which I am using in .NET 2.0, seems to have limited capabilities with regards to this functionality. The newer GridView control doesn't support this at all to my knowledge. I was thinking about developing a custom control but that could get expensive for my client.. I need this control for WinForms (not ASP.NET) thanks 回答1: We've used Janus Grids here

Rendering HTML Content within Silverlight application

一世执手 提交于 2019-12-06 04:22:51
In one of our application it is required to display bullet list in one of the Silverlight 2.0 container. We have decided to use HTML markup text for the same. While there are number of options available on Google like overlaying HTML div container etc., I would like to know what is the most workable way of doing this. I think the easiest will be to use some 3-rd party solution. For example, Telerik has an HtmlPlaceholder that allows you to display html pages inside Silverlight application. You can see a demo here: http://demos.telerik.com/silverlight/#HtmlPlaceholder/FirstLook This is how you

C# How do you get the operating system architecture (x86 or x64)? [duplicate]

匆匆过客 提交于 2019-12-06 04:09:11
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: How to detect Windows 64 bit platform with .net? How can I retrieve the operating system architecture (x86 or x64) with .NET 2.0? I have not found any good method to get the OS architecture on Google. What I found was how to tell whether the process is 32-bit or 64-bit. If there isn't anyway to find out in .NET 2.0 please tell me. :) 回答1: Not the accepted answer in the duplicate question, but this is how I'd do

.Net 2.0 ServiceController.GetServices()

∥☆過路亽.° 提交于 2019-12-06 03:59:55
问题 I've got a website that has windows authentication enable on it. From a page in the website, the users have the ability to start a service that does some stuff with the database. It works fine for me to start the service because I'm a local admin on the server. But I just had a user test it and they can't get the service started. My question is: Does anyone know of a way to get a list of services on a specified computer by name using a different windows account than the one they are currently

MessageBox loses focus in maximized MDI form

ⅰ亾dé卋堺 提交于 2019-12-06 03:22:32
I have an MDI application (written in .NET 2.0) which lets users open multiple child forms. The child forms are always maximized inside the MDI parent. When the MDI parent is maximized and I attempt to do a MessageBox.Show, the MessageBox doesn't show. If I do an alt-tab (or even just press alt) the MessageBox pops to the front. Any ideas how to make that sucker show up to begin with? This is only a problem when the MDI parent is maximized... Try using MessageBox.Show(Window owner, string message, string caption) Setting the MDI application as owner so the MB is shown in the front Ah, you

What is the best way to sort an IList<T> in .Net 2.0?

大憨熊 提交于 2019-12-06 03:18:01
问题 I have an IList<T> that I need to sort, and I would rather not copy the list if possible. I've noticed that ArrayList has an Adapter static method that wraps the passed list without copying it, but this takes an IList and I have an IList<T> . Is it safe to cast from a System.Collections.Generic.IList<T> to a System.Collections.IList and just use the Adapter method? Note that this is .Net 2.0, so LINQ is not an option. 回答1: From the blog of Paul Fox, I recommend the post "How to sort an IList"

Windows 7 TextureBrush..ctor() error

不想你离开。 提交于 2019-12-06 03:15:03
问题 I have a .NET 2.0 app that runs just fine on XP and Vista, but on Windows 7 RC (x64) it crashes with the following error: Exception Information Exception Type: System.OutOfMemoryException Message: Out of memory. Data: System.Collections.ListDictionaryInternal TargetSite: Void .ctor(System.Drawing.Image, System.Drawing.Drawing2D.WrapMode) HelpLink: NULL Source: System.Drawing StackTrace Information at System.Drawing.TextureBrush..ctor(Image image, WrapMode wrapMode) at System.Windows.Forms