.net

Implementing MS Access style 'relationships' GUI

I have no idea what the correct name for this UI style is. In MS Access the 'relationships' tool shows the db tables as little movable boxes that can be linked with lines. It's the same with Visio and a few audio apps - boxes that are movable, containing lines of text that can be joined together in a meaningful way. How could I create a...

What are some examples of how anonymous types are useful?

I've read some articles on how to create anonymous types in C#. What are some use cases for these things? To me, it seems like it might make things a little more difficult to understand declaring objects and their members inline. When does it make sense to use Anonymous Types? ...

How can I capture the keystroke that triggers "CellEndEdit" on a DataGridView in C#?

I have a DataGridView that is set to EditOnF2. I do some special processing of data in the CellEndEdit eventhandler that sets the value of the cell. I still want the functionality of the EditOnKeystrokeOrF2 of reverting to the original value when the Esc key is pressed. Unfortunately, at the CellEndEdit eventhandler, I don't see a way...

Selective Cache clearing across load balanced servers (ASP.Net)

We have a website that runs on two load balanced servers. We use the ASP.Net caching to help improve performance by caching high usage data. BUT, occasionally that data changes. When it does, we need to clear the relevant cache items on BOTH the load balanced servers. Does anyone have some easy to implement suggestions for how this c...

Generics: Accessing New Members, Not Hidden Members

I have run into a problem with generics and new members. I wrote a generic class which operates on an object of type ObjectA. ObjectB derives from ObjectA and hides a few of ObjectA's members. When I supply the type of ObjectB as the type parameter to the generic class, I would expect that when I call any of the members hidden by Obje...

SerialPort + CF 2.0 prevent losing data

Can anyone tell my why the code below would be missing or dropping data. I have been googling all night but can't find any pointers. the serial port is using the following settings; 38400,n,8,1 xon/xoff flow control. ReceivedBytesThreshold = 1. isReceiving and stockReceived are both members of the form private void serialPort1_...

Custom Configuration for ASP.NET Apps (use of Application Settings or other frameworks)

I know how to create custom configuration handlers for my .NET application. There are plenty of posts on StackOverflow that cover what needs to be done. I've spent most of the day knocking out classes that derive from ConfigurationElement. I'm getting worried that this approach involves a lot of work - more work than I was expecting. I'...

How do I retrieve data with Linq to XML?

I need to find ShippingMethod and the attribute Code and Destination from the following piece of XML: <ScoreRule> <ShippingMethod Code="UPS1DA"> <Destination Country="US" Area="IL" Value="0" /> </ShippingMethod> </ScoreRule> How do I retrieve that data with Linq to XML? ...

How would I write this as a single LINQ query?

Using the following logic, what would the correct syntax be for a single LINQ query? If Branch is Service, I want its parent, otherwise I want Branch. Can you critique my attempt and let me know how I can improve it? int branchId = 21; var t = ctx.BranchInfos.Single(p => p.BranchID == branchId ); if (t.Type == BranchType.Service.T...

.NET project for TCP messaging

Is there an open source project or framework in .NET which provides the basic "plumbing" for messaging between client(s) and server over TCP? It seems like one of those things where I end up writing essentially the same thing over and over, and I'd like to abstract myself away from that a little bit more and deal with the particulars of ...

Where to move the business logic when moving it out of the database

I have a CRUD-heavy ASP.NET application with all the business logic in Stored Procedures. As an example, there is an UPDATE stored procedure that's ~500 lines long and contains large amounts of conditional logic, referencing multiple tables & UDFs. The proc takes in the field name being updated and the new value, sets a bunch of declar...

What kind of Application would be best for running non interactively?

I need to create an application that can be activated with a batch file. The application would accept a single string parameter of a file name. It will then run some processing with this file and drop another file in a predetermined location and exit. The application does not need to interact with an actual user. My preferred platfor...

Passing a anonymous type to function.

I have tables with either many columns or a column with a large data set (XML doc), I need to load information from the table quickly (status info) into a class. I notices that Linq allows you to select columns as such...: Using an anonymous type: var query = (from name in some.Table select new { ColumnName = name.ColumnNam...

MySQL function that alerts if a new row is inserted.

Is there a function in MySQL that we can use in a client application that will automatically sends alerts every time a new row is inserted in a table? ...

Must Satellite Assembly versions match the base version?

I just ran into a situation where I needed to patch a release with a new version of one of our assemblies. All my assemblies are strong names and this is a Windows Forms application. I edited my App.config to do the appropriate re-mappings and all went fine until we tested our software with our localized version. The problem we saw is...

Is there an API in .net to read XML comment documentation file.

In this question I see that microsoft ships the XML documentation files for the BCL. I wonder if anyone knows if there an API within .net that can be used to look this up at runtime. I know we can parse the files manually using the XML api. The use case is that we allow custom (read 3rd party) types/assemblies to be used in our system, ...

Validate MSSQL identifier (parameter) in .NET or regular expression

In a .NET project I need to verify if a string is a valid Microsoft SQL Server 2005 parameter identifier. Example: SELECT * FROM table WHERE column = @parameter Is there a runtime class method to validate a string for being a parameter, or is there a regular expression that verifies the rules? (see below) From the documentation on ide...

How do I deserialize XML without knowing the type beforehand?

Say I have a couple of basic objects like so: [Serializable] public class Base { public string Property1 { get; set; } public int Property2 { get; set; } } [Serializable] public class Sub: Base { public List<string> Property3 { get; set; } public Sub():base() { Property3 = new List<string>(); } ...

Determining the parent process id from C#

I would like to determine the process id of the parent process for an arbitrary process in Windows. I need this method to work on both x64 and x32. Any ideas / sample code to make this happen. System.Diagnositics.Process does not include this info. I am a bit worried about using the toolhelp apis cause they are 32 bit specific. R...

Using System.Json for non-Silverlight projects?

Any idea on how to do it? If not possible, what's a good JSON library for C#? ...