.net

How can I improve our .NET productivity?

I lead a team of six developers, and over the last year we've migrated over to a Silverlight/WCF/C#/EF/SQL Server architecture for our development. We've now deployed 5 or 6 small apps using this architecture, and we are currently working on a larger system. We've developed our own little solutions framework which we use as a template f...

HTTP Server invalid request/connection throttling

I have a custom HTTP server. When F5 is held down in a browser the server gets slammed with requests. How can I detect and limit these (or any other) invalid connections? It seems that I would have to record, for each incoming IP, the length of time between each request and whether or not the request was valid. If a certain number of...

Status of Spark View Engine

It’s been a while since the community got any feature releases from the spark team. Has it ceased development? With the advent of Razor, has Louis moved on? The least release was in March and the last development build was in July ...

How to share libraries without using the GAC?

I have a library that is meant to be used by many websites. The way I am doing it now is in the library's properties, I set the "Post-build event command line" to: copy "$(TargetPath)" "$(SolutionDir)\MyWebsite\bin\$(TargetFileName)" Every time I want a new website to use the shared library, I add a new line like this: copy "$(TargetPat...

How should I handle resources created by XmlSerializer?

Let's say I have a class: class Class1 { public List<Class2> Classes; } that I deserialize with XmlSerializer and Class2 creates some stuff that I should Dispose. Should I dispose everything myself or is that going to be done automatically? ...

LINQ Aggregate behavior of nullable types

Hi, Can someone explain what is going on here? Howcome both these things are true? [TestMethod] public void WhatIsGoingOnHere() { List<int?> list = new List<int?> { 1, 2, 3, null, 5, 6 }; Assert.AreEqual(17, list.Sum()); int? singleSum = 1 + 2 + 3 + null + 5 + 6; Assert.IsNull(singleSum); } Specifically, why does th...

What is the purpose of Attributes in C#?

What is the purpose of Attributes in C#? How do I know which attribute have to use for particular functionality? How can I add them dynamically in c#? What are custom attributes ? ...

How do I stop a setter being exposed over web services?

Hi All, I want to have an class like this, public class Apple { public string Size { get; set;} public string Colour { get; set;} public string Shape { get; set;} public int appleId { get; set;} } I want to expose that over web services using some web methods like this, public void AddApple(Apple apple) { } public A...

Get all users from AD domain

Hi guys, I have a need to be able to identify all of the users on my AD (Active Directory) domain. I have the domain name and that is about it. It would rock if i could get it as a list of UserPrincipal or something but if its just a string then i can get the rest of the info i need from there. Thanks! ...

Where does a user-control go when the visibility of it is set to false?

Curiosity is kicking out again. I've been using the user control .Visible and .Hide() method for a long time. So where does a user-control go when the visibility of it is set to false? ...

Validating Uri from String

Hi everyone, I need an Uri validation method. So, strings like: "http://www.google.com", "www.google.com", "google.com" ..must be validated as Uri's. And also normal strings like "google" must not be validated as Uri's. To do this checking, I use two methods: UriBuilder and Uri.TryCreate(). The problem with UriBuilder is that any s...

What's the different between ldsfld and ldstr in IL?

I've read some article about String.Empty vs "" and I also do test by my self. Different between them are below. String.Empty L_0001: ldsfld string [mscorlib]System.String::Empty "" L_0001: ldstr "" After I talk with my friends they argue that String.Empty is faster than "" because under the hood (at assembly level) ldstr do more ...

openTK vs openCL.NET

I am getting started with openCL on .NET. How is openTK compared to openCL.NET - which is better? ...

Is the AutoResetEvent type an appropriate choice for an atomic switch?

Suppose I am processing a large amount of incoming data from multiple threads. I may want for this data to act as a trigger for a specific action when certain criteria are met. However, the action is not reentrant; so the same trigger being fired twice in rapid succession should only cause the action to run once. Using a simple bool fla...

wpf app - why is the window size larger than I set it to?

Hi, Any ideas re why the WPF application I've starting building has a larger width and height than what I set in VS2010? That is, in VS2010 I set the height of the window to be AUTO (so it should be just high enough to contain the controls) and this seems to work visually within VS2010. But when I then run the application the window h...

Pausing an animation rotation, setting the angle value, then resuming later?

I have a situation where I have a 3d Model that has a constant rotation animation. When a user touches the screen, I would like the rotation to stop, and the user's control to take over the animation of the rotation. I tried to do this by pausing the animation, setting the angle property of the rotation locally, then resuming the rotati...

How do I set a timer XAML.CS which acts like HoverIntent in Javascript

Trying to include a hoverIntent based on the following code: private void ViewerTab_MouseLeave(object sender, MouseEventArgs e) { _mouseOverTabPanel = false; ChangeCurrentPanelPosition(TabPanelPosition.Bottom); } private void ViewerTab_MouseEnter(object sender, MouseE...

How to get the ListBoxItem for an item in ListBox on "bind-time"

I have a ListBox with Foo objects, and based on some events I disable/enable the ListBoxItems in the ListBox. Using the ListBox.Items property I find Foo objects, and from what I've understood I need to use the following function to get the ListBoxItem container for the Foo. Correct? foreach (var item in Items) { var lbi = ItemCont...

Call to GetData fails silently in DragDrop event

Hello, I am building a Winforms application with drag and drop support into a TextBox. The TextBox should allow files and text to be dropped onto it. Its AllowDrop property is set to true. This is the event handler for its DragDrop event: var validFile = e.Data.GetDataPresent(DataFormats.FileDrop); var validText = e.Data.GetDataPrese...

Accessing resource from server component in ASP .NET

I'm a beginner in the black art of ASP .NET development, so forgive me if this is a stupid question. After a bit of googling, and reading though (some of...) ASP .NET 3.5 Unleashed, I've yet to find a way of doing what I want - which usually either means I'm trying to do something stupid, or it's so obvious I've missed it :) I'm creati...