.net

Extend WebService without impacting existing clients - returning derived types from query

If I have a web service method, e.g. [WebMethod] [XmlInclude(typeof(SportsCar)), XmlInclude(typeof(FamilyCar))] public Car[] GetCars() { Car[] cars = new Car[2]; cars[0] = new FamilyCar(); cars[1] = new SportsCar(); return cars; } If I want to add a new car type to my service, I woul...

'Contains()' workaround using Linq to Entities?

I'm trying to create a query which uses a list of ids in the where clause, using the Silverlight ADO.Net Data Services client api (and therefore Linq To Entities). Does anyone know of a workaround to Contains not being supported? I want to do something like this: List<long?> txnIds = new List<long?>(); // Fill list var q = from t in ...

Being specialised and keeping up

One of the things mentioned recently maybe in the SO podcast or Joel was that the best way to succeed at business when you start out is to start specialised and concentrate on one thing only. If you say you're the jack of all trades; you're just another jack! If you say you're a specialist in - I think joels example was some type of fau...

Set folder permissions with C# - convert CreateObject("Wscript.Shell") from vb to C#

Hello. I'd like to know how to convert this vb script to C# Dim strFolder As String Dim objShell As Object strFolder = "C:\zz" Set objShell = CreateObject("Wscript.Shell") objShell.Run "%COMSPEC% /c Echo Y| cacls " & _ strFolder & _ " /t /c /g everyone:F ", 2, True What I'm trying to do is set per...

How do I implement a many-to-many association from an entity to itself in Entity Framework?

I have an entity that exposes a collection of children of the same type. The entity can itself be a child of another instance - in effect a many-to-many relationship with itself. In the database I have a linker table with two columns - parentId and childId - both of which reference the Id column in my entity table. Entity Framework corre...

Open-source zip library for .NET?

Does anyone know of a good open-source zipping library for .NET? ...

Are event subscribers called in order of subscription?

Is it safe to assume that event subscribers are called in order of subscription? Example: void One(object sender, EventArgs e) {} void Two(object sender, EventArgs e) {} event EventHandler foo; foo += One; foo += Two; Is One() always called before Two() when the event is fired? Edit: You should ofcourse not rely on it, I was just...

What do you think of the new Microsoft Sync Framework?

Are you using it or plan to use it? ...

Allow users to insert a TAB into a TextBox but not newlines

I want to have a TextBox which does accept the TAB key (and places a TAB, ASCII 0x09, \t accordingly into the textbox) instead of jumping to the next control. The TextBox has a property AcceptsTab, which I have set to true but this does not give the desired result. It turns out the AcceptsTab property only works then Multiline is set to ...

Add extra column to fill out space in datagridview C#

I have a datagridview which im binding DataTable to. What I want do is add an extra column which will fill out the remaining gap in the windows form. At the moment I only have 3 columns so the width of all the columns is only about half the size of the windows form. ...

Access 2007 - "Could not update; currently locked"

Hello. First sorry for my bad english but I'll try my best. Right now I'm programming a .net application using Access 2007 as datastore. In a nutshell: I have two threads. One thread inserts a row with a transaction into a table. The other thread updates many rows in constant intervals. Thread 1 Database db = _loggingDatabase; usin...

How do I create a new windows form, and associate it with an already existing thread?

I'm trying to write a chat client in C# and have run into a problem. How it works is that the client polls the server every 1 second to see if there are any new actions to take (for example display a message in a channel, or whatever). The polling is done in a thread of its own. Now, I want the polling thread to open a new MDI form whe...

How to be able to select a portion of the screen?

In some screen capture software when you press a key it's possible for the client to select a portion of the screen. How can I implement that in my software written in framework 2.0 .Net? Here is a image of what I would like to do : http://img341.imageshack.us/img341/3782/portionpb9.png you see, I can select a portion of the screen. How...

Script.Net vs Nemerle

I was looking into scripting to be incorporated into my apps. Then I bumped into Script.Net and Nemerle. I do know that they have different syntax and Nemerle supports macro but not Script.Net. But I would like to know more about their differences in terms of functionality, usage and flexibility. And which one would you recommend, why? ...

How to check if an object is nullable?

Hi, How do I check if a given object is nullable in other words how to implement the following method... bool IsNullableValueType(object o) { ... } EDIT: I am looking for nullable value types. I didn't have ref types in mind. //Note: This is just a sample. The code has been simplified //to fit in a post. public class BoolCon...

Dependencies of references not copied to output directory

I have a CommonUtils lib I have built into a dll which I file reference from several of my projects. CommonUtils depends on log4net.dll which was set as a file reference and copy-local=true when CommonUtils.dll was built. log4net.dll and CommonUtils.dll are not in GAC. Everything works fine in MyWorkingProject where I only have a file r...

How to print to a null printer in .NET?

I need to write a unit test for a method that will print a document. Is there an easy way to send the output to the Windows equivalent of /dev/null? I'm guessing that having our build server print a document on every check in is going to get expensive quickly. ;) Ideally, this would work on both our build server (which has no default...

Why not upgrade to the latest .net framework

I see a lot of people has .net 2.0 or even 1.1 as a requirement for their projects. In my own workplace there is also lots of skepticism for upgrading to the latest and greatest .net framework. As a programmer I feel it is very frustration working with the older frameworks when you know that you could have done this so much easier with...

Boxing/Unboxing and Nullable?

I understand that boxing and unboxing is about casting (real type to object... object to real type). But I do not understand what the MSDN say about it with the Nullable. Here is the text I do not understand: When a nullable type is boxed, the common language runtime automatically boxes the underlying value of the Nullable object, no...

How do I get a specific drive's icon for any version of Windows?

In a .NET WinForms app, how do I get a specific drive's icon (C:\ for example) for whatever version of Windows the client might be running? ...