.net

Is it possible to map a IDataReader to a nested DTO using automapper?

I was hoping that I could map a flat datareader into a nested DTO. Running the following code the name is null. Am I doing something wrong or is this just not possible? class Program { public class Person { public int id { get; set; } public Name name { get; set; } } public class Name { ...

How to get list of avialable screen resolutions?

Possible Duplicate: How to list available video modes using C#? My application needs a list of available screen resolutions. I've red this article (link text) but it didn't help me so much. Is there any other way? ...

How do I find the file path from a namespace.class name?

I'm programatically looking ito a .aspx file and getting the file class name declared in its CodeBehind. For example, when analyzing myFile.aspx I read in its Page Directive and found its CodeBehind equals "myApplication\myPage.aspx.vb". Then I use the code below: [Code] Dim Assm As System.Reflection.Assembly = System.Reflection.Assem...

How to implement this logic in linq, collection . Shortning a searching scope

PK_RPM_BTN_SETTING_ID FK_BUTTON_ID FK_ITEM_OR_PKG IS_ITEM_OR_PKG SORT_ORDER --------------------- ------------ -------------------- -------------- ---------- 1 1 1 I 1 1 2 1 P 2 1 3 ...

Using a .Net 2.0 Web Reference in Visual Studio 2010

I have a .Net 3.5 class library project that I've migrated to use Visual Studio 2010. It still targets .Net 3.5. This project contains two ASP.Net 2.0 style Web References (with the auto generated Reference.cs files). During the migration to VS 2010, the Reference.cs files were updated to use .Net 4.0. Specifically, the constructor att...

How to use string values in place of ticks on WPF Tickbar?

I wish to customize the appearance of the basic WPF TickBar. I was wondering if there was a simple way to do this using a control template: I wish to have numbers in place of ticks along the tickbar. I want the position of the number to correspond to the value of a slider (much like the picture in the link). I've searched around an...

VNCSharp Disconnects Immediately

I am using VNCSharp (http://cdot.senecac.on.ca/projects/vncsharp/) to create a WPF based VNC client. When I try to connect to a server I am almost immediately disconnected. But when I use the RealVNC client (a RealVNC server is running) the connection completes just fine. Does anyone have any ideas why I'm getting bounced off the serv...

C# to VB.net project conversion

I am trying to convert a C# project to a vb.net project but am having some difficulties. The following is the click event of a button: private void button2_Click(object sender, EventArgs e) { Appointment m_App = new Appointment(); m_App.StartDate = dayView1.SelectionStart; m_App.EndDate = day...

Not tracing WCF Service (diagnostics tracing)

I have a client (a Unit Test) that call to WCF Service (hosting in debug mode in Console application). I have an error in service but I dont know which. I need trace it, but not generate anything file svclog in client. any suggestions , any sample code works ? EDIT: I use logging EntLibrary 4.1. I think there are errors in configurati...

ASP.NET MVC Problem with Html.ListBoxFor()

I'm having problems with the helper Html.ListBoxFor(). Here is my ViewModel: public class NewReservation { public SelectList AvailableServiceDates { get; set; } public DateTime SelectedServiceDate { get; set; } } Here is my action method: public virtual ActionResult New() { NewReservation newReservation = new...

Using List as query string parameter using MVC

Hi. I have an action method that looks like this: public ActionResult DoSomething(string par, IEnumerable<string> mystrings) I wanted to map this to a URL using Url.Action, passing mystrings in the RouteValueDictionary. However, this only yields a query string that only corresponds to mystrings.ToString(). How could I pass a list in ...

Index of Currently Selected Row in DataGridView

It's that simple. How do I get the index of the currently selected Row of a DataGridView? I don't want the Row object, I want the index (0 .. n). ...

Determine source of a ConstraintException in an EF entity.

I have an entity class with a bunch of non-nullable string properties. If I try and set one of these to null, I get a ConstraintException and the message "This property cannot be set to a null value." Without setting tracker variable to the name of each property before assignment, is there a way I can determine which property assignmen...

How do I add an 's' to the end of an output sentence?

How would I add a character to the end of my output? I am scraping some data, I am using a regex to get what I want. I got it but I have to add an 's' to the end of the sentence. The sentence changes every time so I can't just do a replace. I think I am using the .NET regex engine. ...

iTextSharp not converting aspx( html )to pdf

Hi, I want to convert one of my asp.net reports to pdf as it is. However, I thought iTextSharp would be the ideal solution but it is not converting the report properly. My conversion code is as follows Public Function DotNetConvert() Dim strFileName As String = HttpContext.Current.Server.MapPath("map1.pdf") ' strFileName ...

c# cross-thread error with UserControls

Here is my situation: I instantiated a c# usercontrol on a main thread, but it is not added to the form. //global declaration usercontrol1 datacontrol; constructor() { ....... datacontrol = new usercontrol1(); ........ } I then have an asyhcnronous background thread that fires an event that is handled by the instantiated data...

How to stop log4net from writing to two separate files

I'm using the below log4net configuration. I'm trying to write performance logs to a separate file but the output is going to both files. Even though I'm specifiying: private static readonly log4net.ILog log = log4net.LogManager.GetLogger("PerformanceMetricsLogger"); How do I stop log4net from writing to the default appender in this...

XML from DataTable using Linq

This code XmlDataDocument xmlDataDocument = new XmlDataDocument(ds); does not work for me, because the node names are derived from the columns' encoded ColumnName property and will look like "last_x20_name", for instance. This I cannot use in the resulting Excel spreadsheet. In order to treat the column names to make them something mo...

How do I create a secondary message loop in vb.net?

I've got an app working semi-background stuff in the GUI thread. Another thread won't work and a timer won't work. But I want the app to be responsive while I'm going my 'background' work. I cound use application.doevents - but that gives me 3 bad choices: loop with no sleeps - end peg an entire CPU (my task waits on stuff besides cal...

MVVM Window / Control Operations

I'm building a WPF MVVM application and I'd like to keep what I can conforming to MVVM (I know some stuff is over-engineering, putting a best effort here though). I've run into a small dillema, I need to Hide / Close a window based on some logic in one the the methods in the view model. I can't for the life of me come up with a reliabl...