.net

How to pass data between threads?

What are ways to pass data between threads in .NET? There are two things I can currently think of: Membervariables, e.g. using the producer-consumer-queue pattern. Using the ParameterizedThreadStart delegate when starting the the thread. (Only works once, not good for long running background worker threads). What facitlites does the...

Which exception should be thrown for an invalid file name?

I have a method which accepts a filename as a parameter, all filenames should end with '.csv'. Which exception should I throw if a filename that does not end with .csv is passed? Or should I take a different approach? ...

Avoid "program stopped working" in C#/.NET

I have a console application written in C#/.NET that I want to run from a script (nant). If an exception occurs in the console application, I would like nant to continue, but in Windows Vista there is a popup that searches for solutions and asks for debug etc. I would like to avoid the popup with "program stopped working" when an except...

Iterator Variable Naming Convention in .NET

In a standard foreach loop, is there a generally accepted naming convention for the iterator variable? Typically, I use currXXX where XXX is basically the name of what I'm iterating through. I haven't seen others follow this convention, it's just something I've been doing as long as I can remember. I do see value in having a name simila...

Graph Viewer option available in WPF UI??

Hi, In a WPF UI app, is there any control to display graph? I mean, i have 2 combo boxes, on selecting the values in it, it generates a graph.( I have done this using crystal report viewer in a normal windows app... ). How to achevie this in WPF?? As a is available for documents, do WPF has any graph or reports viewer in it. I am no...

Metadata file '.dll' could not be found

Hey there, I am working on a WPF, C#3.0 Project and I am getting this error: Error 1 Metadata file 'WORK=-\Tools\VersionManagementSystem\BusinessLogicLayer\bin\Debug\BusinessLogicLayer.dll' could not be found C:-=WORK=-\Tools\VersionManagementSystem\VersionManagementSystem\CSC VersionManagementSystem EDIT: This is how I ref...

Best Practices in Design of Billing / Invoice Software in .NET

I am currently working on a project where I have to design / implement the billing/invoicing system for our companies new project. We will be generating the invoices once a month as pdf files and sending out a link to the file to the customer. The framework in use will be .Net 3.5 / C#. As I do not have a lot of experience doing thi...

Prevent many different MVC URLs from filling ASP.NET Cache

Our website uses ASP.NET MVC for a part of the pages in it. These URLs typically have the form http://oursite/detail.mvc/12345/pictures/ In this URL, the 12345 is an ID in the database. We have several hundred thousands objects for which we show detail pages. Recently we noticed a rise in the memory use for the site, so I investigated a ...

DataTable Select vs LINQ Select

Any advice on when DataTable.Select should be used versus LINQ Select when dealing with an in-memory DataTable? I find LINQ syntax easier and more powerful, but I'm not sure if there are performance or other issues which make a DataTable select preferable. (I'm using a third party API that provides a DataTable that has been pre-populat...

How to mark C# event handler as "handled"?

Say I've got a button on a form that I want to disable if some condition is met. Is there a way to check for this condition inside the button's "IsEnabled" event handler and modify the enabled state such that setting the enabled state a second time does not trigger another call to the IsEnabled event handler? Let me demonstrate: privat...

how would you design a "state/management" that would do this

I have a list of nullable integer and it look like a 1 to many relation id1 can have an id2 and id3 id2 can have id4 if the value of id1 change, id2 and id3 must be set to null and it mean id4 must be set to null In that example, I only use 4 variables so that easy to manage. I got, for now, at least 15 variables to manage. The w...

Ignoring an optional suffix with a greedy regex

I'm performing regex matching in .NET against strings that look like this: 1;#Lists/General Discussion/Waffles Win 2;#Lists/General Discussion/Waffles Win/2_.000 3;#Lists/General Discussion/Waffles Win/3_.000 I need to match the URL portion without the numbers at the end, so that I get this: Lists/General Discussion/Waffles Win T...

Is it possible for an unmanaged C++ app to only load the CLR when it needs managed types?

More to the point, I have a native C++ application, that may never need to use managed types. I would like the CLR to remain unloaded until I the codepath that actually depends on managed types is actually hit. I was trying to accomplish this using the /clr switch in Visual Studio 2005, but as far as I can tell as soon as I use that swi...

Summary Detail Control?

Hi, Typical master - detail scenario e.g Order has many order lines One form requests the user for an order number which then opens another form to display the order lines for that particular order. I'd like to have a summary of order lines whereby when one is selected all the details are displayed for that order line below. I have l...

VNC server component for .NET

I'm looking for a way to listen on a specific port as a VNC server, then be able to send whatever I want to the connected VNC client. There's a lot of VNC client components, but I've not yet found a .net VNC server component. I intend to use this to allow a client to connect directly to my windows form (and only the form, so they don'...

C# accelerator keys not working

I am working on an application that has multiple dockable panels like Visual Studio. At some point the accelerator keys for the menu stopped working. They sometimes work depending on what panel is currently active. When they are not working pressing the alt key sets the focus to the menu bar and shows the underscores under the appropriat...

How a LocalSystem Service can run an application as a user [C#]?

On my local machine I am running an administrative c# service as LocalSystem called Serv.exe which performs various tasks. One of the tasks it needs to perform is to launch an application under the USER account (currently logged on), not as admin - as this violates security. The obvious solution would be simple impersonation when launch...

Running graphics display on multiple systems, keeping synched.

I have a series of systems on a LAN running a synchronized display routine. For example, think of a chorus line. The program they ran is fixed. I have each "client" download the entire routine, and then contact the central "server" at fixed points in the routine for synchronization. The routine itself is mundane with, perhaps, 20 pos...

Deploying files to remote machines

I need to deploy a set of configuration files to a hundred or more Windows hosts. I have the IP addresses, the user name and password, and the location on the remote machines into which the files should be copied - and was wondering if there was anything in the .NET framework that would let me utilise all that info to move these files?...

WebBrowser access to binary content

I am trying to access the binary data of PDFs in my C# .NET 2.0 project. I have a URL that points directly to the PDF, but I connot access the content through DocumentStream (which is null) . I can't use an HttpWebRequest to get the PDF from this URL, because the server that the PDF is hosted on requires script-based authentication, whic...