.net

Why do C# containers and GUI classes use int and not uint for size related members ?

I usually program in C++, but for school i have to do a project in C#. So i went ahead and coded like i was used to in C++, but was surprised when the compiler complained about code like the following: const uint size = 10; ArrayList myarray = new ArrayList(size); //Arg 1: cannot convert from 'uint' to 'int Ok they ex...

Fluent NHibernate SqlDateTime overflow exception

Hey, I'm mapping a very simple Users table, and i have a column named 'LastLoginDate' which is defined as nullable in sql server. My mapping looks like this : public Users { Id(x => x.UserId); Map(x => x.UserName); ... ... Map(x => x.LastLoginDate).Nullable(); } But everytime I try to save this entity programatic...

Overriding LINQ extension methods

Is there a way to override extension methods (provide a better implementation), without explicitly having to cast to them? I'm implementing a data type that is able to handle certain operations more efficiently than the default extension methods, but I'd like to keep the generality of IEnumerable. That way any IEnumerable can be passed, ...

How to best implement IPropertyChanged on Timespan subtype?

in .NET (and WPF), I need to monitor changes on a Timespan object which doesn't include any change event like PropertyChanged. What would be the best way to add this functionnality? ...

Using MyGeneration, doodads, and Oracle XE, is it possible to implement an "auto number primary key" scheme?

Hello world. Using MyGeneration, doodads, and Oracle XE, is it possible to implement an "auto number primary key" scheme? Problem facts: I am using Oracle XE. I have implemented the following table and trigger: CREATE TABLE "USERS" ( "ID" NUMBER(38,0), "USER_NAME" VARCHAR2(50), "PASSWORD" VARCHAR2(50), "EMAI...

Can a Backgroundworker proceed working when it reaches the "...Completed" event handler

Hi, as described in the title. My backgroundworker is doing its job...finishes the first part and calls the ...Completed event handler. Can I tell here my backgroundworker to proceed with another job by doing DoWork -= OldJob DoWork += NewJob also DoWorkCompleted -= OldJobCompleted DoWorkCompleted += NewJobCompleted Is this possible...

Why is my namespace not recognized in Visual Studio / xaml

Hello, these are my 2 classes a Attachable Property SelectedItems: code is from here: http://stackoverflow.com/questions/1297643/sync-selecteditems-in-a-muliselect-listbox-with-a-collection-in-viewmodel The namespace TBM.Helper is for sure proper as it works for other classes too. The namespace reference is also in the xaml file AND ...

Adding different context menu for datagrid's header

Hi, I want to add a different context menu for my datagrid's header on WPF. How can I do that? ...

Arraylist uses Array?

Does an ArrayList internally use an Array? Is this an empty array if we use the default constructor (new ArrayList())? Thanks. ...

WPF: change DataTemples according to Value

I have a class called Cell with two properties. One is called Value of type int? And the other is called Candidates of type ObservableCollection<ObservableCollection<Candidate>> during the initialization I am utilizing a DataTemplateSelector to choose between two datatemplates for two different scenarios. If the Value property has a va...

memory usage in C# (.NET) app is very high, until I call System.GC.Collect()

I've written an app that spins a few threads each of which read several MB of memory. Each thread then connects to the Internet and uploads the data. this occurs thousands of times and each upload takes some time I'm seeing a situation where (verified with windbg/sos and !dumpheap) that the Byte[] are not getting collected automatical...

How to create an array of buttons in C++

Hi, I'm using C++ in VS2005 and have an 8x8 grid of buttons on a form. I want to have these buttons in an array, so when I click on any of them it will open the same event handler (I think that is what they are called), but I will know the index of which one was clicked on. I know how to do this in VB and C#, but I can't seem to figure i...

Singular method name for single object argument, plural for a list?

I'm having a problem with naming a method for a database application. In my Database instance, I have a method that can remove an Agreement object from the database. However, I want to be able to remove multiple Agreements at once, to be able to use transactions. The problem is that I also have an overload to remove a single Agreement o...

Monitoring all events in a class and sub-classes

Hi, I wonder if someone can help me. I've got a console App which I use to debug various components as I develop them. I'd like to be able to log to the console every time an event is fired either in the object I've instantiated or in anything it's instantiated [ad infinitum]. I wouldn't see some of these events normally due to them be...

Test MVC using moq

I am new to moq and I was trying to test a controller (MVC) behaviour that when the view raises a certain event, controller calls a certain function on model, here are the classes - public class Model { public void CalculateAverage() { ... } ... } public class View { public event EventHandler CalculateAvera...

More efficient way to find media item in WMP media library?

Hello, all. I am messing around with the WMPLib component provided by Windows Media Player 12 (wmp.dll) in VB.NET with .NET Framework 3.5 SP1. I am trying to retrieve a media item from my media library based on its name (assuming there are no duplicate names). At the moment, I'm grabbing the entire media library, and looping through ev...

How to handle all unhandled exceptions when using Task Parallel Library?

I'm using the TPL (Task Parallel Library) in .NET 4.0. I want to be able to centralize the handling logic of all unhandled exceptions by using the Thread.GetDomain().UnhandledException event. However, in my application, the event is never fired for threads started with TPL code, e.g. Task.Factory.StartNew(...). The event is indeed fir...

C# Retrieve Canon Specific EXIF Data

I have wrote an app that reads the basic EXIF data from an image via the PropertyItems exposed in .Net's System.Drawing.Image class. However, I cannot retrieve Canon specific EXIF data via these properties. How does one read this information? I know it exist in the file as Photoshop reads it. ...

How to resolve %CommonProgramFiles%\system\

I have a situation where I need to return a directory path by reading the registry settings. Registry value returns me a path in the format %CommonProgramFiles%\System\web32.dll while the consumer code is expecting it in the format C:\Program Files\Common Files\System\web32.dll How can I resolve such directory path in .net code? ...

Weird <T> Activator Question.

Hello, I'm sorry, but a while ago I wrote a piece of code that was so nice. And now I'm trying to remember it for a new project. All I can remember about it is that it looked something like this: public static Create<T>() *something missing here* : *Something missing here* { // add methods etc here. I also think I remember someth...