.net

What is the best solution? Using WF StateMachine to follow user states on a web application.

I was looking at WF and was wondering if it would be best to use the StateMachine workflow to follow a users state. i.e. user is anonymous, user is known but not authenticated, user is known and authenticated. would this be a good way to go about solving this regular issue? ...

What is the difference between myCustomer.GetType() and typeof(Customer) in C#?

I've seen both done in some code I'm maintaining, but don't know the difference. Is there one? let me add that myCustomer is an instance of Customer ...

.NET Architectural issue: 2 Web Services, how do I change which one is used at run time?

I am working with Reporting Services and Sharepoint, I have an application that leverages reporting services however a client would like our application integrated into sharepoint. Currently we are tightly coupled to the ReportService.asmx webservice which exposes various methods for performing operations. Reporting Services has somethin...

How to convert Pixels to Points (px to pt) in .NET? (C#)

I have a need to convert Pixels to Points in C#. I've seen some complicated explanations about the topic, but can't seem to locate a simple formula. Let's assume a standard 96dpi, how do I calulate this conversion? ...

How to deal with .NET TabPage controls all ending up in one Form class?

I'd like to structure a Form with a TabControl but I'd like to avoid having every control on each TabPage end up being a member of the Form I'm adding the TabControl to. So far I've identified these options, please comment or suggest alternatives: 1) Write a UserControl for each TabPage 2) Leave only the Control on the main Form but tu...

Bare Minimum Configration for RESTful WCF

What is the bare minimum I need to put in web.config to get WCF working with REST? I have annotated my methods with [WebGet], but they are not getting the message. ...

Can someone provide a practical example of how they have used attributes on method parameters in .Net?

I know it's possible, and I've seen simple examples in the docs, but I was wondering if anyone on here has actually used them. I use attributes at the class and method level all the time, but have never used them on method parameters. Have any of you guys? If so, what was your reason and can we see the example? I'm not interested in see...

What's the foolproof way to tell which version(s) of .NET are installed on a production Windows Server?

This question is not so much programming related as it is deployment related. I find myself conversing a lot with the group in my company whose job it is to maintain our production Windows servers and deploy our code on them. For legal and compliance reasons, I do not have direct visibility or any control over the servers so the only wa...

ASP.NET Validation Controls and Javascript Confirm boxes

I have a page using .NETs server-side input validation controls. This page also has a javascript confirm box that fires when the form is submitted. Currently when the Submit button is selected, the javascript confirm box appears, and once confirmed the ASP.NET server-side validation controls are fired. I would like to fire the server-...

Using InstallUtil and silently setting a windows service logon username/password

I need to use InstallUtil to install a C# windows service. I need to set the service logon credentials (username and password). All of this needs to be done silently. Is there are way to do something like this: installutil.exe myservice.exe /customarg1=username /customarg2=password ...

How can I return a custom HTTP status code from a WCF REST method?

If something goes wrong in a WCF REST call, such as the requested resource is not found, how can I play with the HTTP response code (setting it to something like HTTP 404, for example) in my OperationContract method? ...

What triggers ConstraintException when loading DataSet?

How can I find out which column and value is violating the constraint? The exception message isn't helpful at all: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. ...

Targeting .NET Framework 3.5, Using .NET 2.0 Runtime. Caveats?

I'm developing an application that is targeting the .NET 3.5 Framework. The application's setup installs the .NET 2.0 runtime on the target machine. So far I haven't had any issues with doing this, but I'm wondering what problems I'm going to have down the line. Do I need to be installing the 3.5 runtime? I must package the .NET runtime...

Is there a way to return different types from a WCF REST method?

I am trying to write a web service to spec and it requires a different response body depending on whether the method completes successfully or not. I have tried creating two different DataContract classes, but how can I return them and have them serialized correctly? ...

Catching 'external drive inserted' event in a windows service

I'm trying to write a super-simple podcast-to-device downloading service to use for running. I imagine that it'll like this: Whenever a particular device is plugged in (via USB), it: Deletes everything from the device Checks for all the latest entries in a number of RSS Podcast feeds Downloads those to the device Notifies the user a...

Nullable entity projection in Entity Framework

I have a following SQL Server 2005 database schema: CREATE TABLE Messages ( MessageID int, Subject varchar(500), Text varchar(max) NULL, UserID NULL ) The column "UserID" - which can be null - is a foreign key and links to the table CREATE TABLE Users ( UserID int, ... ) Now I have several POCO classes with names ...

What is the maximum possible length of a .NET string?

What is the longest string that can be created in .NET? The docs for the String class are silent on this question as far as I can see, so an authoritative answer might require some knowledge of internals. Would the maximum change on a 64-bit system? [This is asked more for curiosity than for practical use - I don't intend to create any ...

Base constructor in C# - Which gets called first?

Which gets called first - the base constructor or "other stuff here"? public class MyExceptionClass : Exception { public MyExceptionClass(string message, string extrainfo) : base(message) { //other stuff here } } ...

Is there a NAnt task that will display all property name / values?

Is there a NAnt task that will echo out all property names and values that are currently set during a build? Something equivalent to ant's echoproperties task maybe. ...

Is it possible to compile .NET IL code to machine code?

I would like to distribute my .NET programs without the .NET framework. Is it possible to compile a .NET program to machine code? ...