.net

How to make SqlConnection timeout more quickly

I am using an SQL connection string with SqlClient.SqlConnection and specifying Connection Timeout=5 in the string, but it still waits 30 seconds before returning failure. How do I make it give up and return faster? I'm on a fast local network and don't want to wait 30 seconds. The servers that are not turned on take 30 seconds to fai...

Create Windows 7 Quick Launch

how to Create Windows 7 Quick Launch Icon With C# ? ...

Where is the Microsoft.VisualBasic.Logging temp path exactly

I am making a small change to an existing application so that users can email us the log file when things go wrong. Even though it is c# the app is using Microsoft.VisualBasic.Logging.FileLogTraceListener. This gets setup like this: FileLogTraceListener fileLogTraceListener = listener as FileLogTraceListener; fileLogTraceListener.Locat...

DataContractJsonSerializer changing my date

A user enters a date in a form, but when I pass a date through an AJAX json call, my date is getting changed by the DataContractJsonSerializer. Here's my AJAX call: function Save() { //Convert date to milliseconds from from 1/1/1970 - necessary for passing a date through JSON var d = "09/01/2010 05:00"; myDate = new Date(d)...

Why should I use nhibernate instead of entity framework 4

I'm trying to convince my client to use nhibernate instead of Entity Framework 4. My client have decided to use only Microsoft libraries (including Unity and Enterprise library 5). I don't agree with them (there are so much better logging frameworks/validation layers/ioc etc) but respect their decision. I've played with EF4 for a couple...

Why should Dispose() be non-virtual?

I'm new to C#, so apologies if this is an obvious question. In the MSDN Dispose example, the Dispose method they define is non-virtual. Why is that? It seems odd to me - I'd expect that a child class of an IDisposable that had its own non-managed resources would just override Dispose and call base.Dispose() at the bottom of their own ...

Breaking up a WCF RIA Services Project

I'm currently building an application that has two parts, the user front end and the administration backend. The front end is a ASP.NET MVC application and the backend is a silverlight application. I started the project by creating a silverlight business application called Administration and two projects got added, the silverlight app ...

Check reference parameter value or return bool?

Hi, I am using a method that has the following signature: public static bool TryAuthenticate(string userName, string password, string domainName, out AuthenticationFailure authenticationFailure) The method declares: bool authenticated = false; then goes on to authenticate the user. Whenever authenticated is set to true or fals...

How to inherit/extend styles from a resource dictionary?

I am having trouble extending one of my styles that I have defined in the Windows dictionary. Alone, it seems to apply the style to my controls as expected. However, if try to extend the style in one of my userControls, using the basedOn property, it simply overrides the main one and all the base styles dissapear. Here's an example: ...

Programming Word XML in .NET

I'm currently in a development team trying to come up with an app that will be able to accept an Open XML Word document, shred the XML and somehow come up with UI screens on the fly that could be used for data entry. I'm using the Open XML SDK but my challenge has been to come up with a very generic means of representing the document as...

NUnit global initialization - bad idea?

We need some global one time setup code in our test suite. We can do it more than once but it takes quite some time. It's required by all fixtures so [TestFixtureSetUp] does not work. It has to run before all [TestFixtureSetUp] code. Put it in Main() since we keep test assemblies as executables. However Main doesn't get executed under...

EF 4.0 - Load Navigation Property of Navigation Property

I am attempting to perform the LoadProperty operation from my context to load a navigation property of a navigation property. My setup is that I have an EntityA, which contains a list of EntityB's, and each EntityB contains a list of EntityC's. I am doing the following programatically: public virtual List<T> LoadProperty(List<T> entiti...

Remove version number from reference (avoiding "Could not load file or assembly..." error)?

In my class library, I am referencing DLL's from my website's bin folder. Sometimes the DLL's in the bin folders get updated, then I get the error of: Could not load file or assembly 'MyAssembly.Sub, Version=3.7.2096.3, Culture=neutral, PublicKeyToken=dfeaee3f6978ac79' or one of its dependencies. The located assembly's manifest de...

Access Database Alternatives.

Ok before I explain... I know Access should basically not be used anymore. My application now uses access for its portability.. its an internal application and makes private/internal database storage a snap. Problem is, it uses JET 4.0 which is not supported in 64 bit operating systems and is frankly not very well implemented anymore....

ASP.NET 4.0 IIS Registration

I have a web server running IIS 6 which has .NET 2,3.5, and 4 installed. Everytime I install a .NET 4.0 web appication the ASP IIS Registration tool is ran which is clearing out some important registry entries for EnableExtionlessUrls. We have reinstall the .NET 4.0 framework but are still having the same problem. Has anyone else expe...

Wix & T4 : no "Custom Tool" option

I want to generate a fragment using T4 but after adding a .tt file to the Wix project there is no "Custom Tool" option for this file. And there is no menu item "Run custom tool" when right clicking on the .tt file. Is there a hack for this ? I'm using VS 2010 and latest Wix 3.5 ...

Serialization: Change the name of the root node without changing the class name

Goal Take a class named "Item" and output its serialized XML as: <Template><!--some properties --></Template> Problem The root node is derived off the class name that is implementing IXmlSerializable. // By the time I get here 'writer' already has a root node public void WriteXml(XmlWriter writer) { writer.Wri...

Microsoft .NET compatibility

I used VS2010, and target for .Net 2.0 (VB.Net Windows Form application) http://stackoverflow.com/questions/2171980/how-to-decide-what-is-the-net-target I decided on 2.0 because I understood it will be OK if the users have higher version I tested my app on XP with .Net 2.0, works fine. I uninstalled .Net 2.0 [to see what error message...

Control object creation during deserialization

I would like to control object creation of a type that is not usually serializable during deserialization using a NetDataContractSerializer (or any serializer I guess). Using a custom SerializationBinder I can control the type that is constructed and using a custom ISurrogateSelector and ISerializationSurrogate to control how state is se...

How Do I Make Any Program's Window TopMost from my Program?

Hi. I am writing a glassing program, similar to Glass2k (see image below) as I often need to view my pdf tutorials while working on the program in question. I have so far been able to write the program that glasses the windows I want (via a global keyboard shortcut). I now need a way to replicate Glass2k's feature which makes glassed w...