.net-3.5

How should I manage developing on SQL Server 2008 and SQL Server 2005 for different clients?

The company I work for has several clients. I'm currently splitting my time between 2 .net projects. For Client A I need Visual Studio 2008, SQL Server 2008 and the 3.5 framework. For Client B 2005 versions/2.0 Framework. Others in the company are using Microsoft Virtual PC to keep the development environments separate. What do you su...

Insert cell comments in excel programmaticaly.

What's the better way to insert cell comments in excel 2007 files programmaticaly using c# and .net 3.5? ...

Save attribute value of xml element with single quotes using linq to xml.

How do I make the XDocument object save an attribute value of a element with single quotes? ...

Extend a LINQ entity-class with constructor methods and make that entity-class inherit from it's DataContext class

Is it possible to extend LINQ-to-SQL entity-classes with constructor-methods and in the same go; make that entity-class inherit from it's data-context class?--In essence converting the entity-class into a business object. This is the pattern I am currently using: namespace Xxx { public class User : Xxx.DataContext { pub...

What is the memory footprint of an object at Runtime in .NET?

I have a static object at runtime that is basically a list of other objects (ints, strings, Dictionary, other objects, etc). Is there way to determine the memory used by my static "list of other objects" object at runtime? This would be handy for instrumentation and reporting purposes. ...

Why doesn't the NameObjectCollectionBase class provide a way to insert objects into the collection by index?

The System.Collections.Specialized.NameObjectCollectionBase class is used extensively at my company as the basis of collection classes. (Let's not get into questioning why.) I recently came across a situation where I needed to add an object at a specific index, but the functionality wasn't there. At first I wondered why we had left that ...

log4net with ASP.NET 3.5 problems

I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the first time I've tried to use log4net, I feel like I'm missing a piece of the puzzle. My project references the log4net assembly, and as far as I can tell, it is being deployed successfully on my server. My web.config contains the following: <configSections...

convert XmlNode to XNode?

Anyone know off the top of their heads how to convert a System.Xml.XmlNode to System.Xml.Linq.XNode? ...

Raising C# events with an extension method - is it bad?

We're all familiar with the horror that is C# event declaration. To ensure thread-safety, the standard is to write something like this: public event EventHandler SomethingHappened; protected virtual void OnSomethingHappened(EventArgs e) { var handler = SomethingHappened; if (handler != null) handler(this, e)...

Query with a join or use LINQ magic?

Is is better to do a joined query like this: var employer = (from person in db.People join employer in db.Employers on person.EmployerID equals employer.EmployerID where person.PersonID == idPerson select employer).FirstOrDefault(); Or is it just as good to do th...

Limitations of C# Action lambda code blocks

C# .NET 3.5. I'm trying to understand the intrinsic limitation of the C# Action object. Within the lamda (are those, in fact, lamdas?), we can perform assignments, call functions, even execute a ternary operation, but we can't execute a multi-statement operation. Is this because the single-statement execution is just syntactic sugar f...

How .NET 3.5 (lambdas, Linq) evolved

I remember reading a post about a year or so ago by Scott Hanselman (maybe by scott guthrie) about how Linq evolved. It remember it showing that anyonymous types led to lambda expressions which then led to Linq in some way. I can't seem to find it on google. Does anyone else remember this post? If so, can you please post it? ...

What to use: var or object name type?

this is a question that when programming I always wonder: What to use when we are writting code: var myFiles = Directory.GetFiles(fullPath); or string[] myFiles = Directory.GetFiles(fullPath); var is new and is a Implicitly Typed Local Variables, so we can only used locally and it has rules like can't be null, etc., but I wonder i...

Converting one XML document into another XML document

I want to convert an XML document containing many elements within a node (around 150) into another XML document with a slightly different schema but mostly with the same element names. Now do I have to manually map each element/node between the 2 documents. For that I will have to hardcode 150 lines of mapping and element names. Somethin...

How to determine if XElement.Elements() contains a node with a specific name?

For example for the following XML <Order> <Phone>1254</Phone> <City>City1</City> <State>State</State> </Order> I might want to find out whether the XElement contains "City" Node or not. ...

Load XML containing 300 elements for each record into db

So I have this large XML file containing 300+ elements for each record and I need to insert these records into a database table. The name of the nodes in the XML file are the same as the column names in the db. And they're all strings. Is there an automatic way to map them and insert the data or will I have to write out lines of code map...

Where to practice Lambda function?

I am currently trying to learn all new features of C#3.0. I have found a very nice collection of sample to practice LINQ but I can't find something similar for Lambda. Do you have a place that I could practice Lambda function? Update LINQpad is great to learn Linq (thx for the one who suggest) and use a little bit Lambda in some expre...

C# 3.5 - Connecting named pipe across network

What is the correct way to setup a named pipe in C# across a network? Currently I have two machines, 'client' and 'server'. Server sets up its pipe in the following manner: NamedPipeServerStream pipeServer = new NamedPipeServerStream( "pipe", PipeDirection.InOut, 10, PipeTransmissionMode.Byte, PipeOptions.None) pip...

Delivery of .Net 3.5 SP1

If I were to include .Net Framework setup file along with my apps (installation process is done by our own technician), to be install on a clean Windows (XP SP2/SP3 or Vista SP1) without prior installation of any framework, which of the .Net Framework setup do I need to install in sequence, to get to 3.5 SP1? Currently I have the setup f...

How to do forward-compatibility for .NET 3.5 features in .NET 2.0 apps?

I want to start using .NET 3.5 features in an app that is currently stuck in the past - how can I write in support for selected features like JSON serialization in a forward-compatible way? In the case of JSON serialization I need to reference System.ServiceModel.Web - is it OK to reference a .NET 3.5 dll in a VS2005 app? Presumably thi...