.net

C#: Populating a UI using separate threads.

I'm trying to make some sense out of an application Ive been handed in order to track down the source of an error. Theres a bit of code (simplified here) which creates four threads which in turn populate list views on the main form. Each method gets data from the database and retrieves graphics from a resource dll in order to directly po...

Best source control system for maintaining different versions

Hi all! We need to be able to simultanously maintain a set of different versions of our system. I assume this is best done using branching. We currently use TFS2008 for source control, work items and automatic builds. What is the best version control solution for this task? Our organization is in the process of merging to TFS2010. Wil...

When is ReleaseController method called?

I'm implementing a custom ASP.NET MVC controller factory. I wonder when the ReleaseController method is called? Is it the same time as EndRequest? ...

.NET 4.0 Fails When sending emails with attachments larger than 3MB

I recently had an issue after upgrading my .net framework to 4.0 from 3.5: System.Net.Mail.SmtpException: Failure sending mail. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Net.Base64Stream.EncodeBytes(Byte[] buffer, Int32 offset, Int32 count, Boolean dontDeferFinalBytes, Boolean shouldAp...

Regex with all optional parts but at least one required

I need to write a regex that matches strings like "abc", "ab", "ac", "bc", "a", "b", "c". Order is important and it shouldn't match multiple appearances of the same part. a?b?c? almost does the trick. Except it matches empty strings too. Is there any way to prevent it from matching empty strings or maybe a different way to write a regex...

How do I use a DataGrid to display the contents of a MDB

I'm relatively new to .Net 4 and I am creating my FIRST WPF application using a MDB as a backend datasource. I designed my UI. I have a TextField (called Name), a Combobox (called Division) and a DataGrid (called dataGrid1). The only problem I'm having is figuring out how to link my DataGrid to display data from the DataSource. and loa...

How to setup SqlDependency to monitor multiple tables

I am trying to figure out how to monitor more than one table with a SqlDependency. All the examples I have found are for one table. I have multiple classes that represent a monitor for a specific table. Each time a change event is raised I stop the dependency and start a new one but that unhooks the other monitors. How do I get it to...

Application disappears in the background

Hi, in my application there is a print form. When you click the print button, the windows print dialog appears, showing the printed page. When it's finished the print form is closed (this is still ok) but my application is set to the background on the z-order (this is not ok) and another application window is set to the foreground. I c...

Unable to catch exception from Activator.CreateInstance.

OK, I admit it this code will just look weird to you, and that's because it is weird. This is just code to reproduce the behavior, not code I want to use. class Program { static void Main(string[] args) { try { Activator.CreateInstance(typeof(Func<int>), new object[] { new object(), IntPtr.Zero }); ...

What is the .NET attribute to not compile a method is release mode

I know that if I have a block of code I don't want compiled when in release mode I can wrap that code block in: #if DEBUG while(true) { Console.WriteLine("StackOverflow rules"); } #endif This will keep this code block from compiling in any mode other than DEBUG. I know there is an attribute that can be placed on an entire method t...

Could not load type 'System.Web.Mvc.ViewUserControl<SOMETYPE>'.

I'm trying to deploy ASP.NET MVC 2 project (VS2010) to Win Server 2008 R2 It works perfectly on dev machine. But strange error occurs at Server 2008 R2: When .ascx file has header that uses generic type: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyProj.Web.Models.RangeViewModel>" %> Server reports Could not ...

Does the .Net Framework 4.0 Installer include the .Net Framework 3.5

Do .Net components that were compiled against the .Net Framework 3.5 run on a system that has only .Net Framework 4.0 installed? Or in other words does the .Net Framwork 4.0 Installer include the .Net Framework 3.5? ...

purchasing source code from third party vendor

Hi Our company uses some third party vendors to write some of our external facing web sites, however with one vendor we keep experiencing over inflated charges for simple changes and it has been decided to bring the product in-house. I have been tasked to provide a list of deliverables/checkpoints that would form a part of the agreeme...

Decrement all int values in Dictionary

I have a Dictionary<string,int> and I simply want to decrement the value in my dictionary by one. I have this but not sure if its best practice. foreach (KeyValuePair<string, int> i in EPCs) { EPCs[i.Key] = i.Value - 1; } UPDATE: The reason I am trying to decrement the value is becase the value is a index number relating to a posi...

Third party class not loading in 'using'. Where are additional classes installed?

I have a third party library installed, but the accompanying namespace isn't found. The type or namespace name 'Maverick' could not be found (are you missing a using directive or an assembly reference?) Fair enough, VS 2010 can't find it. But where does my system look for third party libraries? Can I modify the list of locations? ...

.NET Windows Forms - intercepting the Close X event.

This must be a dumb question, but I cannot figure it out. I also cannot use the designer because coders before me managed to throw GUI and logic all in one, so now it is confused. I've got to do it the old school way. I have a Form which can be closed in 3 ways: Close button, File / Close menu, and the X icon. I want them all to do the ...

.NET API for HID (USB)?

Is there an API in .NET (C#) for using USB HID (Human Interface) devices? ...

ObjectDisposedException from core .NET code

I'm having this issue with a live app. (Unfortunately this is post-mortem debugging - I only have this stack trace. I've never seen this personally, nor am I able to reproduce). I get this Exception: message=Cannot access a disposed object. Object name: 'Button'. exceptionMessage=Cannot access a disposed object. Object name: 'Button'....

memcached - what is a good method to cache common queries, but also handle invalidation?

I understand the need for a function like DB_Get_Cached("sql string") that hashes the SQL in order to perform a lookup in memcached for the existence of the data. function DB_Get_Cached(string SQL) data = memcache_get_data(md5(SQL)) if (!data) return DB_Get(SQL) end if end function What is a good method to expand this to handle ...

How to load the App.config file?

Hi, I'm parsing the App.config file of a project. This config file has been loaded from a caller project. Inside the called project, I have something like: XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("app.config"); // Some parsing... Unfortunately the app.config file is not correctly located. Apparently the Load meth...