.net

Is there a tool out there to find out which .NET framework is installed on a PC?

I know the official way is the registry, but this kinda timeconsuming. I have to check installed versions on several PC's, none of them have VisualStudio , but all of them (probably) a version of .NET framework. Since the hot water probably exists already, where can i find it? ...

.NET: Conditional Socket.Accept

There doesn't seem to be any method of Socket, or ListenSocket that will allow me to conditionally accept connections. When I recieve a SYN, I want to be able decide if I want this connection depending on the source, if I send a SYN/ACK back (accept connection) or a RST (a forceful reject). Is there any want to achieve this? Unfortunat...

How do you unit-test a TCP Server? Is it even worth it?

I'm developing a small TCP server, which will process some TCP packets and behave differently based on the request. How can I write unit test for this? If it's really hard to write, is it even worth the effort? ...

Long running Windows Services

Folks, I want to develop a long running windows service (it should be working without problems for months), and I wonder what is the better option here: Use a while(true) loop in the OnStop method Use a timer to tick each n seconds and trigger my code Any other options ? Thanks Essam ...

Which .NET library / wrapper do you recommend for sniffing packets ?

As far as I understand all sniffing libraries in .NET just a wrapper around WinpCap, which is OK. If you know any other better option please write as answer. Have you used any of them? Which one is the best according to your experience? I'm only looking for libraries which have commercial friendly licenses, Also commercial libraries ar...

How does the .NET runtime determine that two types are the same?

Hello, I have assembly A that depends (statically) on type T (reference type, a class) in assembly B. I do not own assembly A but I do own assembly B. T unfortunately is a real type (not an interface) but luckily A uses reflection to discover its members. I want to be able to create dynamically B (and T). The only important item is th...

Parameter naming: filename or fileName?

I try to be grammatically correct in my naming*. I've always used filename instead of file*N*ame. The java convention also seems to use this, but FxCop prefers fileName. There's a discussion on WikiPedia about it. The more I read, the more I feel I'm right (which is quite usual! :) ). Does anyone have a definitive answer or is this ...

.NET programmable graphics matching?

Does anyone know of a .NET programmable/usable API for reading an image file, and comparing it to an existing set of images? e.g. I have three pictures of the letters A, B, and C. I then copy the picture of A, and modify it so that it is flipped 180 degrees. I'd like to be able to have a piece of software that detects that it is a mat...

Immediately register and transfer domain for hosting for .NET

I'm doing a ASP.NET/SQL Server contract project. The client wants to show what's built so far to demo it for some third-party on a domain that's currently unregistered. Normally I register domain names through GoDaddy. But GoDaddy puts a lock for 60 days on your domain after its registered, so I'd have to get GoDaddy hosting too to dem...

Collections in DataContracts in partial trust scenarios

I've been pretty confused on one point in design of DataContracts for serialization. Say I have an object (e.g. a Customer) and it exposes a collection property (e.g. an AddressCollection named Addresses). Framework design guidelines dictate that I should not expose a public mutator for the property, i.e., the collection property shoul...

Createinstance() - Am I doing this right?

I'm trying to put together a plugins system with .NET, and I'm not sure if I'm doing it correctly. The basis of the system is that a specific directory ({apppath}/Plugins/) will have a bunch of precompiled DLLs, and I want to look through each one with reflection, and for every class available, if it inherits a specific base class (this...

How do I auto-create a code snippet in Visual Studio 2008?

I'm trying to create an interface that automatically implements a fully typed out method in VB.Net However, I can't figure out how to do it. I wanna do something that's similar to what happens when you implement IDisposable, where it gives you the full function, including codes and comments. I know how to make a code snippet and how ...

Mono XSP License

First of all I'm sorry for such a question, I look over the internet and google searches but there so many different ideas out there. In a mail-list I actually see that people claim that one need to buy Mono license to use it in a commercial tool. Can I use Mono XSP in a commercial tool, does licensing permits that? I'm not good with r...

extension method on type and nullable<type>

For sake of simplicity, let's assume I want to write an extension method for the type int? and int: public static class IntExtentions { public static int AddOne(this int? number) { var dummy = 0; if (number != null) dummy = (int)number; return dummy.AddOne(); } public static int AddO...

linq to xml and ViewList problem

Hello everybody, I seems to run into problem, and not sure how to make it work. I am trying to take data from XML by using linq and the code works, however when i try use this linq data as DataSource for the ListView, i am getting an error. How can I make it work ? How do i convert my var variable to proper variable so ListView with th...

contravariance seem to cause a conficted behavior

The following example is taken from C# in Depth: What you need to master C# 2 and 3, and seems to only only cause a breaking change as jskeet has identified, but be wrong. Please explain: delegate void SampleDelegate(string x); public void CandidateAction (string x) { Console.WriteLine("Snippet.CandidateAction") } public class...

What are all the usages of '@' in C#?

I have noticed this piece of code: FileInfo[] files =new DirectoryInfo(@"C:\").GetFiles(); What is the purpose of @? Are there other uses? ...

How captured value in anonymous methods are implemented in .NET

I am curious about the actual .NET implementation and the decision behind it. For example in Java, all captured values used in an anonymous classes are required to be final. This requirement seems to be dropped in .NET. Also, is there a difference in an implementation of captured values for value types as opposed to reference types? T...

yield statement implementation

I want to know everything about the yield statement, in an easy to understand form. I have read about the yield statement and its ease when implementing the iterator pattern. However, most of it is very dry. I would like to get under the covers and see how Microsoft handles return yield. Also, when do you use yield break? ...

How to access command line parameters outside of Main in C#

I am writing a .NET class that needs to parse the command line of the process. I don't want to have a dependency between the Main() method and that class. How can the class access the command line? ...