.net

Header File Template

Is there a standard template to use for .NET source code files? I am accustom to putting my header information between /* */ tags, but StyleCop is complaining about those. ...

Conditional LINQ where statement?

I have a linq statement that I want to add an additional where clause to if a drop down index is not 0. people.Where(n.surname == "surname" || n.forename == "forename" && (dropdown.SelectedIndex > 0) ? n.id = dropdown.SelectedValue : n.id > 0).Select(n => n); I am not even sure if what I am trying is possible?? I would like to do th...

Control that gets a tab stop twice

In a standard WinForms application, is it possible to have a scenario like the following and how would I do it: A form with four textbox controls, arranged on the form from top to bottom: TextBox1 TextBox2 TextBox3 TextBox4 The desired behavior is that when the form loads, the focus is on TextBox3, but when tabbing out, the focus go...

How can I tell if a thread is finished executing without polling ThreadState?

Is there an elegant way to know when a worker thread is done executing so I can access resources it produced? For example if the worker thread queried a list of SQL Servers using ServersSqlDataSourceEnumerator.Instance.GetDataSources(); and saved the result in a DataTable variable, what mechanism can I use to know when this DataTable...

Precise definition of the term 'marshalling'.

In the .NET world, does marshalling mean just the preparation of an object/data for transfer across some boundary or over a wire OR does it mean the preparation and transfer across a boundary or over a wire. And what does to marshal a call mean. Does it mean just the packaging of the call for "transfer" over a context boundary or is it ...

WCF Security Problem with UserName clientCredentialType

Hi, First of all I apologize for my english... Then: I have a problem! I wrote the code for a simple WCF Service and with the configuration #1 all works fine. Conf #1 - server <configuration> <system.serviceModel> <services> <service name="WCFservice.Service" behaviorConfiguration="WCFservice.ServiceBehav...

Deploying and running .NET assemblies on a worker computer

I have a basic task framework, where task such as doing some content processing, report generation, error log watcher, mailer, etc., is encapsulated in an ITask interface, which has a Run method, and other status related members. These tasks are either run continuously on a schedule, or on demand. They are hosted either as a windows serv...

How do I determine the colour mode of an uploaded image in ASP.Net

I have an asp.net page where I am letting the user upload an image file using a FileUpload control. I allow them to upload png, gif and jpeg images. I want to limit the type of image they can upload, specifically I want to only allow them to upload images which have a colour mode on RGB. How can I check the colour mode of an uploaded ...

.NET Single Line Logging (ala Trace.Write/WriteLine) using Instrumentation.Logging

Hello Everyone, My question is whether it is possible to get line/multiline (very unsure of correct term for this) behaviour of the Trace.Write and Trace.WriteLine methods but using the Microsoft Instrumentation Logging framework in .NET 2.0. Desired Output Hello World! Oh Hai. What I Currently Have Trace.Write("Hello "); Trace.Wri...

C# automatic property deserialization of JSON

I need to deserialize some JavaScript object represented in JSON to an appropriate C# class. Given the nice features of automatic properties, I would prefer having them in these classes as opposed to just having fields. Unfortunately, the .NET serialization engine (at least, by default) totally ignores automatic properties on deserializa...

Why is this CRC32 implementation in C# so slow?

I'm using the following function to compute the CRC32 of a file in a VS2008, .NET 3.5 project: public UInt32 ComputeHash(System.IO.Stream stream) { unchecked { const int BUFFER_SIZE = 1024; UInt32 crc32Result = 0xFFFFFFFF; byte[] buffer = new byte[BUFFER_SIZE]; int count = stream.Read(buffer, 0, ...

.NET MVC and securely passing data between pages

a little background info first. I have been using Web Forms for most of my career and have recently become interested in .NET MVC. I realize that it is intended to be stateless, however, i dont understand how it is completely feasible. In a forms application, the user authenticates and I return a user ID and some roles which are then pla...

Built-in methods to construct a POST request body in .NET?

I am looking for a built-in utility method in .NET for constructing HTTP POST message body for the two common content types: application/x-www-form-urlencoded multipart/form-data I'd rather use someone else's ready and tested implementation than roll my own, even though I realise it's not difficult to do so. However there doesn't see...

Insert empty BLOB into SQLite DB using ODBC and C++ Net

I'm using a SQLite database to store cover images of books I have in a database. I've got the inserting of BLOBs ok, but when I don't have a cover image for my book I can't seem to get it to insert a null BLOB. I'm using parameters for my insert SQL statement, using ODBC, as shown below: OdbcParameter^ paramCoverImage = gcnew OdbcParam...

Using the Lutz reflector for seeing IL code

I have a class with a few methods and I would like to see how the code is converted to IL code. Can I do this using the reflector? If not, can I use VS IDE to view the IL code? ...

Been a LAMP developer for years, now transitioning to the Microsoft Web Stack. Where do I begin?

I've always worked with the standard Linux web stack (linux, apache, php, python, mysql) but have been given a great job opportunity working with a group that works with the Microsoft Web Stack (IIS, ASP.NET, MSSQL, C#). There seems to be a pretty good Microsoft following here on SO. Where should I begin? Specific books, tutorials, on...

Dump WebRequest transmissions for debugging purposes?

My application is performing numerous HttpWebRequests, and some of them fail occasionally. I would like to dump the bytes leaving my PC whenever I perform a request as well as the bytes arriving as a response. Is it possible to do this from within my code easily? I'd only like to use something like Wireshark as a last resort if no othe...

What is the best mechanism for communicating cross-process in Windows CE?

I need to broadcast an event that can be picked up by any application running on a Windows CE 5 device. Haven't done this before so i'd be interested in knowing what techniques people would suggest to see if there is anything i've not considered. All of the applications that need to receive this event are .NET Compact Framework based s...

What's the preferred method for storing user settings in a .NET windows app?

Pardon my ignorance, but I've never really developed windows apps. How do you store user settings? Is an embedded database the preferred method? ...

Can a Visual Studio component designer access and modify the project .config file?

Can a component designer access and modify the app.config or web.config file of a project at design time? More specifically, is there some hosting service exposed by VS to do this 'the proper way' ? I know I can locate the .config file myself, open it and have my way with it as I please, but I want this to go through the VS sanctioned wa...