.net

How to color lines in a listbox?

Hy! I would like to make a logging system with a listbox, that highlights some of my lines, depends on my will :P So, if I have 4 kind of reporting, like, general, warning, error, debug. I add with somelistbox.Items.Add("Starting"); <-- I would like to drawn this as grey somelistbox.Items.Add("Error!"); <-- I would like to d...

RabbitMQ consumer question

I have a Windows Service that retrieves messages from a RabbitMQ queue. The service works locally on a Windows 7 machine. When I install the service on a Windows 2008 server it does not work (and does not throw any errors). My ASP.net MVC app can publish messages to the same queue. Could there be a firewall or security issue here? ...

Detect when drive is mounted or changes state (WM_DEVICECHANGE for WPF)?

Hello, I am writing a directory selector control for WPF, and I would like to add/remove a drive from the directory tree when it gets mounted or unmounted or when it becomes ready or not ready (e.g. the user inserts or removes a CD). I am looking for a system event similar to WM_DEVICECHANGE. konstantin ...

Entity Framework 4 Code Genning - One Set of Entities?

Hello, I am looking to setup architecture for entity framework that will break apart the entities into multiple models. What I am wondering if it is possible to code-generate one set of entities, so that each model uses the same set of data access classes? I realize the issue with contexts, but I was wondering if each context really n...

WPF: How to walk up the Visual Tree to find a Model3DGroup a clicked 3d-model is in?

I'm displaying a few 3D-models as Model3DGroups. They are surrounded by Viewport3D which catches MouseDown-events. I want to determine which Model3DGroup (they all have names) was clicked. I'm starting with this: Point location = e.GetPosition(karte.ZAM3DViewport3D); HitTestResult hitResult = VisualTreeHelper.HitTest(ka...

How to Remove or Revert DataContext.DataLoadOptions?

First let me start by explaining my use case: Say there is a database "Cars". In that database, each row might have Make, Model, EngineType, etc. I have a page that is essentially a view of a single "Car" record, displaying its various stats. In that page, I have a user control that calculates and displys various MPG stats based on the ...

Visual Studio 2008 - Program exits immediately with F5 (start debugging)

I'm having a strange issue with Visual Studio where if I start debugging it exits immediately. This started happening after changing the assembly name in the project properties. If I change the assembly name back to the previous name then the program runs fine. How can I fix this? Here is the output when running after changing the assem...

Do you know what are the best Domain Specific Languages(DSL) tools for .NET 4.0?

I would like to know what are the best DSL tools created to be used in .NET.? I have googled a bit, but, as I have no experience, I just want to be sure that the one I'm going to use is the best or it is among the best ones. Thanks in advance. ...

Parameters in Visual Studio c++ 2010

Hi, I just installed Visual Studio C++ 2010 Express (BTW. great ide). I have to make simple application, but I will open it from command prompt, and I need using parameters. So my question is: how to using parameters in Visual C++ .NET 2010 Express? I need one string and some int. It's special creator to do this or I must change code (i...

Disabling "print" button in .net print preview dialog

I'm working on a C# / .net app. I want the user to be able to print preview, but I don't want the user to be able to print from the print straight from the preview dialog. The print preview dialog has a little printer button on it that sends the previewed pages straight to the printer. Question is, is there a way to get rid of / disab...

If Using Enterprise Library, Is log4net better to log with?

Hello, For a project we are using Enterprise Library 5, and will be using several of the blocks. I'm inclined to use the Logging application block since its built into this framework. But I do see a lot of recommendations for log4net, so what have people chosen to do and if choosing log4net, why did you choose it over some of the othe...

Split list at marker elements with LINQ?

I have a List<T> that is a mixture of 'regular' elements and 'marker' elements. I want to split it into a List<List<T>>, broken at the markers. e.g. given an input of {a, b, M, c, d, e, f, M, g}, where 'M' is a marker element, I want to get {{a, b},{c, d, e, f}, {g}} It is easy to do the job with a loop, but it seems like it should be ...

Best practices for not passing object references on service calls

I have an application where a client communicates with a server side through REST. This is written in .Net, but I guess the question should be independent of this. Now - I have services such as GetAllCustomers and GetCustomerById. A Customer has references to a potentially big list of Order, so I don't want to pass the Customers refere...

Inheriting XML comments from interfaces in C#

Hello, I was wondering if anyone knows how to link an interface xml comment to an implementation. The problem is that I want the base comments to come from my interface first. Example: interface myinterface { /// <summary> /// Does something. /// </summary> void method1(string foo); } and then the implem...

How to access x:Name-property in code?

I assigned x:Name in my XAML-file to a object which can trigger a MouseDown-event. In that event I'd like to get the x:name-attribute of the sender again. How do I do that? The object looks like that: <ModelUIElement3D MouseDown="ModelUIElement3D_MouseDown" x:Name="trololo"> ...

LINQ Join (Left Outer) with Take(1)

I have the below LINQ that is returning zero IF there aren't any Addresses(Inner Join). How would I make this an Outer Join and then only Take(1)? var results = query.Join( DB.tblAddresses.Where(t => t.AddressTypeID == 'm' || t.AddressTypeID == 'b').OrderByDescending(x => x.AddressTypeID), p => p.PersonI...

When hosting a WCF REST service in a console app, error finding contract name

I have a WCF REST service that works from a Windows service (.NET 3.5). To make it easier to build and debug, I would like to run it from a console. When I do this, I am setting up the endpoints in the console app. When I create an endpoint, it fails with this error: "The contract name 'IRestService' could not be found in the list of ...

WPF Is it legal to invoke another event from within an event-invocation-method.

The following code was part of an answer I have received to solve a probem I have posted in SO. It works fine, however I'm curious if its allowed to manually invoke another event from within an invocation-method with the EventArgs of the original event: protected override void OnMouseLeftButtonUp( MouseButtonEventArgs e ) { ba...

Visible Binding Based On Bound Object and Model Properties

I ran in to the unique situation today where I needed to bind the Visible property of a button in a DataGridRow to be based on both a property of the bound object and of the model backing it. XAML: <t:DataGrid ItemsSource="{Binding Items}"> <t:DataGrid.Columns> <t:DataGridTemplateColumn> <t:DataGridTemplateColum...

Is there .net magic to get parameter values by name in console application?

I've been developing .net console applications using C# and have always just dictated what order parameters must be inserted in so that args[0] is always start date and args[1] is always end date, for example. however I would like to move over to using named parameters so that any combination of parameters can be sent in any order, such...