.net

Does a List<T> guarantee that items will be returned in the order they were added?

Does a List<T> always guarantee that items will be returned in the order they were added when enumerated? Updated: Thanks for all the answers folks, puts my mind at ease. I had a quick poke around the List<T> class with .NET Reflector (should've probably done that in the first place) and indeed the underlying store is an array of T (T[]...

How can I create a Product Key for my C# App

How can I create a Product Key for my C# Application? I need to create a product (or license) key that I update annually. Additionally I need to create one for trial versions. Thanks! Related: How do I best obfuscate my C# product license verification code? Web-based license activation How do you protect your sof...

Exception line numbers are messed-up on CCNET build reports

We are having an integration server (CruiseControl.NET) building and validating a couple of .NET 3.5 libraries. When some integration code fails, the exception is logged and appears in a custom report. Yet, the line numbers reported by the exception messages are messed-up - usually short from 50 / 100 lines below the place where the exc...

DateTime as key in a SortedDictionary<K, V>

Can I safely use DateTime as a key in a SortedDictionary<K, V> without implementing my own IComparer? I've tried it and sort order is maintained and importantly for my purpose the .ContainsKey<T> method works as expected. But I just want to double check before committing myself down this road. Update: Thanks for clearing that up folks....

How to get the total allocated memory by an (ASP).NET app programatically ?

How can I check programmatically, how much memory my program currently has allocated ? I need it for an ASP .NET app, but i suspect the solution is general for all types of .NET applications. Ideally, the operation to get the currently allocated amount of memory, should be fast, since I will need to query it often. EDIT: Thanks for you...

[.NET] Using Thread.VolatileWrite() with array parameters

I want to use Thread.VolatileWrite() (or an equivalent function) to change the value of a T[] field, so that the updated value is immediately visible to all other threads. However, the method does not provide a generic version, and I'm not able to use the Object overload since it takes a ref parameter. Is there an alternative? Would Int...

Resolving extension methods/linq ambiguity

I'm writing an add-in for ReSharper 4. For this, I needed to reference several of ReSharper's assemblies. One of the assemblies (JetBrains.Platform.ReSharper.Util.dll) contains a System.Linq namespace, with a subset of extension methods already provided by System.Core. When I edit the code, it creates an ambiguity between those extensio...

Java's Virtual Machine and CLR

As a sort of follow up to the questions called "Differences between MSIL and Java bytecode?" what is the (major) differences or similarity in how the Java Virtual Machine works versus how the .NET Framwork Common Language Runtime (CLR) works? Also, is the .NET framework CLR a "virtual machine" or does it not have the attributes of a vir...

What is the best spell checking library for C#?

What's the best spell checking library for C# / .net? (This will be web-based, so the built in spell check for WPF won't work.) ...

What is the best way to publish c# app with PreLoaded Sql Server Express Database

I would like to distribute my C# application along with SQL Server Express 2005 and the apps corresponding database. When installed SQL Server Express 2005 needs to have my sample database automatically loaded with data, not just table structures, when it is installed. How can I accomplish this. Is there a way to do this with the Visu...

MDI form 'creep' (position change in MDI window)

I have a VB.NET MDI WinForms app. My users have been complaining about form creep (as they call it), this is where each time you open a specific form within the main MDI window it opens slightly below and to the right of the location it loaded previously - i.e. it starts in the top left of the window and works its way down to the bottom ...

Serial number (registration key) algorithm in .NET

There have been a few timely posts about IP security and the like, but none that I can find that specifically address an algorithm. In one of my current projects, we've decided to go the route of an offline registration key system. I imagine most of our eventual user base will be honest, so I don't think we have too much to worry about....

How can I prompt the user to reboot in a .net installation?

I have an easy one for the install ninjas. I'm using Visual Studio 2008 to write an installation and I'm a complete newbie when it comes to installations. I've created an installation and successfully written some custom actions using a C# assembly. One action sets a RunOnce registry value, and now I need to prompt the user to reboot whe...

C# whats best method of saving dynamically created controls

I am currently saving a .net ( c# ) usercontrol to the disk as a XML file by saving each property as an element in the xml document. The file is used for later recreation of the controls at runtime. I am wondering if it is possible or better to save the control as a binary file. There would be many controls so I guess it would have to ha...

Why do .NET developers offer 32-bit/64-bit versions of .NET assemblies?

Evey now and then I see both x86 and x64 versions of a .NET assembly. Consider the following web part for SharePoint. Why wouldn't the developer just offer a single version and have let the JIT compiler sort out the rest? When I see these kinds offering is it just that the developer decided to create a native image using a tool like ngen...

dcomcnfg functionality programmatically

I can find all sorts of stuff on how to program for DCOM, but practically nothing on how to set/check the security programmatically. I'm not trying to recreate dcomcnfg, but if I knew how to reproduce all the functionality of dcomcnfg in C# (preferred, or VB.net) then my goal is in site. I can't seem to be able to find any good resourc...

In C#, how do you reference types from one in-memory assembly inside another?

The example program below compiles two in-memory assemblies. The first compilation works fine. The second one fails because it needs access to a class from the first assembly and the type isn't available. Specifically: The ReferencedAssemblies member of the CompilerParameters class is a string collection and it is used to load the man...

"WCF Getting Started" MSDN Tutorial Problem

Solution to original problem (below) may have been discovered. I commented out <identity> ... </identity> tag in the app.config file for the client. But I'm not sure if this is going to cause other problems, if it does, could someone let me know? I've been following the Getting Started tutorial at MSDN for WCF. I'm using Visu...

System.Net.Mail and =?utf-8?B?XXXXX.... Headers

I'm trying to use the code below to send messages via System.Net.Mail and am sometimes getting subjects like '=?utf-8?B?W3AxM25dIEZpbGV...' (trimmed). This is the code that's called: MailMessage message = new MailMessage() { From = new MailAddress("[email protected]", "Service"), BodyEncoding = Encoding.UTF8, Body = body...

Performance of Arrays vs. Lists

Say you need to have a list/array of integers which you need iterate frequently, and I mean extremely often. The reasons may vary, but say it's in the heart of the inner most loop of a high volume processing. In general, one would opt for using Lists (List) due to their flexibility in size. On top of that, msdn documentation claims List...