.net

How do I set my mouse cursor to the hybrid hourglass and arrow in code? (.NET)

I have a timely operation that runs on a background thread. While running, I currently put the cursor in a wait state: Mouse.OverrideCursor = Cursors.Wait I just implemented a feature that allows the user to click a "Cancel" button if they're tired of waiting. However, some users may not realize they can do this (despite the cancel ...

Free NHibernate helper tools?

Are there any free tools to help simplify working with an NHibernate project in .NET 3.5? Primarily, I'm looking for some kind of code and config file generator to automate some of the more tedious parts of working with NHibernate. ...

Filewatcher created event

I am monitoring a folder with a .net filewatcher for certain kind of files(*.mbxml). I am using the created event of filewatcher for it. Once the created event fires I have to move this file to another folder. The problem with this approach is that the created event is fired as soon as the file copying starts. So if the file is taking to...

Simulating connection problems for .NET HttpWebRequest

Are there ways to programmatically simulate connection problems (slow connection, response does not complete, connection gets dropped, etc.) when using the HttpWebRequest class? Thanks EDIT: To elaborate more, I need this for debugging but would want to turn it into a test eventually. I'm using the async methods BeginGetRequestStream, ...

RIA Server Architecture .NET

I'm using WebORB as a remote gateway for Flex projects. I was wondering what would be the best architecture to use on the Server .NET side. At this moment we are using SubSonic to generate a Data Access Layer. Besides that each call from Flex uses a little bit a transaction script pattern because the server side really only acts as a way...

How do I disable the WPF WebBrowser control's click noise?

I've got a simple little WPF app with a TextBox and a WebBrowser control. As I type into the TextBox the WebBrowser updates with its content. But on each keystroke, when the WebBrowser updates, it makes a click sound. How can I disable the WebBrowser control's refresh click sound? My XAML... <TextBox Name="MyTextBox" ... ...

Keep window on top and steal focus in WinForms

I realize that this would be COMPLETELY bad practice in normal situations, but this is just for a test app that needs to be taking input from a bar code scanner (emulating a keyboard). The problem is that I need to start up some scripts while scanning, so I need to window to regain focus directly after I click the script to run it. I'v...

Enumerating all strings in resx

We would like to enumerate all strings in a resource file in .NET (resx file). We want this to generate a javascript object containing all these key-value pairs. We do this now for satellite assemblies with code like this (this is VB.NET, but any example code is fine): Dim rm As ResourceManager rm = New ResourceManager([resource name], ...

How do you override ToString in a static class?

Howdy, I have a public static class in which I would like to have a ToString() method. I have defined it as public static string ToString(), but get the following warning: 'Class.ToString()' hides inherited member 'object.ToString()'. To make the current member override that implementation, add the override keyword. Otherwi...

VS2008 XAML design view chokes on namespaced C++ assembly

I have a C++ assembly with both managed and umanaged code compiled to a DLL. It is correctly imported into the project references as I can see all my classes and their members with the Object Browser. The problem is with the XAML Design view. In my XAML code I want to make a data bind with my C++ assembly so I have the namespace like s...

Incorrect syntax near @[parameter name] when using parameterised Alter Database command

I'm trying to drop a SQL Server database using the following code: SqlCommand command = new SqlCommand("USE MASTER; ALTER DATABASE @database SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE @Database", connection); command.Parameters.AddWithValue("@database", TestingEnvironment.DatabaseName); command.ExecuteNonQuery(); When I ex...

Perform a modulus in a huge number?

I need to do a modulus operation on very large integers. The biggest integer supported by my platform (edit: .NET 2.0) is a 64 bit integer, which aren't big enough for the numbers I'm working with. How can I do a modulus on really big integers, like 12654875632126424875387321657498462167853687516876876? I have a solution that treats t...

Throwing multiple exceptions in .Net/C#

In an application I work on, any business logic error causes an exception to be thrown, and the calling code handles the exception. This pattern is used throughout the application and works well. I have a situation where I will be attempting to execute a number of business tasks from inside the business layer. The requirement for th...

Reading the MSMQ transcational dead letter queue

I'm trying to read the transactional deal letter queue in MSMQ using C#.NET and am getting "A workgroup installation computer does not support the operation" For 10 Stack Overflow points, what am I doing wrong? ...

Why won't my Website Project adapt to .NET 3.5?

We've converted our solution from .NET 2.0 to .NET 3.5. All projects converted just fine except for the Website Project, which still doesn't understand what I mean when using 'var' and the like. I've looked in the property pages for the web project, and the Target Framework is set to '.NET Framework 3.5'. Any other ideas? ...

Dot Net and Java Culture Codes

I've been tasked with the awesome job of generating a look-up table for our application culture information. The columns I need to generate data for are: Dot Net Code Version Culture Name Country Name Language Name Java Country Code Java Language Code Iso Country Code Iso Language Code I have found the globalization name space, but ...

How do I create an expression tree to represent 'String.Contains("term")' in C#?

I am just getting started with expression trees so I hope this makes sense. I am trying to create an expression tree to represent: t => t.SomeProperty.Contains("stringValue"); So far I have got: private static Expression.Lambda<Func<string, bool>> GetContainsExpression<T>(string propertyName, string propertyValue) { v...

Does the List Clear() method destroy children [C#.NET]?

If I create a recursive list of of lists: class myList { List<myList> childLists; List<string> things; //... } List<myList> tempList = new List<myList>(); And then later call tempList.Clear(), will it destroy all the childLists in memory, or should I create a recursive method to clear all the childLists first? ...

Is there a .NET Framework method for converting file URIs to paths with drive letters?

I was looking for something like Server.MapPath in the ASP.NET realm to convert the output of Assembly.GetExecutingAssembly().CodeBase into a file path with drive letter. The following code works for the test cases I've tried: private static string ConvertUriToPath(string fileName) { fileName = fileName.Replace("file:///", ""); ...

How to detect a truncated file in C#

If I'm reading a text file in shared access mode and another process truncates it, what is the easiest way to detect that? (I'm excluding the obvious choice of refreshing a FileInfo object periodically to check its size) Is there some convenient way to capture an event? (Filewatcher?) ...