.net

Is there an equivalent of ComboBoxRenderer for NumericUpDown?

I want to draw spinner controls, such as those found on a NumericUpDown, on a custom component. If I want to draw a drop-down button, I can use ComboBoxRenderer. Is there an equivalent of ComboBoxRenderer for NumericUpDown? ...

Is SPRING.Net the best framework for Aspect Oriented Programming(AOP)?

Please give me the advantages and disadvantages of using the particular framework. Can give me examples of successes where you have used AOP in you .net applications? ...

Creating a DateTime in a specific Time Zone in c# fx 3.5

I'm trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected. In the test I need to be able to create DateTime objects in a none local time zone to ensure that people running the test can do so successfully irrespective of where they are located. Fro...

Keeping a "reference" to a row object for a long time

In my application I keep a LINQ object fetched from the database, and regularly modifies it followed by db.SubmitChanges(). I have read that you are not supposed to keep around the DataContext object for a long time. But if I close my DataContext between modifications, I guess the data object loses its link to the actual database row. ...

Resharper, has it changed your "programming" life?

Hey, We're thinking of getting Resharper and I would really be interested to hear from people who've used it and whether you get much out of it? Does it really speed up production and if you moved to anther job without it, would you miss it and why? Thanks Crafty ...

How to implement a singleton in C#?

How do I implement the singleton pattern in C#? I want to put my constants and some basic functions in it as I use those everywhere in my project. I want to have them 'Global' and not need to manually bind them every object I create. ...

C#/.Net Changelog

I started programming C# applications when the 1.0 framework was first released. I worked professionally with it for about three years right up until just before the 2.0 framework release. As I look now I see that 3.5 came out last year and that each new version of the framework has added large sets of features that are interconnected. ...

Access Edit Mode Values of BindingSource Control

I have a BindingSource control (http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx) with a datasource of a (single) Linq object. If I change any of the properties of the underlying Linq-to-Sql object then all the other changes on the bound controls on the form are lost. Does anyone now why and how I work ar...

ProtectedData.Protect intermittent failure

I'm writing a password encryption routine. I've written the below app to illustrate my problem. About 20% of the time, this code works as expected. The rest of the time, the decryption throws a cryptographic exception - "The data is invalid". I believe the problem is in the encryption portion, because the decryption portion works the...

.Net Equivalent of set_unexpected()

Is there a .net equivalent to the C++ unexpected()/set_unexpected() functionality? Edit: Sorry--I omitted some details previously: Language: C# 2.0 I have some legacy apps that seem to be throwing some unhandled exception somewhere. I just want to put something in place to stop the customer's pain until I can trace the actual sour...

Writing to a FileStream behaves strangely, as observed by process monitor

I'm using FileStream to write to a file, and watching the underlying system calls using Process Monitor. I'm having trouble with some file locking issues in a production deployment, so I'm looking at the details closely. This sample code: using (FileStream fs = new FileStream("c:\\temp\\test.txt", FileMode.Create, FileAccess.W...

Reading and Parsing Files in .NET - Performance For Hire

Hi, I want the most performat way to read and parse a file. Is it possible to read a file in .NET, but not load the entire file into memory? i.e. just load the file line by line as I parse the content of each row? Does XmlTextReader load the entire file into memory or does it stream the file into memory as it reads the file? ...

x64 .NET compilation / Process Explorer oddity

Apologies if any of what I'm about to say makes no sense or overlooks something obvious - my knowledge of CLR internals is spotty. If I understand correctly, then if I just build a solution for 'AnyCPU' in VS2K5 (or point MSBuild at that .sln file with those settings) then the binaries only compile as far as MSIL. They then get JITted t...

Merging a custom ContextMenuStrip with the system edit context menu in a DataGridView

I have a DataGridView in a VB.NET app that I have limited to cell selection only. The control has two columns, the first is not editable, the second is editable. I have a ContextMenuStrip that provides some additional functionality and I am able to make it appear when an editable cell receives a right click and is not in edit mode. Based...

Which of these two GetLargestValue C# implementations is better, and why?

I'm having a disagreement with someone over how best to implement a simple method that takes an array of integers, and returns the highest integer (using C# 2.0). Below are the two implementations - I have my own opinion of which is better, and why, but I'd appreciate any impartial opinions. Option A public int GetLargestValue(int[] v...

Load multiple external websites into one webpage via re-using ONE IFrame + Ajax

I am trying to embed multiple external websites into one web page. Using an IFRAME works ok, but once you get past 10 embedded iframes, the memory fottprint starts to get too big. So I was thinking, is it possible via ajax/javascript, to re-use the same iframe to load the collection of websites one after enother, and display the result...

Event signature pattern in .net

What's the point in the standard pattern for event delegates in .net? I.e. the EventHandler predefined delegate? Why not just choose the most appropriate signature for the requirement? Edit: And furthermore, is it necessary to slavishly follow Microsoft's example in all cases? ...

Should I persist a sqlconnection in my data access layer?

It seems like there is a lot of overhead involved in rapidly opening and closing sqlconnections. Should I persist a connection (one, per client, per database), or continue declaring a new sqlconnection object whenever I need one, and making sure I clean up after myself? What have you done? What worked well and what worked poorly? ...

How to (de)serialise JSON data in Silverlight using a different name to member variable

I have the following members defined in a class that I'm trying to deserialise: [DataMemberAttribute(Name = "cust_title")] public String Title { get; set; } [DataMemberAttribute(Name = "cust_description")] public String Description { get; set; } For some reason, the deserialisation fails (it seems to ignore the DataMemb...

Can I Format A String Like A Number in .NET?

If I had a phone number like this string phone = "6365555796"; Which I store with only numeric characters in my database (as a string), is it possible to output the number like this: "636-555-5796" Similar to how I could if I were using a number: long phone = 6365555796; string output = phone.ToString("000-000-0000"); I've...