.net

Get value of static field

I've got the following class: public static class Pages { public static string LoggedOut = "LoggedOut.aspx"; public static string Login = "Login.aspx"; public static string Home = "Home.aspx"; } I know I can use Pages.Home statically, but there is a reason for my question. I wish to have a method that I can call like this...

add contents through textboxes

I have a Windows Forms application which contain a textbox (tbox) and two buttons: Save (b1) and Delete (b2) and an XML file leaf.xml Whenever i am putting anything in textbox and then click Save (b1) the content in textbox will be saved in the leaf.xml file. When i press delete (b2), it will delete from the file leaf.xml and at the sam...

GDI+: How do I draw a line that's one inch in length on any device it's drawn on?

I need to draw a line one inch long on any device given a Graphics reference to it. I need it to be an inch long regardless of what Transform is set to. Let's assume that the scaling factor of the transform is given by scale in both horizontal and vertical directions. Some C++/CLI code: g->DrawLine(Pens::Black, 50.0f, 50.0f, 50.0f + on...

Getting single result from a query with anonymous types in Linq To Sql

I have a query with single result. The result is an anonymouse type. How can I use access the type so I don't have to use query.Single() every time? This is my query: var result = from row in db.Table select new { CustomName = row.RowName }; This is how I use it right now: string name = result.Single().CustomName; Of course my re...

MessageBox help

How do I display a MessageBox with Yes and No buttons? ...

Aop, Unity, Interceptors and ASP.NET MVC Controller Action Methods

Using log4net we would like to log all calls to our ASP.NET MVC controller action methods. The logs should include information about any parameters that were passed to the controller. Rather than hand-coding this in each action method we hope to use an AoP approach with Interceptors via Unity. We already have this working with some ot...

How expensive are dots in .NET?

In the past, in C and C++ land, nested pointer dereferencing was considered, by some, to be a relatively expensive operation if executed in a tight loop. You wouldn't want to get caught with: for (int i = 0; i < 10000000; i++) { j->k->l->m->n->o->p->dosomeworknowthatwereherewhynoteh(); } because you might lose precious millisecond...

Is it possible to successfully merge transitive assembly references with ILMerge?

I'm trying to use ILMerge to internalize some transitively referenced assemblies into an assembly I'm referencing to eliminate conflicts with those transitive dependencies elsehwere in my project. In particular, I'm referencing Antlr3.StringTemplate (hereafter referred to as AS, available here: http://www.stringtemplate.org/download.htm...

Must I unsubscribe all event handlers?

Hi, From the Designer in VS let's say you double click on a button and it generates this Click event handler. the subscription code is in the designer.cs. I was wondering, in the dispose the Form MUST I unsubcribe the event ? Also, all control that are in the form will it be disposed when the forms disposes? it actually call dispo...

Multiple TransactionScope problem

Hi, I want to create a transaction, writing some data in a sub-transaction, reading the data back, and rollback the transaction. using(var transaction = new TransactionScope()) { using(var transaction = new TransactionScope()) { // save data via LINQ / DataContext transaction.Complete(); } // G...

Custom JavaScriptConverter for DateTime ??

I have an object, it has a DateTime property... I want to pass that object from an .ashx handler back to a webpage via AJAX/JSON... I don't want to use 3rd party controls... when I do this: new JavaScriptSerializer().Serialize(DateTime.Now); I get this: "\/Date(1251385232334)\/" but I want "8/26/2009" (nevermind localization....

Can Sybase Sql Anywhere be deployed like VistaDB (or MSAccess)?

Hello all, The context : My current project uses VistaDB as it really fits the main scenario: the user log into the application, selects the DB (file on HDD or Network drive), does his job, then logs off. The DB (a single file) can be copied (email, usb dongle, cd ...) and transfered to colleagues or to the headquarters. And, best of al...

Work with DirectoryEntry not on a Domain, set user password never expire

Hello i try to put the user password check to never expire. When i create the user, the check is always uncheck. I try many twist to execute that but noting work. There is my code. DirectoryEntry user = root.Children.Add(adUserName, "user"); // NOTE(cboivin): Documentation : http://msdn.microsoft.com/en-us/library/aa746340(VS...

Storing default value in Application settings (C#)

I am using Application settings to store and retrieve my GUI settings. For one of the setting Name - FileDirectory Type - String Scope - User Value - Problem?? i need to store Desktop folder path i.e Environment.GetFolderPath(Environment.SpecialFolder.Desktop) I can't set this in Settings Page. How can i set this default value? ...

Disappearing Repeater

I have a Repeater generating ImageButtons. When I click an ImageButton or interact with the GridView elswhere on the page, everything generated in my Repeater disappears. All of my controls are in an UpdatePanel so I dont beleive this is a PostBack issue. ...

Does BinaryFormatter apply any compression?

When .NET's BinaryFormatter is used to serialize an object graph, is any type of compression applied? I ask in the context of whether I should worry about the object graph having many repeated strings and integers. Edit - Hold on, if strings are interned in .NET, there's no need to worry about repeated strings, right? ...

How to access DataGridView column names safely?

When manipulating DataGridView cells, you typically do: MyGrid.CurrentRow.Cells["EmployeeFirstName"].Value = "John"; which is all fine and dandy, but as complexity rises, you start worrying about spelling errors, refactoring issues etc. Historically, I just made the columns public so I could access them directly in the class instanc...

Lost in WinDbg with 64-bit dump on 32-bit machine

I'm a newbie with WinDbg and got this dump from the WER ReportQueue folder on a 64-bit Windows 2008 Server. I need to examine the dump and want to do so on my developer machine on which I've installed the Debugging Tools for Windows package. When I try to load SOS I got the following error which I've never seen before: 0:035> .loadby so...

Get friends of a friend in facebook using C#

I am using: http://www.codeproject.com/KB/IP/Facebook%5FAPI.aspx Is there a way in this API? If not, is there a .NET API that I can use to do this? ...

How can I change the working directory for NUnit tests in Team City?

Hi, I am using Team City as the build server, and I have a msbuild build script to build and run integration tests for my project. However, Team City when running my tests decides to ignore the WorkingDirectory attribute on the NUnit task, and as a result my tests fail to initialize: [17:46:54]: [Project "MyProject.msbuild.xml.teamcity...