.net-2.0

MessageBox loses focus in maximized MDI form

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 ...

Using an ASP.NET SiteMap for a Page with multiple paths

I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this: < Page 1 >   < MyPage / >   ... < /Page 1 > < Page 2 >   < MyPage / >   ... < /Page 2 > < Page 3 >   < MyPage / >   ... < /Pag...

How to Refactor to Generics from Class that Inherits from CollectionBase?

I am working on an application that is about 250,000 lines of code. I'm currently the only developer working on this application that was originally built in .NET 1.1. Pervasive throughout is a class that inherits from CollectionBase. All database collections inherit from this class. I am considering refactoring to inherit from the g...

Speed up loop using multithreading in C# (Question).

Imagine I have an function which goes through one million/billion strings and checks smth in them. f.ex: foreach (String item in ListOfStrings) { result.add(CalculateSmth(item)); } it consumes lot's of time, because CalculateSmth is very time consuming function. I want to ask: how to integrate multithreading in this kinda proces...

How do I work with quarters (quarterly dates) in ASP.Net using VB.Net 2.0?

I know that Sql Server has some handy built-in quarterly stuff, but what about the .Net native DateTime object? What is the best way to add, subtract, and traverse quarters? Is it a bad thing™ to use the VB-specific DateAdd() function? e.g.: Dim nextQuarter As DateTime = DateAdd(DateInterval.Quarter, 1, DateTime.Now) Edit: Expanding...

Prevent a PostBack from showing up in the History

I have a page where I submit some data, and return to the original form with a "Save Successful" message. However, the user would like the ability to return to the previous page they were at (which contains search results) by clicking the browser's Back button. However, due to the postback, when they click the Back button they do not g...

Excel Addin Access Violation

Using c#, VS2005, and .NET 2.0. (XP 32 bit) This is a Winforms app that gets called by a VBA addin (.xla) via Interop libraries. This app has been around for a while and works fine when the assembly is compiled and executed anywhere other than my dev machine. On dev it crashes hard (in debugger and just running the object) with "Unhandl...

Anyone know of a solid .NET Framework 2.0 installer script for Inno Setup?

I've spent a good part of the day searching, writing and finally scrapping a script that I can use with my Inno Setup install script that will download and install the appropriate .NET 2.0 Framework if needed. There are definitely a number of examples out there, but they: Want to install Internet Explorer if needed which I wouldn't da...

What's the best way to instantiate a generic from its name?

Assuming I have only the class name of a generic as a string in the form of "MyCustomGenericCollection(of MyCustomObjectClass)" and don't know the assembly it comes from, what is the easiest way to create an instance of that object? If it helps, I know that the class implements IMyCustomInterface and is from an assembly loaded into the...

WSE 2.0 Web Services Client using .NET 2.0

What's the best way to access WSE 2.0 web services from .NET 2.0? Using VS2005's web references is not working, because generated classes are using System.Web.Services as their base (instead of Microsoft.Web.Services2). ...

Checking for duplicates in a collection

Suppose you have a collection of classes: class Foo { public string Bar; public string Baz; } List<Foo> foolist; And you want to check this collection to see if another entry has a matching Bar. bool isDuplicate = false; foreach (Foo f in foolist) { if (f.Bar == SomeBar) { isDuplicate = true; brea...

What does AllowLocation="true" do in System.Web section of Web.Config?

We have a .NET 2.0 application which we normally run on IIS6, and used to run fine on IIS7, but recently after installing SP1 for Vista IIS7 seems to be choking on a line in the Web.Config file: <system.web AllowLocation="true"> Is it safe to remove the AllowLocation attribute? What does this attribute do? ...

Can you make a site with ASP.NET MVC Framework using .NET 2.0?

Is it possible to make a site with ASP.NET MVC Framework using .NET 2.0? I am limited to using .NET 2.0 (we use VS 2008, but we have to use the 2.0 Framework) and I really want to try out the MVC Framework. ...

Is there a way to make Strongly Typed Resource files public (as opposed to internal)?

Here's what I'd like to do: I want to create a library project that contains my Resource files (ie, UI Labels and whatnot). I'd like to then use the resource library both in my UI and in my Tests. (Ie, basically have a common place for my resources that I reference from multiple projects.) Unfortunately, because the StronglyTypedResou...

Displaying controls on an alpha-blended form

I tried the Visual C# Kicks code for an alpha-blended form. This works (as soon as I remove the TransparencyKey property); that is, I can use the W3C's PNG alpha test image and see other windows underneath, but makes all controls on the form invisible. Presumably, they simply aren't painted, as OnPaint is overridden. I tried calling the ...

.NET Log Soap Request on Client

I'm consuming a third party .NET WebService in my client application. For debugging purposes I want to capture the SOAP requests that are being sent from my server. How would I go about doing this? This is being done on .NET 2.0 without the use of WCF or WSE. ...

When to use IEnumerable over IEnumerable<>

Due to the lack of generic variance in the .NET framework, is it more "correct" to have methods that handle the non-generic versions of the System.Collection interfaces, if the methods are being designed to handle multiple types? Ideally, once moved to .NET 3.5, the code would modified to change these methods into extension methods. ...

AddHandler/RemoveHandler Not Disposing Correctly

I have heard that calling AddHandler, but not calling RemoveHandler doesn't remove the handle to the event under certain conditions, leaving the control/object as active and not diposed, and thus leading to memory leaks. Is there any truth to this? Are there other causes to memory leaks that are solely available in VB as opposed to C#?...

C#: Getting maximum and minimum values of arbitrary properties of all items in a list

I have a specialized list that holds items of type IThing: public class ThingList : IList<IThing> {...} public interface IThing { Decimal Weight { get; set; } Decimal Velocity { get; set; } Decimal Distance { get; set; } Decimal Age { get; set; } Decimal AnotherValue { get; set; } [...even more properties and m...

Reading .resx files programatically

I have an application where the contents of e-mails that get sent are stored in a .resx file. This is an ASP.Net application, the .resx file lives in /App_GlobalResources When I need to send an e-mail, i'm reading this using: HttpContext.GetGlobalResourceObject("MailContents", "EmailID").ToString Now, I need to use the same maili...