.net-3.5

C# - How to copy/create an object as a decendent

This is easier to explain with an example. Given these two classes: public class MyClassA { public String Property_A { get; set; } public String Property_B { get; set; } public String Property_C { get; set; } public String Property_D { get; set; } ... public String Property_Y { get; set; } } public class MyClas...

What is the accepted pattern for implementing Session in ASP.NET MVC sites?

Obviously, the typical WebForms approach won't work. How does one track a user in an MVC world? ...

Add elements to XDocument after LINQ Query

I have the following XML LINQ query from my XDocument. var totals = (from x in MyDocument.Descendants("TOTALS") select x).FirstOrDefault(); Once I have found my totals node I need to add some elements to that node and push that change to the XDocument. ...

What is the difference between these 2 XML LINQ Queries?

I have the 2 following LINQ queries and I haven't quite got my head around LINQ so what is the difference between the 2 approaches below? Is there a circumstance where one approach is better than another? ChequeDocument.Descendants("ERRORS").Where(x=>(string)x.Attribute("D") == "").Count(); (from x in ChequeDocument.Descendant...

Setting Cookie Port

I'm trying to set the port on a cookie in ASP.NET (code below), but I'm getting a very unusual error at runtime (below the code). Any thoughts? target.Cookie = new Cookie { Comment = "Test Comment", CommentUri = new System.Uri("http://www.tempuri.org"), Discard = false, Domain = "tempuri.com", Expired = false, Ex...

C# update a varying property on each item within a collection

I have this code (which is way simplified from the real code): public interface IAmount { decimal Amount { get; set; } } public class SomeAmount : IAmount { public decimal Amount { get; set; } } public static void UpdateAmounts( this IEnumerable< IAmount > amounts, decimal totalAmount ) { foreach ( IAmount amount in amounts ) ...

What's the best way to create a Windows Mobile application with multiple screens in C#

I am creating a Windows Mobile Application in C# and Visual Studio 2008. The application will have 5-6 main 'screens'. There will also be bar (/area) with information (e.g. a title, whether the app is busy, etc) above the screens, and a toolbar (or similar control) below the screens with 5-6 buttons (with images) to change the active sc...

Error "Index was outside the bounds of the array" for EDMX

OK. When I'm actually trying to Update the modal, some additional keys are getting added. For solving that, I've opened the edmx file with xml editor. then removed the additional keys. Then the edmx build successfully. But the problem is when I do 'validate' the edmx, then visual studio throws strange error "Index was outside th...

Are there differences between running .NET app with 3.5 requirement on machine with or without SP1?

I have an application which requires 3.5 (not SP1.) My understanding is that SP1 is an additive service pack. Therefore, installing SP1 on a machine would not affect my application in any way besides performance. As far as I can tell from the sources listed below, SP1 is mostly about new features, and significant performance improveme...

Which platform to develop web-based game in?

I'm thinking of writing a new web-based game, and wondered if anyone had any suggestions on which platform I should opt for. The game will be 2D sprite based, but will need to maintain a decent fps rate (there'll probably be up to 20 things moving at once). It'll all be controlled via the mouse. I use .NET daily, so Silverlight seems ...

TransactionScope and Connection Pooling

Hi, I'm trying to get a handle on whether we have a problem in our application with database connections using incorrect IsolationLevels. Our application is a .Net 3.5 database app using SQL Server 2005. I've discovered that the IsolationLevel of connections are not reset when they are returned to the connection pool (see here) and ...

Ordering XElements

I have the following XML Document (that can be redesigned if necessary) that stores records and errors. <MYROOT> <RECORDS> <RECORD> <DATETIME>11/03/2010 14:12:41</DATETIME> <DOCUMENTID>1</DOCUMENTID> </RECORD> <RECORD> <DATETIME>11/03/2010 14:12:44</DATETIME> <DOCUMENTID>2</DOCUMENTID> </RECOR...

Tool to convert inline C# into a code behind file

Hi I have a number of legacy web controls (ascx) that contains huge amounts of inline C#. The forms contain a number of repeated and duplicate code. Our first plan is to move the code into code behinds per file, then refactor etc... were doing this to upgrade the client to the latest version of their cms At the moment we are going ...

running asp.net 3.5 and asp.net 2.0 in same site

We're running ASP.Net 2.0 on our corporate web site, and I'd like to get it up to ASP.Net 3.5 as smoothly as possible. The project/solution architecture in VS 2005 is an ASP.Net 2.0 web project and an .Net 2.0 data access layer project which is used by the site code. Upon opening the projects in a new VS 2008 solution they seemed to be...

How to expose multi-element field in base class to derived classes

I have a base class that declares a grouping of objects. That grouping can be an array, List, Collection, that's up to me. The derived classes of this base class are the ones that actually set the values of this multi-element field. What is the best way to expose this field to the derived classes? ...

How can I copy an XmlNode from one XmlDocument to another?

I'm building a tool that authors/edits XML files, and I want to be able to populate it with template fragments defined in another XML file. For example, the tool has an "Add FooBarBaz Element" button that adds a element to the new document being created, and I want to add FooBarBaz by copying it from a template. Or let's say this is m...

Fluently setting C# properties and chaining methods

I'm using .NET 3.5. We have some complex third-party classes which are automatically generated and out of my control, but which we must work with for testing purposes. I see my team doing a lot of deeply-nested property getting/setting in our test code, and it's getting pretty cumbersome. To remedy the problem, I'd like to make a fluent...

MEF - Modify execution if one plugin fails

Hi! I'm using MEF for a plugin-system to my application. The flow goes like this: Run all Pre-plugins Run all Core-plugins Run all Post-plugins For example, if a plugin in the Core execution fails, i don't want to run certain post plugins. What would be the best way to achieve this? Hope my question is clear, otherwise please tell ...

tree view; show lines property is not working properly

Hii, I am a bigginer in using tree view control. I am using tree view control to make a simple tree like structure. But when i use show lines property it is not connecting to the root node. The code which i have written is as follows. <asp:TreeView ID="treeSettings" runat="server" ImageSet="Simple2" NodeIndent="15" ...

Search value in List collection

I need to search a name which is stored in collection. Search criteria: eg: 'Search Name' . If i give 'N' this name should be displayed. If i give any alphabet then all the names which contains the given alphabet should be displayed..the name can contains more than one word. I am using List collection. search criteria: eg. 1) a 2) xyz...