.net

Socket.RemoteEndPoint from SocketException

Hi there, A SocketException error is thrown when a client disconnects through Read/Write/Accept operations. When a SocketException is thrown I would love to have details about that 'Client' socket -- namely the Socket.RemoteEndPoint Any way of getting this from the SocketException object? I am particulary interested in obtaining req...

Howto find .NET version?

How do I find out which version of .NET is installed? I'm looking for something as simple as "java -version" that I can type at the command prompt and that tells me the current version(s) installed. EDIT: I better add that Visual Studio may not be installed - this is typically something that I want to know about a client machine. ...

Open source (free) Object mapping software for .Net

We're needing to map between one object and another, i.e. obj1.property1 needs to map to obj2.property3 and obj1.property2 needs to map to obj.property1, etc. I know there are open source frameworks for Java like Dozer. Are there any .Net ones out there? ...

Tool for displaying binary decision tree

The system I'm currently working on involves the creation of binary decision trees. Lots of them. Some of them are stored in XML format so they can be analyzed manually if needed. The tree structure is basically nested <NODE> tags. Each node may also have a few child tags defining the properties of the node. What I would like to do is ...

.NET Framework symbols and source files out of sync?

It seems that my .NET Framework debug symbols and their corresponding source files are out of sync. Here is an example. I’m trying to step in to ASP.NET MVC from a view. So I set a breakpoint on a function in ASP.NET MVC (using a function name). When Visual Studio stops there, it’s actually in the correct function, but the yellow highli...

.Net Hash Codes no longer persistent?

I have an API where various types have custom hash codes. These hash codes are based on getting the hash of a string representation of the object in question. Various salting techniques are used so that as far as possible Hash Codes do not collide and that Objects of different types with equivalent string representations have differen...

Is it possible to set private property via reflection

Can I set a private property via reflection? public abstract class Entity { private int _id; private DateTime? _createdOn; public virtual T Id { get { return _id; } private set { ChangePropertyAndNotify(ref _id, value, x => Id); } } public virtual DateTime? CreatedOn { get { return ...

How to search for a node using Linq to XML Query?

Below the xml doc <Root> <Global> </Global> <local> <section name="A"> <subsection name="A"> <innersection name="A"> <Property1> </Property1> </innersection> <innersection na...

When create a static method

I use resharper and resharper adviced me to declare one method as static and the another not. But i can't understand why the other method can't be static ? method recommended to be static private static string Prehod(string retazec) { var pole = retazec.ToCharArray(); var output = ""; char? temp = null; ...

Can't Allow User To Add Rows to DataGridView with List<> Datasource.

Hi everyone, I've DataGridView that bound to List<myClass> as DataSource. But when i set "AllowUserToAddRows" property to "True" there is nothing appear. I tried to change the DataSource to BindingList<myClass> and it's going well. I wonder if i should replace my List<> with BindingList<> or there is better solution ??. Thank you ve...

Is it possible to restart a PC using "pure" .NET and *without* using p/invoke?

Is it possible, without employing pinvoke, to restart a PC using .NET? I kind of just repeated the title, but I'm not too sure how to elaborate much further! Edit: I should have mentioned that don't want to use "shutdown -r" as a solution. I was really after a pure .NET way, something like: Environment.ShutDown(); In other words, s...

Converting TIFF files to PNG in .Net

I have to build an application in .Net (3.5) to pick up a TIFF file saved from another piece of software and convert it into a PNG so that it can be rendered easily in Internet Explorer. Does anyone know of any libraries (preferably freeware/open source) that will do this conversion for me? If there aren't any simple ways of getting it ...

Dragging and dropping a control from one form to another results in moving the control

Hi, I want to have another copy of some control upon dragging and dropping it to another form. My code results in moving the whole control. Is there a way to have the two of them being displayed at once given that I want them to have the same reference because the source updates values every second. here's my code public partial c...

Regex Help Wanted With Capture Groups

I am trying to extract some words from a string. The two cases look like this: Case 1: "Group X - Ford Mondeo or similar" Case 2: "Group X - Ford Mondeo" I would like a single .NET regex that captures "Ford Mondeo" in both cases. The best I have so far is: ^Group [A-Z] - (?<VehicleModel>.+)(?: or similar)$ which returns: Case 1: "F...

Why is this bad code?

I was looking at a question on here about confessing your worst code ever written and I am not quite sure, because of my lack of knowledge on why this is bad code. public string GetUsername (string userName) { User user = DbLookup.GetUser(userName); return user.Username; } Is it because, it assumes username will exist and doesn't ...

LINQ: help with "contains" and a Lambda query

Hi there, I have a list which contains enums, its a standard Enum but has an attribute attached to it and an extension method which returns a CHAR of the enum (see below - GetCharValue), the extension works great. Now I have (another extension method for linq) public static IQueryable<Building> WithStatus(this IQueryable<Building...

Date as simple text (e.g. Today, Yesterday, 1 Week Ago) in .Net

Hi, Does anyone have a simple function to hand for converting a date to a simple string (using .Net)? E.g. 14-Oct-09 would read "Today", 13-Oct-09 would read "Yesterday" and 7-Oct-09 would read "1 Week Ago" etc... Cheers, Tim ...

Forum solution (asp.net c#) handling Windows Authentication

Hi guys, We are searching for a Forum solution to integrate with one of the intranet solutions we have developed. At the moment we are testing Jitbit AspNetForum which seems to integrate quite well but it seems not to be focused on using it with Active Directory and Windows Authentication. We are not getting enough control over certai...

XML Documentation

Basic question here, but how would I reference the following (ie does it have a name). I looked on msdn and all I could find was they called is XML Documentation, which seems a bit misleading. /// <summary> /// This is a simple summary for my class /// </summary> /// <param name="foo"></param> /// <param name="bar">...

.NET 3.5 - Relax the strictness on Xml returned from a Web Service

I'm calling a SOAP 1.1 web service that I don't own and it's not strict about returning valid Xml. Specifically, when sending SOAP faults it's ignoring the order of sub-elements that are specified in the for the SOAP schema. The result is that when I call the service and it returns a SOAP fault I end up with a CommunicationException a...