.net

Preventing GUI update event floods in .NET

I'm creating a system that takes readings from a hardware device that sends data via a serial port. Every time a "packet" comes in off the serial port, I update and redraw some GUI components to reflect the updated information. Since serial port events stem from a separate thread, I have to call Invoke(Invalidate) on several components t...

Quick and easy way to remove "dead" (commented out) code

I'm working with an inherited code base which contains thousands of lines of commented out code. I know the previous coder meant to save all his hard work for posterity rather than simply deleting it but: I will never read it and it just gets in the way. One problem example is that when I perform text searches for certain code segments I...

How to run a .NET program, automatically, every hour

Hi I have xml data I access through a web service. I need to read the data and copy it locally. The below code works fine. I need now to run this code at least twice or three times a day wihout manual intervention. How do I do that? Thanks! using System; using System.Collections; using System.Data; using System.Xml; class MainClass...

Generics vs boxing

Hey, I have one quick question... by using generics, do I completely get rid of boxing/unboxing operations? For example, by using a List do I still get lots of boxing/unboxing? I've read several docs on the internet but couldn't solve this specific question... Thnaks in advance. ...

What exception clas to use in when IEnumerable contains null

I have seen the following exception case several times public SomeClass(IEnumerable<T> someValues) { if (null == someValues) { throw new ArgumentNullException("someValues"); } int counter = 0; foreach (T value in someValues) { if (null == value) ...

How can you get a DLL to be deleted when its owner process exits?

I have a .NET assembly DLL that is created on-the-fly from pre-compiled code in a database. Is there a way to create the DLL file, put data into it, load it with the Assembly class, then when the process exits, have that DLL be deleted? My first thoughts were to open it with the FILE_SHARE_DELETE flag, load it with Assembly.LoadFrom, an...

Unable to Affect Scintilla Control Programmatically at Runtime

I'm attempting to use the ScintillaNET control in an application I am working on. I drag and drop the control into my form and run form. The control appears on the form. This is good. In addition, if I set any of the properties in the control's properties editor (ConfigurationManager.Language, for example), I am able to type in that l...

Help with saving or adding more than 4000 words to a List<T> in .NET

I need help with my application where i save a bunch of words like more than 4000 words or more in a List<[class name]>. My problem is, as the number of words increases, the process in saving it in the list seems to go slower and the application uses a lot more of memory. Can you give me an advise or alternative to do this without affe...

Testing a Gui-heavy WPF application.

We (my colleagues) have a messy 12 y.o. mature app that is GUI-based, and the current plan is to add new dialogs & other GUI in WPF, as well as replace some of the older dialogs in WPF as well. At the same time we wish to be able to test that Monster - GUI automation in a maintainable way. Some challenges: The application is massive. I...

How do you extract a specific element out of an XDocument?

I have the following XDocument: <SomeDoc Id="73" Protocol="rahrah" xmlns="http://schemas.company.com/rah/rah2/2005/"&gt; <Prop1>11111</Prop1> <Prop2>77777</Prop2> <Prop3>88888</Prop3> </SomeDoc> And I want to extract the value in Prop1. I use the following code: var prop1 = xml.Element("Prop1"); But prop1 is being set to ...

Online .NET IDE?

Does anyone know of a (free?) web-based IDE for .NET development online? ...

Language Interoperability in .NET (CLR) and Mono

Let's say I need to use Python and C++. I can call Python function from C++ with Python C API, and reverse is possible with SWIG or equivalent. How about .NET? I know there are IronPython and C# that finally produces .NET assembly. Is there any well-defined language interoperability mechanism in .NET so that one can use whatever functi...

NHibernate generate mappings from classes?

Is there a way to generate mappings for NHibernate from POCO? This reply to my question makes NHibernate look very interesting. However i have a lot of classes that look like this public class register_email_job { public PK id; public user_data user; } public class user_comment : BaseComment2 { [IsNullable] public user_...

MVC2, .NET4/C#4 optional parameters and Controller constructors

I am a big fan of optional parameters in C#4 but am having an issue with MVC when I use them in my controller constructors. For example, if I have a single constructor: public TestController(sting a = "") { /* blah */ } MVC has a fit saying that there are no parameterless constructors for TestController. How can I get around this? ...

Is it possible to pass an instance "pointer" to another process through a memory mapped file?

I'm basically searching for a way to pass instances across programs/processes without serializing the instances, in .NET 4.0. Yes, I'm missing my good ol' 100% unsafe pointers ;) I thought the new integration of Memory-mapped files to .NET 4.0 would help me, having read somewhere that you could pass references/pointers "natively" using...

Root web.config used instead of site web.config

I had a situation on a dev server where all the ASP.Net applications we have started to fail at the same time. After some investigation we found that calls the app settings, in 1.1 apps, and the connection strings collection in 2.0 apps all failed. The config files had the values, but the code was returning null. After some head scratc...

Is there a "max" number of assemblies for a .net app

Quite a few apps support plugins Are there any downsides to having a large # of plugins ? Is there a sweet spot beyond which there's a performance degradation perhaps ? What's the largest # of assemblies you've seen loaded in an app ? ...

safely lock a file then move? windows

I have a file and need to ensure it exist before inserting a row into the db. After i insert i need to use the PK as part of the filename and move it into another location. How do i check if it exist then lock it so it cant be deleted until i can insert into the db then proceed to move the file without it being deleted upon releasing th...

Merits of .NET ORM data access methods Enity Framework vs. NHibernate vs. Subsonic vs. ADO.NET Datasets

I have recently heard "fanboys" of different .NET ORM methodologies express strong, if not outlandish oppinions of other ORM methodologies. And frankly feel a bit in the dark. Could you please explain the key merits of each of these .NET ORM solutions? Entity Framework NHibernate Subsonic ADO.NET Datasets I have a good understandi...

Problem implementing Interceptor pattern

I'm attempting to develop an Interceptor framework (in C#) where I can simply implement some interfaces, and through the use of some static initialization, register all my Interceptors with a common Dispatcher to be invoked at a later time. The problem lies in the fact that my Interceptor implementations are never actually referenced by...