.net

Will it be any performance issues when referencing 2.0/3.5 assemblies from .net 4.0 project?

I've found a lot information in internet about this, but I can't answer for myself; will .net 4.0 application work slower if I add .net 3.5/2.0 assembly, and should I recompile them in 4.0 if I can? ...

Assert.AreEqual() Exception in VS2010

I am fairly new to unit testing and am using VS2010 to develop in and run my tests. I have a simple test, illustrated below, that simply compares 2 System.Data.DataTableReader objects. I know that they are equal as they are both created using the same object types, the same input file and I have verified that the objects "look" the sam...

Best architecture for accessing secondary database

I'm currently developing an app which will use a Linq to SQL (or possibly EF) data access layer. We already have a database which holds all our Contacts information, but there is currently no API around this. I need to interact with this DB from the new app to retrieve contact details. I can think of two ways I could do this - 1) Develo...

How does the " is " operator work internally

I want to compare the type of an object to a type to see if they are the same. I do not have the object, just the type of the object. I can do type1 == type2 and get general equality I can have a recursive loop where I repeat the above step for type1.BaseType until the BaseType is null. I can do type1.GetInterface( type2.FullNam...

How to check if a checkboxes state has changed

Using .Net, I need to generate a response based on only the checkboxes on my form that have had there states changed. So how do I know if the check box has changed from its previous value before submission. I can't use the onchange event because the user may check multiple boxes before submitting. ...

SQL Server Compact Edition 3.5 performance

I am using SQL Server CE 3.5 SP1 in one of my client applications. When a user loads the program and starts using it, performance is fine. If the user lets the program sit idle for a while, it takes a considerable amount of time (10 or more seconds) for the program to respond. Every time the user asks for a new screen, a call is made to ...

TextChanged Events - Why does this not result in an infinite loop?

While trying to do something a bit more complicated, I ran across a behavior I don't quite understand. Assume the following code below handling the textChanged event. private void textChanged(object sender, TextChangedEventArgs e) { TextBox current = sender as TextBox; current.Text = current.Text + "+"; } No...

RuntimeBinderException - C# .NET 4 Dynamic Keyword - Help Me Understand Why Method Isn't Matching

I've built a generic config system for an HttpModule that allows pluggable HTTP header inspectors. For reference, here is the basic layout of the code -- this should be enough to get a feel for what I'm doing: public interface IHttpHeaderInspectingAuthenticatorFactory<T> where T: HttpHeaderInspectingAuthenticatorConfigurationElemen...

Is there a simple to know if my connection string is encrypt or not?

I want to know if my connection string is encrypted or not. I don't want to encrypt it again and again. This is only an issue in development stage. Any way to check the status of the connection string in App.config? ...

Best .NET Development Conference

My employer has offered to send me to any conference I choose this year. I guess I just missed MIX. I went to VSLive last year and enjoyed it quite a bit. I've never been to PDC or TechEd so that's what I'm leaning toward. Am I missing any others? ...

Selectable TextBlock or a TextBox with formatted text in WPF

I have a situation where I need to show a formatted text (normal, bold, highlighted) and should also be selectable so that user can copy the text. I have used textblock where i can apply multiple formattings using Inline content flow elements but unfortunately it's text is not selectable. Whereas Textbox allows to select text and copy...

Find time zone from IP address

Is there a way to find the time zone a user is in when all I have is their IP address? I'm looking for the time offset I need to apply to the server time in order to find the time for the user's location. ...

Use AttachedProperty in Style in ControlTemplate

Here is my simple app: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:app="clr-namespace:WpfApplication1" Title="Window1" Height="300" Width="300"> <Window.Resources> <Style x:Key="Test"> ...

System.Threading.Tasks - Limit the number of concurrent Tasks

I have just started to look at the new "System.Threading.Tasks" goodness in .Net 4.0, and would like to know if there is any build in support for limiting the number of concurrent tasks that run at once, or if this should be manually handled. E.G: If I need to call a calculation method 100 times, is there a way to set up 100 Tasks, but ...

How to convert a character to key code?

Hello everyone, How can I convert backslash key ('\') to key code? On my keyboard backslash code is 220, but the method below (int)'\\' returns me 92. I need some generic conversion like int ConvertCharToKeyValue(char c) { // some code here... } Any ideas? ...

AES-XTS implementation in C#

Is there any implementation of AES-XTS written in C# available in the Internet? Bouncy Castle disappointed me :( I took the source codes of TrueCrypt and FreeOTFE but they are written in C which is very hard for me to understand... Anyone? ...

Can Visual Studio 2010 Test .net 3.5 SP1 Projects?

I have some projects in a solution that are running on .net 3.5 SP1 (and can never ever be updated to 4.0 as they are SharePoint projects). When I try to create a new Visual C# Test Project in VS2010 Premium, I have to choose .net 4.0 which is apparently intended. Now I don't care about what my Unit Test project is (don't have to care ...

How can I require an attribute on a class definition?

Is there a way to enforce a compile requirement for certain attributes on a class or interface implementation? For example, let's say my application uses a series of static classes that contain const int resource values. I'd like to decorate the class in a Description attribute to describe its contents. In concept, I'd like to apply t...

Federated Identity- Windows Identity Server - disable cookies in the browser

Hello, I see that Federated Identity stores Security token to a cookie, after its first request to the STS(Secure Token Service). In that case if I disable cookie in my browser, how does it work. Does the authentication module again connects to the STS to retrieve the user information or will it throw any error ? Is there any way th...

Casting an object to two interfaces at the same time, to call a generic method

I want to call a generic method that constrains the input type T to implement two interfaces: interface IA { } interface IB { } void foo<T>(T t) where T : IA, IB { } How can I fix the last line of void bar(object obj) { if (obj is IA && obj is IB) { foo((IA && IB)obj); } } ? Reflection probably allows to do th...