.net

Null Difference

What is the difference between if(null==object) and if(object==null) Please give the advantage for using the above. ...

Advantages of using delegates?

I'm looking to implement the Observer pattern in VB.NET or C# or some other first-class .NET language. I've heard that delegates can be used for this, but can't figure out why they would be preferred over plain old interfaces implemented on observers. So, Why should I use delegates instead of defining my own interfaces and passing arou...

.NET 3.5 chart controls exception: Error executing child request for ChartImg.axd

Anyone getting this error when using the new free chart controls MS bought from Dundas? "Error executing child request for ChartImg.axd" On the MSDN forum they suggested it was my web.config: MSDN forum post So far that hasn't fixed the problem though. Any other ideas? ...

WPF User Control Parent

I have a user control that I load into a main window at runtime. I cannot get a handle on the containing window from the user control. I have tried this.Parent, but it's always null. Does anyone know how to get a handle to the containing window from a user control in WPF? Here is how the control is loaded: private void XMLLogViewer_M...

What are the best practices for encrypting data in .NET?

What are the best practices for dealing with Things that should be hashed. i.e. passwords and Things that cannot be hashed, but are extremely confidential and would cause tremendous pain if compromised. i.e. credit cards, SSN, missle launch codes. Which encryption algorithm is strongest, most recommended? How you do handle the ...

Implementing Custom CacheDependency to invalidate ASP.Net cache item

Hi, I want to implement my own customCacheDependency class by deriving base CacheDependency, as provided SqlCacheDependency is not suitable for my case. (thousands of cache items, and there will so many subscriptions in SQL as well as issues with registration in ASP.Net) I want to use this in ASP.Net VirtualPathProvider's our custom im...

c# how hashtable shrinks when elements are removed from hashtable?

Hi, I am looking to find out the logic , if any , which shrinks hashtable in c# when elements are removed from it. Regards Harish ...

TripleDES Encryption in C#

I'm trying TripleDES Encryption with ECB mode. My code looks like that: public static string EncryptDES(string InputText) { byte[] key = new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 }; byte[] cle...

Parameterized Queries with LIKE and IN conditions

Parameterized Queries in .Net always look like this in the examples: SqlCommand comm = new SqlCommand("SELECT * FROM Products WHERE Category_ID=@categoryid", conn); comm.Parameters.Add("@categoryid", SqlDbType.Int); comm.Parameters["@categoryid"].Value = CategoryID; But I'm running into a brick wall trying to do the following: Sql...

C# - WinForms - What is the proper way to load up a ListBox?

What is the proper way to load a ListBox in C# .NET 2.0 Winforms? I thought I could just bind it to a DataTable. No such luck. I thought I could bind it with a Dicitonary. No luck. Do I have to write an class called KeyValuePair, and then use List<KeyValuePair> just to be able to load this thing with objects? Maybe I am missing somet...

Can a Generic Method handle both Reference and Nullable Value types?

I have a series of Extension methods to help with null-checking on IDataRecord objects, which I'm currently implementing like this: public static int? GetNullableInt32(this IDataRecord dr, int ordinal) { int? nullInt = null; return dr.IsDBNull(ordinal) ? nullInt : dr.GetInt32(ordinal); } public static int? GetNullableInt32(this...

Is there a better StringCollection editor for use in PropertyGrids?

I'm making heavy use of PropertySheets in my application framework's configuration editor. I like them a lot because it's pretty easy to work with them (once you learn how) and make the editing bulletproof. One of the things that I'm storing in my configuration are Python scripts. It's possible to edit a Python script in a StringColle...

Is there a master list of COMExceptions?

The Oracle community has a several support sites (here and here) that have lists of errors. The first site even has suggestions for how to fix them. Does anyone know of an equivalent list for Microsoft COM, preferably with Office Interop issues? ...

XML Deserialization Issue

I have the following xml that's sent to me from a web service. I'm using .NET to deserialize it, but I'm getting an exception saying that its formatted wrong. There is an error in XML document (2, 2) Now, if I understand that correctly, it's not liking that it's finding the first <error> node. <?xml version="1.0" encoding="UTF-8"?> <m...

Using an interface to convert an object from one type to another?

Suppose I have two classes with the same interface: interface ISomeInterface { int foo{get; set;} int bar{get; set;} } class SomeClass : ISomeInterface {} class SomeOtherClass : ISomeInterface {} Suppose I have an instance of ISomeInterface that represents a SomeClass. Is there an easy way to copy that into a new instance ...

Logging component that produces xml logs.

A lot of programs log things into a text file in a format something like this: 11/19/2008 13:29:01 DEBUG Opening connection to localhost. 11/19/2008 13:29:01 DEBUG Sending login message for user 'ADMIN'. 11/19/2008 13:29:03 DEBUG Received login response 'OK' for user 'ADMIN'. ... However, I prefer something more structured like XML ...

Open new Page from an Xbap

Our application is an Xbap running in full trust. I have a function similar to this: private void ShowPage(Page page) { NavigationWindow mainWindow = Application.Current.MainWindow as NavigationWindow; mainWindow.Navigate(page); } This works great for browsing inside an existing window. I would like to open this new page in ...

VB.NET Read current line in a text area?

I have a text area and a function to do syntax highlighting on it. Right now it reads the entire RichTextBox. How would I get a string variable containing the current line? Below is the code i currently have. Private Sub HighLight() Dim rm As System.Text.RegularExpressions.MatchCollection Dim m As System.Text.RegularExpressions....

Inheriting a .net class

Ok here's what I'm trying to do I want to write a class that inherits everything from the class ListItem class RealListItem : ListItem { public string anExtraStringINeed; } For some reason or another .net is treating all the members like they are private when I try to do this so my class is worthless. I tried to do a work around ...

System.Net.Mail - Invalid Characters in Mail Address

How can I send an email using SYstem.Net.Mail to an email address that is unusual (myFirstName.O'[email protected]) but is still RFC 5322 compliant? Does .NET support sending mail addresses that have single quotes in them, and if so, how do I force the system to allow email to be sent to those addresses? Right now we're using the Sys...