.net

How can I make sure scrollbars don't overlap content?

When creating scrollable user controls with .NET and WinForms I have repeatedly encountered situations where, for example, a vertical scrollbar pops up, overlapping the control's content, causing a horizontal scrollbar to also be needed. Ideally the content would shrink just a bit to make room for the vertical scrollbar. My current sol...

Proper name space managment in .NET XmlWriter

I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or something we can't live with but it is preventing us from producing the beautiful XML we woul...

UITypeEditor and IExtenderProvider

I have an extender (IExtenderProvider) which extends certain types of controls with additional properties. For one of these properties, I have written a UITypeEditor. So far, all works just fine. The extender also has a couple of properties itself, which I am trying to use as a sort of default for the UITypeEditor. What I want to do ...

XPath and Selecting a single node

I'm using XPath in .NET to parse an XML document, along the lines of: XmlNodeList lotsOStuff = doc.SelectNodes("//stuff"); foreach (XmlNode stuff in lotsOStuff) { XmlNode stuffChild = stuff.SelectSingleNode("//stuffChild"); // ... etc } The issue is that the XPath Query for stuffChild is always returning the child of the first ...

What is the best way to deal with DBNull's

I frequently have problems dealing with DataRows returned from SqlDataAdapters. When I try to fill in an object using code like this: DataRow row = ds.Tables[0].Rows[0]; string value = (string)row; What is the best way to deal with DBNull's in this type of situation. ...

How can you require a constructor with no parameters for types implementing an interface?

Is there a way? I need all types that implement a specific interface to have a parameterless constructor, can it be done? I am developing the base code for other developers in my company to use in a specific project. There's a proccess which will create instances of types (in different threads) that perform certain tasks, and I need t...

Charting library for Java and .Net

Can anyone recommend a library for chart generation (bar charts, pie charts etc.) which runs on both Java and .Net? ...

Does Mono support System.Drawing and System.Drawing.Printing?

I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below: EDIT: No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something. private void btnPrintTest_Click(ob...

Microsoft .Net framework 3.5 SP1 Setup Fails

On my Vista machine I cannot install the .Net framework 3.5 SP1. Setup ends few moments after ending the download of the required files, stating in the log that: [08/26/08,09:46:11] Microsoft .NET Framework 2.0SP1 (CBS): [2] Error: Installation failed for component Microsoft .NET Framework 2.0SP1 (CBS). MSI returned error code 1 [08/26...

Dynamic top down list of controls in WindowsForms and C#?

In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not. The requirements are that there should be one single list, with one element on each row. Ea...

How can I discover the "path" of an embedded resource?

I am storing a PNG graphic as an Embedded Resource in an assembly. From within the same assembly I have some code like: Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png"); The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marked as an embedded resource. The code fails with an...

Notify Developer of a "DO NOT USE" Method

OK, I know what you're thinking, "why write a method you do not want people to use?" Right? Well, in short, I have a class that needs to be serialized to XML. In order for the XmlSerializer to do its magic, the class must have a default, empty constructor: public class MyClass { public MyClass() { // required for xml serializat...

Create an Attribute to Break the Build

OK, this kind of follows on from my previous question. What I would really like to do is create some sort of attribute which allows me to decorate a method that will break the build. Much like the Obsolete("reason", true) attribute, but without falsely identifying obsolete code. To clarify: I dont want it to break the build on ANY F6 (...

In ASP.NET, what are the different ways to inline code in the .aspx?

Can I get a 'when to use' for these and others? <% %> <%# EVAL() %> Thanks ...

Any pitfalls developing C#/.NET code in a Virtual Machine running on a MAC?

I am considering buying an Apple MAC book Pro, are than any pitfalls developing C#/.NET code in a Virtual Machine running on a MAC? For this purpose, is it better to run Vista or XPPro? ...

Why do my exception stack traces always point to the last method line?

I have a problem with my Visual Studio installation. When I got an exception I always have incorrect line numbers in it's stack trace. There are always point to last line of each method in my codebase. At the same time it's OK when I'm tracing programs with debugger. What's happed with PDBs? No, I'm not re-throwing exception at each met...

Is DateTime.Now the best way to measure a function's performance?

I need to find a bottleneck and need to accurately as possible measure time. Is the following Code Snippet the best way to measure the performance? DateTime startTime = DateTime.Now; // Some Execution Process DateTime endTime = DateTime.Now; TimeSpan totalTimeTaken = endTime.Subtract(startTime); ...

Simple Object to Database Product

I've been taking a look at some different products for .NET which propose to speed up development time by providing a way for business objects to map seamlessly to an automatically generated database. I've never had a problem writing a data access layer, but I'm wondering if this type of product will really save the time it claims. I als...

.NET Compiler -- DEBUG vs. RELEASE

For years I have been using the DEBUG compiler constant in VB.NET to write messages to the console. I've also been using System.Diagnostics.Debug.Write in similar fashion. It was always my understanding that when RELEASE was used as the build option, that all of these statements were left out by the compiler, freeing your production co...

Best architecture for handling file system changes?

Here is the scenario: I'm writing an app that will watch for any changes in a specific directory. This directory will be flooded with thousands of files a minute each with an "almost" unique GUID. The file format is this: GUID.dat where GUID == xxxxxxxxxxxxxxxxxxxxxxxxxxxxx (the internal contents aren't relevant, but it's just text da...