.net

Linq To SQL: Can I eager load only one field in a joined table?

I have one table "orders" with a foreing key "ProductID". I want to show the orders in a grid with the product name, without LazyLoad for better performance, but I if use DataLoadOptions it retrieves all Product fields, which seams like a overkill. Is there a way to retrieve only the Product name in the first query? Can I set some attr...

What is the difference between a group and match in .NET's RegEx?

What is the difference between a group and match in .NET's RegEx? ...

Generic IBindingListView Implementations

Can anyone suggest a good implementation of a generic collection class that implements the IBindingListView & IBindingList interfaces and provides Filtering and Searching capabilities? I see my current options as: Using a class that someone else has written and tested Inheriting from BindingList, and implementing the IBindingListView ...

How do I make a PictureBox use Nearest Neighbor resampling?

I am using StretchImage because the box is resizable with splitters. It looks like the default is some kind of smooth bilinear filtering, causing my image to be blurry and have moire patterns. ...

DoDragDrop and MouseUp

Is there an easy way to ensure that after a drag-and-drop fails to complete, the MouseUp event isn't eaten up and ignored by the framework? I have found a blog post describing one mechanism, but it involves a good deal of manual bookkeeping, including status flags, MouseMove events, manual "mouse leave" checking, etc. all of which I wou...

Windows Vista: Unable to load DLL 'x.dll': Invalid access to memory location. (DllNotFoundException)

Hello, I was testing on a customer's box this afternoon which has Windows Vista (He had home, but I am testing on a Business Edition with same results). We make use of a .DLL that gets the Hardware ID of the computer. It's usage is very simple and the sample program I have created works. The Dll is This from AzSdk. In fact, this works ...

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies

I am trying to get the DB2 data provider from a 32-bit .Net application to connect to DB2 running as a 32-bit application on Vista 64 (is that confusing enough yet)? Unfortunately, I am getting the following error: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\Installed...

Using .NET CodeDOM to declare and initialize a field in one statement

I want to use CodeDOM to both declare and initialize my static field in one statement. How can I do this? // for example public static int MyField = 5; I can seem to figure out how to declare a static field, and I can set its value later, but I can't seem to get the above effect. @lomaxx, Naw, I just want static. I don't want const...

What does ServerVariables["APPL_MD_PATH"] retreives the metabase path for the Application for the ISAPI DLL mean?

Hello, I've trying to get an ASP.net (v2) app to work in the debugger and keep running into a problem because the value returned by HttpContext.Current.Request.ServerVariables["APPL_MD_PATH"].ToLower() is an empty string. I have found out that this "Retrieves the metabase path for the Application for the ISAPI DLL". Can anybody shed s...

Cannot access a disposed object - How to fix?

In a VB.NET WinForms project I get an exception "Cannot access a disposed object" when closing a form. It occurs very rarely and I cannot recreate it on demand. The stack trace looks like this: Cannot access a disposed object. Object name: 'dbiSchedule'. at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Control.get_...

WinForms databinding and foreign key relationships

I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be able to display foreign key lookups in a databound DataGridView. An example of the sort of relationship is that I have a table of OrderLines. Orderlines have a foreign key relationship to Products and Products in turn have a foreign key relationship to Product...

How to catch SQLServer timeout exceptions

I need to specifically catch SQL server timeout exceptions so that they can be handled differently. I know I could catch the SqlException and then check if the message string Contains "Timeout" but was wondering if there is a better way to do it? try { //some code } catch (SqlException ex) { if (ex.Message.Contains("Timeout"))...

How do I make the manifest of a .net assembly private ?

What should I do if I want to release a .net assembly but wish to keep its internals detailed in the manifest private (from a utility such as ildasm.exe) ? ...

Can someone point me to some guides for WPF

I am having trouble finding good guides for WPF. I have experience in C# and .NET but I don't know anything about WPF except for the regular marketing-ish description of the technology as a whole. Can anyone point me to a good beginner's tutorial/guide on WPF. ...

Thread not waking up from Thread.Sleep()

We have a Windows Service written in C#. The service spawns a thread that does this: private void ThreadWorkerFunction() { while(false == _stop) // stop flag set by other thread { try { openConnection(); doStuff(); closeConnection(); } catch (Exception ex) { log.Error("Something went wr...

Best practice for dynamically added Web.UI.ITemplate classes

We have a couple of ASP.Net dataview column templates that are dynamically added to the dataview depending on columns selected by users. These templated cells need to handle custom databindings: public class CustomColumnTemplate: ITemplate { public void InstantiateIn( Control container ) { //create a new label ...

How to send email from a program _without_ using a preexisting account?

I'd like my program to be able to email me error reports. How can I do this without hard-coding a username/password/SMTP server/etc. into the code? (Doing so would allow users to decompile the program and take over this email account.) I've been told you could do some stuff with telneting to port 25, but I'm very fuzzy on the details. M...

Should I migrate to ASP.NET MVC?

Hello, I just listened to the StackOverflow team's 17th podcast, and they talked so highly of ASP.NET MVC that I decided to check it out. But first, I want to be sure it's worth it. I already created a base web application (for other developers to build on) for a project that's starting in a few days and wanted to know, based on your ex...

Monitoring files - how to know when a file is complete

We have several .NET applications that monitor a directory for new files, using FileSystemWatcher. The files are copied from another location, uploaded via FTP, etc. When they come in, the files are processed in one way or another. However, one problem that I have never seen a satisfactory answer for is: for large files, how does one kno...

Manual steps to upgrade VS.NET solution and target .NET framework?

After you've let the VS.NET (2008 in this case) wizard upgrade your solution, do you perform any manual steps to upgrade specific properties of your solution and projects? For instance, you have to go to each project and target a new version of the framework (from 2.0 to 3.5 in this case). Even after targeting a new version of the framew...