.net

Register Hotkey

I have this function: RegisterGlobalHotKey(Keys.F6, MOD_SHIFT | MOD_CONTROL); which call an API to register a global shortcut key in the system. void RegisterGlobalHotKey(Keys hotkey, int modifiers) I created a small options form to set this keys to be variables not fixed values like this: RegisterGlobalHotKey(VARIABLE1, VARIABLE2 | VAR...

Should you request timeouts on locks in .NET?

In Release It!, Michael Nygard reasons that many catastrophic system failures are often caused by a chain of things going wrong. For example, two threads deadlock. There's now two less threads in the thread pool, so load increases on the other threads increasing their likelihood of deadlocks. Suddenly, the server does not respond at all,...

asp-mvc routing when hosted in IIS on development environment.

Hi, i have the application on environment in IIS 5.1 under "localhost/mvcapplication1" The routing configuration is something like: routes.MapRoute("mvc-default", "{controller}.mvc/{action}/{id}" , new { controller = "Home", action = "Index", id = (string)null }); routes.MapRoute("Root", "" , new { controller...

Down Arrows doesn't fire KeyPress Event

Does anyone know why the KeyPress Event doesn't get fired when the user presses a down arrow? I have to look for it in the KeyDown event. I was just wondering if this was something that I was doing wrong or not? ...

Unit Testing my Email Service

How do I write a unit test for a method that use an external service like System.Net.Mail? Do I just check a return value to see if there were any errors sending the email and assume if there were none that it was sent successfully? ...

Class Library of Constants--Best Practice?

...

Do I need to delete structures marshaled via Marshal.PtrToStructure in unmanaged code?

I have this C++ code: extern "C" __declspec(dllexport) VOID AllocateFoo(MY_DATA_STRUCTURE** foo) { *foo = new MY_DATA_STRUCTURE; //do stuff to foo } Then in C# I call the function thus: [DllImport("MyDll.dll")] static extern void AllocateFoo(out IntPtr pMyDataStruct); ... MyDataStructure GetMyDataStructure() { IntPtr p...

How do I get the first element from an IEnumerable<T> in .net?

I often want to grab the first element of an IEnumerable<T> in .net, and I haven't found a nice way to do it. The best I've come up with is: foreach(Elem e in enumerable) { // do something with e break; } Yuck! So, is there a nice way to do this? ...

.NET Remoting - How can the Server update the client?

Right now, I am in prototyping phase. So I am just getting started. Situation: Server - Will be run tests and publish progress to Client, must be low impact, no webserver, possibly running xp embedded or xp home. Client - Initiate tests and receive progress report. running xp pro. The two machines are connected via ethernet. I wou...

How do I find out whether a ResourceManager contains a key without calling ResourceManager.GetString() and catching the exception?

So I have a ResourceManager that points to a resource file with a bunch of strings in it. When I call GetString() with a key that doesn't exist in the file, I get a System.Resources.MissingManifestResourceException. I need to find out whether the Resource contains the specified key without using exception handling to control program flow...

What are the key differences between Visual Studio Team Systems profiling tools and tools like ANTS or dotTrace?

I'm trying to understand the key differences between the profiling tools built into Visual Studio Team System and those provided by third parties like Red-Gate and Jet Brains. Can anyone provide some links? I'm having a difficult time finding some good comparisons. ...

Reflection: walking a class for automated testing

I have classes that store data, and methods to go get data for individual loans. I have code that walks properties and pulls the data back, but according to the MSDN coding guidelines properties are just supposed to get data, not do anything. My properties actually move to a screen on a mainframe and scrape data. So when I am mousing ov...

Can I emulate MS Compute Cluster Server on my dev machine?

I have a project for a client that will consist of managing jobs on a MS Compute Cluster. I will be developing the application outside of their network, and would like a way to develop/debug my app without the need to be on their network. I am developing the app in C#, and all I have so far is the Microsoft Compute Cluster Pack SDK. ...

IronPython vs. C# for small-scale projects

I currently use Python for most of my programming projects (mainly rapid development of small programs and prototypes). I'd like to invest time in learning a language that gives me the flexibility to use various Microsoft tools and APIs whenever the opportunity arises. I'm trying to decide between IronPython and C#. Since Python is my fa...

.NET support for PKCS#11?

Does the System.Security.Cryptography.Pkcs namespace have support for PKCS#11? ...

Fact check: how vulnerable are .NET apps to decompilation?

I came across this post on the MSMobiles.com blog that says the following, among other things: .Net is great in so many ways but for commercial apps? No way! Anybody can just look at your source code. A high end obfuscator will help a lot but any determined hacker will fix your code in less than a day. I know this from sa...

How can I make an HtmlTextWriter object use spaces instead of tabs for its Indents?

I am creating some html from code running on a WinForm. I want to create the following html: <html> <body> <div> <p>foo</p> </div> </body> </html> I'm using the System.Web.UI.HtmlTextWriter class to do this like so: System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(); htmlWriter.WriteFullBegin...

override navigation of datagridview using enter key

How do you override the enter key in a datagridview so that it will set focus to the next column instead to the next row? ...

good open source project using Dependency Injection Framework?

does anyone know about an open source project Implementing Ninject Framework or another one, I haven't work with a DI framework before and Ninject calls my attention because you don't need to have your configuration in XML files. i tend to grasp a lot more when reviewing already implemented code. also if you know about another good p...

How to best clean up resources for .NET application?

What are the best way or method of best practise to ensure that a Winforms .NET application releases all the resources it consumed in the lifecycle of its execution? In particular, the release of file handles and images. Thanks. ...