.net

Are there published style guidelines for C# XML documentation?

I ask my developers who write C# code to follow StyleCop's guidelines. It's great for code, but I almost always have questions about documentation (ok...ok...so no one asks, because programmers tend to hate documentation) style. I could suggest copying MSDN's style, but I'm curious whether Microsoft or someone else has published somethin...

convert string to datetime vb.net

i need to convert strings to date format. the requirement is if current month is selected, the date should be getdate. if any other month is selected then it should be first of that month. the data coming in is "January 2010", "February 2010" and so on. but it should be inserted into sql server database as 01/01/10 or 02/01/10 ...

Cancelling a BackgroundWorker, how to prevent race when it has already finished...

I'm using a BackgroundWorker to perform a long computation (only one such computation at a time). The user has the possibility of cancelling the worker (calling worker.CancelAsync). In the worker.DoWork method I periodically check for the cancel pending flag and then return from the method. Then the Completed event is raised from the ...

Print the contents of an array (code is one line, for use in Immediate window of visual studio)

Can you write a convenient line of code that prints the contents of an array? I will use this in the Immediate Window of Visual Studio 2008, so really it has to work in that window. I may have left out some requirements, but that's pretty much what I'm trying to do. ...

DataGridView: How can I make the enter key add a new line instead of changing the current cell?

How can I make the Enter key behave in a Winforms DataGridViewTextBoxCell like it does in a normal Winforms TextBox (add a new line to the text, instead of changing the current cell)? ...

Bridges between Java and .NET

Hello, I'm interested in technologies(solutions) that permits Java and .NET interoperate. I have tried the following and it works but I would like to know if there are other solutions: Sockets Web Services (Metro) CORBA (IIOP.NET) Messaging (QPid) IKVM Does anyone know other technologies(solutions) that enable Java and .NET interope...

Do WCF 3.5 REST endpoints call associated methods asynchronously?

Hi, When a WCF 3.5 REST endpoint (via WebServiceHost) handles a URI request, does it invoke the associated procedure asynchronously? Thanks, Scott ...

Does .NET have something similar to Java's garbage collection log?

Does .NET have something similar to Java's garbage collection log? I want to write GC stats to a log in a production application. Google doesn't tell my anything useful and SO doesn't seem to have any related questions either. Thanks ...

Best way to read a large file into byte array in C#?

I have a web server which will read large binary files (several megs) into byte arrays. The server could be reading several files at the same time (different page requests) so I am looking for the most optimized way for doing this without taxing the CPU too much. Is the code below good enough? public byte[] FileToByteArray(string fileN...

Linq2Sql Updates

Wondering if anyone else has done most of their Update SQL using stored procedures over Linq2Sql? I like Linq2Sql for all the other operations but Updates seem to be nasty. The generated SQL doesn't look good in profiler with all the columns in the Where clause, then you have to select the current object to set the fields from the edited...

VB.NET default radio button selected inside a group box

I have a WinForms application (VS 2008, .NET 3.5) that has a form with two different group boxes, and inside of each group box are different sets of radio buttons. When I run the application, the first group box automatically has the first radio button in it already selected, and the second group box does not have a radio button selecte...

Getting legacy objects to be imported when they are not attributed as Exports in MEF

I'm starting to use MEF to build up a plugin based application, and I'm slowly adding MEF to the mix. There is a lot of existing code that does not have any MEF DNA yet, but I still want to get that code into the new objects that are being automatically created by composition. Let's make this concrete. I have a list of objects that im...

Why are Nullable<T> considered a value type?

Have you ever tried to use the Convert.ChangeType() method to convert a value to a Nullable<T> type? Awkwardly, it will throw an InvalidCastException saying "Null object cannot be converted to a value type". Try running this on your immediate window: ?System.Convert.ChangeType(null, typeof(int?)) For some obscure reason, Nullables are ...

How do I make a client-side helper class in Silverlight?

In Silverlight, I call my Silverlight-enabled WCF service asynchronously to retrieve, say, a list of values for a combobox. On the server, I cache these values for performance. But I want to cache them on the client to prevent the unnecessary round-trip. Now, I understand how to use local storage to cache them except that I do not want ...

"Ambiguous Constructor Reference" XmlSerializer

I am trying to serialize a List<MyObject>. When I create my XmlSerializer as such: XmlSerializer xmlSerializer = new XmlSerializer(List<MyObject>); I get the following error: Ambiguous Constructor Reference How can I fix this so I can serialize and deserialize my list? ...

Is this the best code to use for reading from a networkstream (vb.net)?

I know it's subjective but this was the result I came up with based on the answer to me previous question and it seems a bit "slapped together", as I have changed it quite a bit: Private Function ReadFromBuffer(ByVal objReader As NetworkStream) As Byte() Dim intRead As Integer = 1024 Dim allBytes(-1) As Byte While intRead...

MethodNotFound, singleton class and "optimize code"

I'm writing a .net compact framework app in c#. It was working fine in the development environment but when built in release mode and run by itself, it was throwing MethodNotFound exceptions. I sprinkled a bunch of debug logging code to find out where it was breaking and narrowed it down to a big Init() function. This in turn calls metho...

Using MS Anti XSS library for sanitizing HTML

In the intent of preventing XSS attacks, I am updating a page in which we have a textbox that accepts HTML, stores it in a database and retrieves and renders it at a later time. My understanding is that I can sanitize the HTML using AntiXSS.GetSafeHtmlFragment() method. As long as I do this before storing the HTML in the database, am I ...

Objective-C Soap Proxy Generator similar to whats in .NET

Hi, We have a contractor doing an Iphone native app in objective-c. They need to call some of our web services to get data. Is there some kind of proxy generator for obj-c that will create native objects that call web services? C#/.NET has this built in--you just add a service reference in visual studio or you use a command line tool...

WPF - Force ShowDialog to return

How can I force ShowDialog to return from a background thread? I have a WPF application built on top of a C++/CLR framework which is listening to messages sent by the framework. One particular message is so important that I need to close all the current windows. However, if a modal dialog (created by ShowDialog from my main window) is ...