.net

Best way to update LINQ to SQL classes after database schema change

I'm using LINQ to SQL classes in a project where the database design is still in a bit of flux. Is there an easy way of synchronising the classes with the schema, or do I need to manually update the classes if a table design changes? ...

How do I create a database programatically in SQL Server?

I would like to create a new database from my C# application. How can I do that? I'm assuming once I create it, I can simply generate a connection string on the fly and connect to it, and the issue all the CREATE TABLE statements. ...

Exceptions in Web Services

My group is developing a service-based (.NET WCF) application and we're trying to decide how to handle exceptions in our internal services. Should we throw exceptions? Return exceptions serialized as XML? Just return an error code? Keep in mind that the user will never see these exceptions, it's only for other parts of the applicatio...

Notification API for windows

Linux has libnotify and OS X has growl. Is there some kind of Notification API for Windows too? It should be accessible via .Net languages. Clarification: Yes I'm looking for an way to send notification to the user, but it won't harm if one can subscribe to certain events with programs too. The linux libnotify uses a system wide D-Bu...

How to Compare Flags in C#?

I have a flag enum below. [Flags] public enum FlagTest { None = 0x0, Flag1 = 0x1, Flag2 = 0x2, Flag3 = 0x4 } I cannot make the if statement evaluate to true. FlagTest testItem = FlagTest.Flag1 | FlagTest.Flag2; if (testItem == FlagTest.Flag1) { // Do something, // however This is never true. } How can I mak...

Create object from database row

Let's say I'm building a data access layer for an application. Typically I have a class definition for a each kind of object that is stored in the database. Of course, the actual data access retrieves data in the form of a datareader, typed or untyped dataset, or similar, usually with the data needed to create one object per row in the...

Whats the difference between RuntimeTypeHandle and Type?

And why would I use one over the other in my code? ...

How to get an array of distinct property values from in memory lists?

I have a List of Foo. Foo has a string property named Bar. I'd like to use linq to get a string[] of distinct values for Foo.Bar in List of Foo. How can I do this? ...

Server centered vs. client centered architecture

For a typical business application, should the focus be on client processing via AJAX i.e. pull the data from the server and process it on the client or would you suggest a more classic ASP.Net approach with the server being responsible for handling most of the UI events? I find it hard to come up with a good 'default architecture' from ...

How should I cast in VB.NET?

Are all of these equal? Under what circumstances should I choose each over the others? var.ToString() CStr(var) CType(var, String) DirectCast(var, String) EDIT: Suggestion from NotMyself TryCast(var, String) ...

how do F# Units of Measure work

Has anyone had a chance to dig into how F# Units of Measure work? Is it just type-based chicanery, or are there CLR types hiding underneath that could (potentially) be used from other .net languages? Will it work for any numerical unit, or is it limited to floating point values (which is what all the examples use)? ...

How to Convert a StreamReader into an XMLReader object in .Net 2.0/C#

Here's a quick question I've been banging my head against today. I'm trying to convert a .Net dataset into an XML stream, transform it with an xsl file in memory, then output the result to a new XML file. Here's the current solution: string transformXML = @"pathToXslDocument"; XmlDocument originalXml = new XmlDocumen...

IRAPIStream COM Interface in .NET

I'm trying to use the OpenNETCF RAPI class to interact with a windows mobile device using the RAPI.Invoke() method. According to the following article: http://blog.opennetcf.com/ncowburn/2007/07/27/HOWTORetrieveTheDeviceIDFromTheDesktop.aspx You can do the communication in either block or stream mode. I have used block mode before, bu...

.NET Mass Downloader with VS.NET 2005?

After downloading all .NET framework symbols and sources using NetMassDownloader, is it possible to setup the VS.NET 2005 for debugging into .NET 2.0 source files? ...

WCF Service Returning "Method Not Allowed"

In the process of developing my first WCF service and when I try to use it I get "Method not Allowed" with no other explanation. I've got my interface set up with the ServiceContract and OperationContract: [OperationContract] void FileUpload(UploadedFile file); Along with the actual method: public void FileUpload(Upload...

Is there a best .NET algorithm for credit card encryption?

The .NET System.Security.Cryptography namespace has a rather bewildering collection of algorithms that I could use for encryption of credit card details. Which is the best? It clearly needs to be secure for a relatively short string. EDIT: I'm in the UK, where I understand we're OK storing encrypted credit card details so long as the ...

New Added Types in .NET Framework 2.0 Service Pack 1

I assumed there were only bug fixes/(no new types) in .NET 2.0 SP1 until I came across few posts which were mentioning DateTimeOffset structure, that was added in .NET 2.0 SP1. I there a full listing of the newly added types in .NET 2.0 SP1? ...

Find item in WPF ComboBox

I know in ASP.NET I can get an item from a DropDownList by using DropDownList1.Items.FindByText Is there a similar method I can use in WPF for a ComboBox? ...

Checking if a list is empty with LINQ

What's the "best" (taking both speed and readability into account) way to determine if a list is empty? Even if the list is of type IEnumerable<T> and doesn't have a Count property. Right now I'm tossing up between this: if (myList.Count() == 0) { ... } and this: if (!myList.Any()) { ... } My guess is that the second option is fas...

.Net ESB's out there

Does anyone know about .Net ESB's out there, I would prefer Open Source. Personally I know about - NServiceBus http://www.nservicebus.com/ - ESB.Net http://www.codeplex.com/KeystrokeEsbNet - Microsofts guidance on ESB using BizTalk ...