.net

How do I List Month Names, e.g. for a combo?

At the moment I'm creating a DateTime for each month and formatting it to only include the month. Is there another or a better way to do this? ...

server.Databases[databaseName].Drop(); fails in MSTest

The following exception is thrown: Error Message: Microsoft.SqlServer.Management.Smo.FailedOperationException: Drop failed for Database '4d982a46-58cb-4ddb-8999-28bd5bb900c7'. ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Dat...

COM over USB with .NET to interface with 3rd party hardware

I have a project where I have to interact with two different devices that supply data via COM over USB. The client is telling me that this can be done easily with HyperTerminal but I am unfamiliar with it. I am coding with .NET 2.0 (but can use 3.5 if necessary). What would be the easiest/quickest way to obtain the data from these hardw...

powershell : how to query AD and exchange mailbox sizes

I just recently found out that exchange server2007 will no longer be supporting WMI, namely the service which uses \ROOT\MicrosoftExchangeV2. The old script I wrote output the ServerName, StorageGroupName, Storename, MailboxDisplayName, Size, TotalItems, DeletedMessageSizeExtended fields to a csv text file. How would I go about doing...

Scientific data visualization and the .NET framework

I have spent a long time searching for a product that would bring functionality similar to matplotlib to the .NET framework. From what I can tell, nothing really measures up. Is this an accurate assessment? Here is what I have found: Commercial: ChartFX Dundas KitWare's ActiViz (basically a managed version of VTK) Open Source: ...

Will a .NET EXE targeted to x86 run on AMD chips?

If I target the x86 platform for my .NET app, will it run properly on AMD chips? I know that it will work with Intel chips, and that Vista 64 has the ability to run x86 apps in a special mode, but I don't know how much of that is hardware and how much of that is the OS. I've tested it on Vista 64 with an Intel chip and it works perfect...

C# Technique - Getting Constant Values By String

Is there any good way to convert strings like "xlSum", "xlAverage", and "xlCount" into the value they have under Microsoft.Office.Interop.Excel.XlConsolidationFunction? I guess reflection would be slow (if its possible). There are about 10 of these constant values. I was trying to avoid a large switch statement if possible. ...

How do I prevent a WCF service from enter a faulted state?

I have a WCF Service that should not enter the faulted state. If there's an exception, it should be logged and the service should continue uninterrupted. The service has a one-way operation contract and is reading messages from an MSMQ. My problems are twofold: The service appears to be swallowing an exception/fault so I am unable to ...

Mocking for Dummies?

I'm new to mocking, I have a new .net web project that is in UI->BLL->DAL->DB structure, I use NUnit to do some testing currently. I intent to use it to test middle tier so I don't have to actually write to DB. Now, I've never done any mocking, don't quite know where to start, so I am looking for a mocking framework that has some end to...

WebBrowser document cast not valid

I've got a WebBrowser control on my page. To fire some javascript on a page displayed in the browser control, I call this.myBrowser.Document.InvokeScript("Test"); This works on my dev box with IE7, but on a seperate test machine I get the following error: Exception Type: System.InvalidCastException Message: Specified cast is not valid....

What is the best way to make the output of one stream the input to another

I'm wondering if there is a better/inbuilt way, other than using a byte buffer and looping, to read from one stream and write it to another (in .NET). Generally this is done to apply a transform to a stream and move it on. In this instance, what I am loading a file, putting it through a deflate stream and writing it out to a file (Error...

C# Best way to get folder depth for a given path?

I'm working on something that requires traversing through the file system and for any given path, I need to know how 'deep' I am in the folder structure. Here's what I'm currently using: int folderDepth = 0; string tmpPath = startPath; while (Directory.GetParent(tmpPath) != null) { folderDepth++; tmpPath = Di...

Pros and Cons of developing .Net Solutions in Vista instead of XP

i am changing my hardware which currently runs Win XP and i am wondering if i should also upgrade my OS to vista. so my question is, what are the most common issues/advantages you find while developing in VS2008 on Vista. with out taking into consideration WPF. should i keep XP where i have no Problems? or what version of vista best fit...

How to design code for testability

I have been looking at using TDD and implementing proper testing (only just started to learn how much better it makes your life) in any of my projects that I create in the future. So for the last couple of days I have been floating around on SO trying to learn about how to design your application for testability, but I still seem to be ...

How to Unit Test a missing .NET ConfigurationSection

If I have code like this: public XALServiceConfiguration CreateInstance() { var config = ConfigurationManager.GetSection(ConfigurationSectionName) as XALServiceConfiguration; if (config == null) throw new ConfigurationErrorsException("Configuration element 'xalService' was not foun...

Parsing a byte stream to a struct/class

I have a byte stream I need parsed into a struct, and I also need to be able to parse the struct back to a byte stream. Below is an example of what I want where I've used BitConverter to parse the values. I hope there is a more efficient way of doing this, because my structs are HUGE! ref struct TestStruct { int TestInt; float ...

How to reclaim image real estate in ListView?

Hi All, Env.: VS 2008, .NET 2.0, WinForms I have a listview in Tile mode. Some items have an associated image. Some don't. The contents (listview items) is often renewed when user clicks some controls. When this happens, it sometimes appears that none of the new items have images. In that case, I would like to get rid of the empty spa...

How can I launch the default media player from a .NET application?

I need to launch a media file from a URL from within my c# .NET application. Is there any way to do this natively in .NET? I don't need an embedded player, I just need the default player to launch. I have tried System.Diagnostics.Process.Start("File URL"); but it launches the default browser and downloads the file, instead of attempt...

Finding the last occurrence of a word

I have the following string: <SEM>electric</SEM> cu <SEM>hello</SEM> rent <SEM>is<I>love</I>, <PARTITION />mind I want to find the last "SEM" start tag before the "PARTITION" tag. not the SEM end tag but the start tag. The result should be: <SEM>is <Im>love</Im>, <PARTITION /> I have tried this regular expression: <SEM>[^<]*<PARTI...

How do I find the lockholder (reader) of my ReaderWriterLock in windbg

I've got a dump of a .Net process that has hung due to a deadlock (the gui thread is no longer responding, and my logs show that some threads have stopped responding). I have taken a snapshot and am now looking through it in windbg, and all threads bar one are waiting for the last one. Looking at that one thread's stacktrace with !clrsta...