.net

Deserializing JSON into an object with Json.NET

Hello. I'm playing a little bit with the new StackOverflow API. Unfortunately, my JSON is a bit weak, so I need some help. I'm trying to deserialize this JSON of a User: {"user":{ "user_id": 1, "user_type": "moderator", "creation_date": 1217514151, "display_name": "Jeff Atwood", ... "accept_rate": 100 }} ...

In WCF , when should a TCP binding be used?

In WCF , when should a TCP binding be used? I know the scenario when web browser is the WCF client. In that case HTTP is used. But what are the scenarios for TCP ? Thanks for ur replies. ...

problem with addressfilter in WCF

I've build my own WCF channel with all necessary stuff (like encoders, bindings, etc) to use it with ServiceHost. I just want to build the "channel stack" making no custumizations at "Service Model". To acomplish this, my encoder returns perfect ServiceModel.Messages with a XML infoset just like other channel does. Lets assume the fol...

Robust DateTime parser library for .NET

Hello, I am writing an RSS and Mail reader app in C# (technically MonoTouch). I have run into the issue of parsing DateTimes. I see a lot of variance in how dates are presented in the wild and have begun writing a function like this: static string[] DateTimeFormats = new string[] { "ddd, d MMM yyyy H:mm:ss \"GMT+00:00\"", "d MM...

In WCF how to remove bindings from the metadata?

The WSDL generated by WCF is describing all my bindings, and I want it to describe only the wsHttpBinding. I want it because a PHP client can't parse the WSDL if it contains unknown bindings. There is a way to do that? ...

How to consume WCF WebServices from PHP?

I have to consume a WCF WebServices but the WSDL contains bindings that PHP doesn't support also. SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport 'http://schemas.microsoft.com/soap/named-pipe' How to bypass this problem? ...

.NET Weird character encoding issue

Our globalization mechanism stores error messages in a SQL 2005 DB. Some of the error messages are used as subjects on email messages sent to the development team. Recently, with no clear reason, we started receiving emails with strangely encoded subjects, such as: =?utf-8?B?Qm1mQm92ZXNwYS5Qb3NUcmFkaW5nRXNwZWNpZmljYWNhbyAtIFN1Y2Vzc...

Communicating Between .NET Programs

I wanted to set up a simple data communication between two C# applications, and I'm not sure what the best method is in doing so. I've previously used Java Sockets and ServerSockets to get the job done, but I'm new to C#, so I've come for advice :) It's going to be two way communication with two clients exchanging strings or something ...

How to tell when a Socket has been disconnected

On the client side I need to know when/if my socket connection has been broken. However the Socket.Connected property always returns true, even after the server side has been disconnected and I've tried sending data through it. Can anyone help me figure out what's going on here. I need to know when a socket has been disconnected. ...

How to programmatically get sites list and virtual dirs in IIS 7?

Does anybody know how to programmatically get the sites list and virtual dirs in IIS 7? ...

what .NET class to proxy HTTP requests through? (and keep track of bandwidth used)

What .NET class/methods could I use to write a simple HTTP(s) proxy that would run on my PC that would: Proxy all HTTP(S) requests through it Let me get bandwidth used per proxy'ed request (e.g. content length) Let me get requesting application or process name per proxied request Ability to proxy/stream the requests on through to my n...

Explanation of casting/conversion int/double in C#

I coded some calculation stuff (I copied below a really simplifed example of what I did) like CASE2 and got bad results. Refactored the code like CASE1 and worked fine. I know there is an implicit cast in CASE 2, but not sure of the full reason. Any one could explain me what´s exactly happening below? //CASE 1, result 5.5 double a...

How to measure the pixel width of the string drawed over Drawing.Bitmap in .NET?

I am generating a png image that contains a text dinamically written. I need to create the bitmap with the minimum width for file size reasons. ...

How to get window opened/closed/minimized messages from a native app?

It's tough to write a good title for this one. I'm working on a WPF application which needs to know about the existence of all other open windows on the system. I'm able to do this by calling the native EnumWindows method just fine, and I can call other native methods to filter out just the windows I'm interested in. This works well. T...

Best way to provide software settings?

I'm using C# .NET. In my software I'm providing settings dialog through which user can set the application settings which I want to save to a file. Requirements (typical): Every class I defined uses some part of these settings. So, these should be global to all classes. These should be loaded while software is started. When ever use...

Where can I find information on the Get, Set and Address methods for multidimensional System.Array instances in .NET?

System.Array serves as the base class for all arrays in the Common Language Runtime (CLR). According to this article: For each concrete array type, [the] runtime adds three special methods: Get/Set/Address. and indeed if I disassemble this C# code, int[,] x = new int[1024,1024]; x[0,0] = 1; x[1,1] = 2; x[2,2] = 3; Console.WriteLin...

Binary comparison operators on generic types

I have a generic class that takes a type T. Within this class I have a method were I need to compare a type T to another type T such as: public class MyClass<T> { public T MaxValue { // Implimentation for MaxValue } public T MyMethod(T argument) { if(argument > this.MaxValue) { ...

C# Class Library wont register for COM

Hello All, I am trying to gain access to a .NET class library in Microsoft Excel. To do this I know that the .NET class library must be registered with COM. So I tried going to my Assembly Info and Setting COM Visible to true. Then on the build tab I set Register for COM Interop for true also. I checked the AssemblyInfo.cs file and it do...

What does MailMessage.IsBodyHtml do?

I'm testing sending out some emails via C#, but I can't tell what effect setting IsBodyHtml to true has. Regardless of the value, whatever I send in my Body shows up with a content type of "text/plain", and my HTML shows up tags and all in my email client (gmail). What is that flag actually supposed to do? NOTE: I can send an HTML ema...

How GC collects resources in a static member in .NET?

I have a piece of code like this: Class Program { static StreamReader sr = null; static int var=0; static Program() { sr = new StreamReader("input.txt") } ~Program() { sr.Dispose(); } static void main(string args[]) { //do something with input here } } This may not...