.net

What is Environment.FailFast?

What is Environment.FailFast? How is it useful? ...

MVC & Date Formatting

Hi, Where in an MVC based architecture should the date formatting (long/short/time/no-time/UK/US) live? I want to be able to specify long/short/time/no-time on a per-field basis - i.e. DateOfBirth doesn't care about time, but CreationDate might. Using ASP.NET MVC, there doesn't seem an easy way to do it in the View, which makes me won...

How can I encrypt a message in Perl to decrypt it in C#?

Hi all, I am needing to encrypt using Perl and decrypt on .Net (C#). i.e. Perl encrypts a file and my .Net code decrypts the file (and even maybe validates integrity). The problem is that I am not familiar with the encryption capabilities of Perl. Can anyone offer guidance on how best to approach this and what the possibilities are? T...

What is a "first chance exception"?

What exactly is a first chance exception? How and where does it originate in a .Net program? And why is it called by that peculiar name (what 'chance' are we talking about)? ...

If you are a hard core .NET programmer, would you invest in learning Java

Learning just another language is not much work. However, getting familiar with all the supporting libraries is veeeery expensive and actually you cannot go too far without that. Would you consider a worthy career investment to learn java once you already are an accepted professional of .NET or you would rather invest the same amount of...

Allowing title bar double click to maximize a dialog but without max-min buttons

This is a little C# specific. The default behaviour of a resizable dialog box is that title bar click maximizes the dialog and a second double click restores the size. However what I want is to have the Help button turned on, which means the minimize and maximize buttons are hidden, but would still like the title bar double click behavio...

Horizontal scroll position when a winforms treevew item is selected

We have some code that uses the .net Windows.Forms.TreeView. When an item in the view is selected then code does treeView.BeginUpdate(); // ... some stuff ... SendMessage(treeView.Handle, WM_HSCROLL, SB_LEFT, 0); treeView.EndUpdate(); This is so that the tree view display doesn't scroll right (which is the default behaviour - to show ...

WCF and NetTcpBinding

When I expose a service using NetTcpBinding, is .Net remoting used under the surface? Could I consume this service using .Net remoting on the client side? I ask this because I always thought that WCF was just a wrapper for underlying protocols such as WS*, Remoting, COM+, and MSMQ. And while I know that exposing WS* will work as expect...

Entity Framework - Table Per Type Inheritance - Existing Database

I want to implement Table Per Type inheritance with Entity framework for an existing database. The database: The inheritance for ImageParagraphs works perfect, but I am not able to make a Table Per Type inheritance with LinkListParagraph because of the different primary keys (ParagraphID; ParagraphID+LinkID): Error 1 Error 3003:...

Porting a .NET 3.5 application to a portable device

I have written a server/client application using sockets in C# for .NET 3.5. I'm interested in porting the client part to some kind of mobile device and am pondering the best way. The client is actually an underlying library and a GUI depending heavily on touch interface capabilities. As I see it I have a few options: Just get an EEE ...

Is there any simple way to check that a path to a file is inside a certain folder (.NET framework)?

In my program I need to check that several paths to files are inside system temporary files folder (for example C:\Users\Roman\AppData\Local\Temp). I haven't found any method in System.IO.File, System.IO.Directory and System.IO.Path classes to do so. So I created my own: public static bool IsSafeToDeleteFileOrDirectory(string path) { ...

NHibernate one-to-many

Hey, I have a pretty simple NHibernate setup: an Item object which has a collection of ItemDetail objects. One-to-many relationship between them. In my web application, I'm writing code similar to: item.Details.Add(new ItemDetail { Item = item, Text = "blah" }); itemRepos.Save(item); This all works well. However, now I'm writing a s...

Keep a large number of objects in memory for a long time

In my ASP.NET app, I have a dictionary that contains a large number of objects (let's say as large as 1M, could get even bigger later), the object stored in the dictionary is of reference type not struct type, the dictionary is meant to work as a cache for this type of objects (I have my reasons not to use the ASP.NET cache for caching t...

Parsing HTML generated from Legacy ASP Application to create ASP.NET 2.0 Pages

One of my friends is working on having a good solution to generate aspx pages, out of html pages generated from a legacy asp application. The idea is to run the legacy app, capture html output, clean the html using some tool (say HtmlTidy) and parse it/transform it to aspx, (using Xslt or a custom tool) so that existing html elements, ...

Comparing program flow between same app in .net 1.1 and .net 2.0

I'm looking at upgrading an application we're developing here using Visual Studio 2003 / .NET 1.1 to Visual Studio 2008 / .NET 2.0. Now I was testing stuff, and found that I have a reproducable case in which the .NET 1.1 version does what it is supposed to do, while the .NET 2.0 version (same code) ends up in an infinite recursion (the ...

How to programatically restart windows explorer process

I'm working on a windows shell extension, and unfortunately, when making changes to the DLL, I must restart windows explorer (since it keeps the DLL in memory). I found this program from Dino Esposito, but it doesn't work for me. void SHShellRestart(void) { HWND hwnd; hwnd = FindWindow("Progman", NULL ); PostMessage(hwnd,...

Passing value from child to mdi parent in VB.net

I have a simple contact book. The application has a main window that's an mdi form. When a contact is added using the "add a contact" form, I want to show a simple feedback message in the parent window status bar saying that the contact was added successfully. Here's the child loading: Private Sub addButton_Click(ByVal sender As System...

How can I get a username and password from my database in C#?

I have the following code in my btn_click event: Sqlconnection con = new Sqlconnection("server=.;database=bss;user id=ab;pwd=ab"); con.open(); SqlCommand cmd = new Sqlcommand("select * from login where username='" + txt4name.Text + "' and pwd='" + txt4pwd.Text + "'", con); SqlDataReader reader = cmd.execute Reader(); Where login is ...

.NET database migration toolkit

My current pet project is a language-independent database migration library (Wizardby on Google Code). It's pretty much inspired by ActiveRecord Migrations, but has a few niceties. For instance, does some basic "type inference" so you don't have to specify the type of a FK column. It's also smart enough to generate "downgrade" scripts gi...

Reading merged excel data in vb.net using ssis

Hi!! I got into a tricky issue here. I am working with SSIS tool set to import data from certain files. One of these is an excel spreadsheet. The problem is while picking data from merged cells. Here is a detailed version of the issue - RowNo ColA ColB 1 Value1 2 XYZ In the above example, Va...