.net

Limiting number of results when using NHibernate

Hello, I was wondering how people usually go about limiting the number of entities returned from a query. I know about SetMaxResults but this seems to break down as soon as joins are involved - 3 entities with each 2 children will produce 6 rows as a result. If I use SetMaxResults(3) to get only 3 entities I will only get 3 resulting ro...

Unauthorisedaccessexception - how to gain access?

I have a winform application to compress and move some files. When I try to access a path on my desktop, I get an unauthorisedaccess exception. I am running visual studio as administrator (says that in the program bar) and I am a full admin on my machine (can access other accounts, etc). How can I acess this path (folder)? One of the pr...

How do I get a control which looks like a TabControl with no tabs?

We have a form which displays media items in tab pages of a tab control, and I'm implementing a feature which allows users to 'pop out' the tab pages into their own forms. However, when I add the media player to a form rather than a TabPage, the background switches from the gradient fill of a tab page to the plain SystemColors.Control b...

Does any one know of a faster method to do String.Split()?

I am reading each line of a CSV file and need to get the individual values in each column. So right now I am just using: values = line.Split(delimiter); where line is the a string that holds the values that are seperated by the delimiter. Measuring the performance of my ReadNextRow method I noticed that it spends 66% on String.Split,...

Creating a GUI interface

Hi Guys, I've an idea of creating a GUI to give the user the opportunity to select some controls (textbox, gridview, labels, etc) and place it in a pallet/panel/window creating a view of the controls, that, pressing Save, it will save the X, Y, W and H of all controls (including the pallet/panel/window itself) to an XML (for later show ...

.Net winform property says Visible but I can't see it

I have a weird situation where I open a form from my application, hide it, and when I try to show it a second time, the Visible property says true, TopMost true also, location is correct, yet I can't see it. Any ideas where and what to look at to work out what the problem is? (Note: there may be issues with event handlers/delegate, bu...

Validate Each Column of dataTable using HashTable

I have a datatable whose columns are lets say col1,col2,col3 Now I want to validate each column value whether its 0 or not I do not want to use if else clause that will be writing to much stuff. Is there any possibility to do the same task using HashTable or something else ? ...

Best approach to Insert a new record with 40 columns from a VB.Net app

A colleague of mine is working on a .NET application. He needs to write his save function for his object. Normally he would use a stored procedure in SQL Server to do this, but with 40 columns that is quite a task. Several of our other colleagues have preferred using XSD's for their database interaction. What is going to give the bes...

Why Char.MinVal / .MaxVal are not static?

public struct Char { public const char MaxValue = (char)0xffff; public const char MinValue = '\0'; } Why don't make this fields to be static? What for it's always allocating additional memory for each char while this two values are permanent? Edit: I don't know how I could forget about been static implicitly! ...

.NET Config Files configSource outside the application directory folder

I have two applications one a console application and the other an ASP.NET app. They both need to know the same appSettings and connectionStrings. So ideally I would like to use the configSource property of app.config/web.config files to point that to a central location. For example <connectionStrings configSource="D:\connectionString...

SerializationException when serializing lots of objects in .NET

I'm running into problems serializing lots of objects in .NET. The object graph is pretty big with some of the new data sets being used, so I'm getting: System.Runtime.Serialization.SerializationException "The internal array cannot expand to greater than Int32.MaxValue elements." Has anyone else hit this limit? How have you solved it?...

How to deep copy between objects of different types in C#.NET

I have a requirement to map all of the field values and child collections between ObjectV1 and ObjectV2 by field name. ObjectV2 is in a different namspace to ObjectV1. Inheritence between the template ClassV1 and ClassV2 has been discounted as these 2 classes need to evolve independently. I have considered using both reflection (which ...

How to add a weighted average summary to a DevExpress XtraGrid?

The DevExpress Grid (XtraGrid) allows grids and their groups to have summary calculations. The available options are Count, Max, Min, Avg, Sum, None and Custom. Has anyone got some sample code that shows how to calculate a weighted average column, based upon the weightings provided as values in another column? ...

How to order properties alphabetically (Visual Studio 2008)

Hi! I'm really anal and would like to order my class properties alphabetically/by type. Is this possible using a pre-existing feature in VS, or a macro that can do this? Eg: public string foo {get; set;} public string bar {get; set;} public int fong {get; set;} public string loo {get; set;} to (if you want to order alphabetically) ...

Linq2XML, Why isn't Element(), Elements() working?

I am trying to traverse through a simple sitemap (adding and deleting elements on the fly.) This is the sample layout <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schem...

How to convert between "#,##0" and "{0:n2}" style format string representations?

.NET supports two types of string formatting. I'm in a situation where existing configuration data has #,##0 style formatting. A new feature requires formatting to the same output, but the API needed for this feature only accepts formatting of type {0:n2}. Does anyone know of a means to convert between these two representations for nu...

Best data type to store list of strings?

In .NET which data type do you use to store list of strings ? Currently I'm using List(Of String) because it's easier than Array to manage and add/remove stuff. I'm trying to understand what are the other options, when they become handy and when I should avoid List(Of String) usage. Do you use another type? Why and When? ...

Microsoft .NET Framework Data Provider for Oracle problem executing scripts

We are having trouble executing scripts that begin with BEGIN and are having multiple procedures or triggers with the aforementioned provider. Execution of those fails. Has anyone eperienced similiar problems? ...

How to manage IDisposable Objects that are cached?

I have an object that is expensive to create, which uses some unmanaged resources that must be explicitly freed when done with and so implement IDisposable(). I would like a cache for instance of these expensive resources so that the creation cost is minimized, but I am having trouble knowing how to deal with the disposal. If the met...

How do I draw a 3D border using visual styles?

I can draw a 3D border using ControlPaint.DrawBorder3D, but I get the 'Windows Classic' 3D border. I want to draw the current theme's 3D border - in the default XP theme, this is a 1px blue or gray border. How do I draw that, and how do I get its widths? ...