.net

Should I support .NET 2.0?

I am currently working on an open source project, and I had originally written my code against the .NET 3.5 Framework. I am using a small amount of Linq, but nothing significant at this point in time. I do not see much need for any of the more advanced features for my project (at this time) A user has asked for .NET 2.0 support, and it ...

LINQ: Dynamic .Where() Statements

Hi, Scenario: I have a list and three search filters. Something like: ResultList = OriginalList.Where(filter1).Where(filter2).Where(filter3); Question: Can I update filter 3, and then have the ResultList update, without having LINQ running filter1 and filter2? (I want to improve performance) Basically, it would be the same as: Re...

Am I misunderstanding LINQ to SQL .AsEnumerable()?

Consider this code: var query = (from a in db.Table where a = SomeCondition select a.SomeNumber).AsEnumerable(); int recordCount = query.Count(); int totalSomeNumber = query.Sum(); decimal average = query.Average(); Assume "query" takes a very long time to run. I need to get the record count, total SomeNumbe...

Hash of .NET assembly and type

In my application I need to compute a hash of a given .NET assembly and of a given type. Assemblies and types to hash are loaded dynamically in this scenario. Object's built-in method GetHashCode returns different value each time an application is started. How to compute a deterministic hash function of an assembly or a type? Any a...

How do you make a Generic Generic Factory?

I am working on a client (Silverlight) interface to a collection of webmethod. And I am trying to avoid writing any custom code for every webmethod. So I have created a ServiceCall<TResult> to handle each call, TResult specifies the return type of the service (I use XmlSerializer to create the returned instance). The client class exposes...

List, SortedList, Dictionary to store objects by key and serialize them?

My requirements: I need to store a collection of objects inside a class, objects must be accessible by their key (which will be unique string), search/remove/replace must work like this MyClass somethingNew = new MyClass(); // set someproperties on somethingNew somethingNew.Id = "FooBar"; // theOtherObject already contains an ...

Keep a ToolStripDropDownButton dropped down for multiple selections

I have a ToolStripDropDownButton that has multiple children and I'm using them as checkboxes (CheckOnClick=True) so you can check multiple child items. My question is: how do I keep the parent item "dropped down" so it doesn't close up every time you click a child item? ...

Making Console Application like Windows Application

I have a console application and I want it to wait till some event is raised. But it executes the code and exits: static void Main(string[] args) { var someObjectInstance = new SomeObject(); someObjectInstance.SomeEvent += SomeEventHandler; } static void SomeEventHandler() { //some logic } I want to make my application behave l...

Build checksum of array of long values

I have an array of long values in my c# program. Now I need a checksum (the smaller the better) to see if all values are incuded in an other array I want to compare with. It should be an easy checksum so I can use it with JavaScript/JQuery too. Is there a method/code snippet I can use? Background: I have a javascript ajax mvc project ...

.NET runtime vs. Java Hotspot: Is .NET one generation behind?

According to the information I could gather on .NET and Java execution environment, the current state of affairs is follows: Modern Java VM are capable of performing continuous recompilation, which combined with profiling can yield great performance improvements. Older JVMs employed JIT. More information in this article: http://www.i...

Custom Listview Column Sort Image to Right

I support a .Net 2.0 Windows application that has a custom listview control to allow for greater flexibility. I am not allowed to bring this to a newer version of the gramework until next year. We are moving from XP to Windows 7, and we have identified an issue with how the column sort image (up/down arrow) is drawn to the listview. C...

Two similar classes, which should do the work?

I've 2 classes. One is a linq-to-sql class and the other is a seriazable data-dump class. Examples: Class TableNotes Id UserId NoteText ... functionality [Serializable] Class NoteDump NoteText ... functionality They both would share a common set of functionality. I decide it is best for me not to duplicate this functionality and th...

Implementing version-control functionality

Are there any recommended approaches for implementing version control functionality accessible to end users of a business application? The goal is to create a robust version control system for an application where users modify business objects (rather than text). I'm not looking for recommendations on version control software for devel...

ZGC.Refresh() Efficiency BottleNeck?

I have a process that refreshes a 1000 line graph while a TrackBar scrolls. I've done some StopWatching and found that ZGC.Refresh() accounts for 90% of the process run time. The ability to see the graph progress as the TrackBar scrolls is essential to the program. Is there any way to optimize the efficiency of ZGC.Refresh() so my p...

Windows WorkFlow Version 4 and Visual Studio 2008

Can i develop Windows WorkFlow Version 4 applications using Visual Studio 2008? ...

Using MEF and XAML together

MEF is a great framework. I can just put a dll into given directory and when host composition goes the DLL code will run. The question is if it is possible to create objects and use interfaces from XAML description, not from DLLs, in the case? ...

simple http server

I have a server client application. The clients sends the server http posts with info every second or so. The server is implemented using C#, there server doesn't need to respond in any way to the client. Whats the easiest and most practical way to get this done? Is there some kind of library that is easy to use that I can import into ...

Calling a C++ .dll from C# throws a runtime error ...

Hi all, The following line is generating a runtime error in a C# GUI: int x = myclass.number_from_dll(); I'm using Microsoft Visual Studio 2008. The code in C# is: class myclass { [DllImport("strat_gr_dll.dll", EntryPoint = "number_from_dll")] public static extern int number_from_dll(); } The code in the C++ .dll is: // This...

Arraylist to list<t>?

How can I convert/dump an arraylist into a list? I'm using arraylist because I'm using the ASP.NET profiles feature and it looked like a pain to store List in profiles. Note: The other option would be to wrap the List into an own class and do away with ArrayList. http://www.ipreferjim.com/site/2009/04/storing-generics-in-asp-net-profi...

MouseLeave event fires when moving over control's ScrollBar

I am reposting this question due to inability to solve the problem (original here). In the TreeView, ListBox, or it seems from my google searches anything with a ScrollBar, the ScrollBar is not considered a part of the control. I have a TreeView that I'm putting into a custom control, and it's Dock Fill. So there it acts as a custom Tr...