.net

Nested class in .net

I have a nested class. I want to access the outer and nested classes in other class. How to access both class properties and methods and my condition is i want to create object for only one class plz provide the code snippet ...

Normalize newlines in C#

I have a data stream that may contain \r, \n, \r\n, \n\r or any combination of them. Is there a simple way to normalize the data to make all of them simply become \r\n pairs to make display more consistent? So something that would yield this kind of translation table: \r --> \r\n \n --> \r\n \n\n --> \r\n\r\n \n\r --> \r\n...

Has anyone used C# with a Sales Logix database?

Has anyone used C# with a Sales Logix database? ...

Grab and move application windows from a .NET app?

Is it possible for a .NET application to grab all the window handles currently open, and move/resize these windows? I'd pretty sure its possible using P/Invoke, but I was wondering if there were some managed code wrappers for this functionality. ...

How do I replace the *first instance* of a string in .NET?

I want to replace the first occurrence in a given string. How can I accomplish this in .NET? ...

Crystal Report 10.5 [included with Visual Studio 2008] Selection by Image column

Hi I have an Image column (Allow Null = true) in SQL Server 2005. I am using Crystal Reports designer (ver 10.5) that comes with Visual Studio 2008. Crystal sees the column as blob field and puts an image object for the column. When I am trying to limit the record selection by using NOT ISNULL({Employee.Picture}) as Selection Fo...

When would I need a SecureString in .NET?

I'm trying to grok the purpose of .NET's SecureString. From MSDN: An instance of the System.String class is both immutable and, when no longer needed, cannot be programmatically scheduled for garbage collection; that is, the instance is read-only after it is created and it is not possible to predict when the instance will be deleted...

What is the proper way to ensure a SQL connection is closed when an exception is thrown?

I use a pattern that looks something like this often. I'm wondering if this is alright or if there is a best practice that I am not applying here. Specifically I'm wondering; in the case that an exception is thrown is the code that I have in the finally block enough to ensure that the connection is closed appropriately? public class S...

How to have a LinkClicked event using an ArrayList of LinkLabels in .NET

I'm working on a form that will display links to open different types of reports. This system has different types of users, so the users should only be able to see the links to the types of reports they can access. Currently, the way I have this set up is that I have an ArrayList of LinkLabels, but the problem I'm having is how to have...

Exceptions vs Result Codes for a socket client class.

Hello, I have a class that encapsulates tcp socket communications with a server. For each command message sent to the server, the server will send back a response message that invariably contains a response code (OK, Fail). Using my class, each command can be executed either sync or async. There are basically two types of exceptions tha...

INotifyPropertyChanged property name - hardcode vs reflection?

What is the best way to specify a property name when using INotifyPropertyChanged? Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(4) but am a little uneasy about the reflection overhead. ...

How to purge expired items from cache?

I've got a nice little class built that acts as a cache. Each item has an expiration TimeSpan or DateTime. Each time an attempt to access an item in the cache is made, the item's expiration is checked, and if it's expired, the item is removed from the cache and nothing is returned. That's great for objects that are accessed frequently, ...

Recursive List Flattening

I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off. I'm trying to write a generic extension method similar to the others introduced in .NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it into one IEnumerable. Anyone have any ideas? Specifically, I...

Visual Studio 2008 source control for small teams

I work on a small web team where I am the only .NET developer currently using Visual Studio 2008 Professional to build and maintain a few web applications. I am about to start training another member of our team so we purchased him a copy of Visual Studio 2008 Professional. I've looked into Visual Source Safe, but I'm dubious. I don't ...

Does anyone know when the ASP.NET MVC will be fully released?

When do you think we can expect the full release version of ASP.NET MVC? ...

How can I access PostData from WebBrowser.Navigating event handler?

I've got a windows form in Visual Studio 2008 using .NET 3.5 which has a WebBrowser control on it. I need to analyse the form's PostData in the Navigating event handler before the request is sent. Is there a way to get to it? The old win32 browser control had a Before_Navigate event which had PostData as one of its arguments. Not so ...

.Net Web Service Logging

My ideal situation for logging in our web service would be to log all the method calls (authentication as well as data access) with the parameters passed to them as well as errors that may have occured, and have them linked with a single ID that associates them with the same call. In addition, I'd ideally like to be able to control whet...

Is there an issue sending XML via WCF?

Suppose you have an XElement or an XmlElment or even a string containing xml that you want to send via WCF. Are there any special precautions you have to take? The question just came up, what happens when, within the xml message, you transmit an xml document declaration (<?xml version=’1.0’ ?>), which may happen if serializing an XmlDo...

Best place for log files in an in-house IT environment

All of my users are a short walk down the hall, and all of my programs run on workstations on the same LAN. Some years ago, I had the staff write the log files for all of their programs to a shared folder hierarchy, naming each log file after the machine name in a sub-directory named after the app. But this arrangement wasn't that great...

Tokenizers in .NET

This must be a classic .NET question for anyone migrating from Java. .NET does not seem to have a direct equivalent to java.io.StreamTokenizer, however the JLCA provides a SupportClass that attempts to implement it. I believe the JLCA also provides a Tokenizer SupportClass that takes a String as the source, which I thought a StreamTo...