.net

Implementing a "LazyProperty" class - is this a good idea ?

I often find myself writing a property that is evaluated lazily. Something like: if (backingField == null) backingField = SomeOperation(); return backingField; It is not much code, but it does get repeated a lot if you have a lot of properties. I am thinking about defining a class called LazyProperty: public class LazyProperty<T>...

Why would I use Reflection in a business app?

I know what Reflection is but why would I need to use it in a typical line-of-business Winforms app? ...

Check Method Signatures when moving a Single DLL

Is there a way to check that the method signatures of a bunch of .NET dlls are "lined up" against one another? Basiclly what the complier does during compile time,but instead it would be trying me trying to move a single dll up instead of the whole group of 20 to fix a problem. For example you have a function that lives in AssemblyB.dll...

How do I get all strings from a Form for localization?

All articles I've read about localization of a WinForms application assume that I already have all the strings translated. According to the articles, I should just set the Localizable property to true and edit all the controls. But how do I get all the original (English) strings from the form? Assume I have a complete application, which...

Fastest Way to get Data From Array Into SQLServer Database?

Problem: How to most efficiently move data from an array into a SQL Server table. Details: I have created an array with many rows (typically, about 100,000) and many columns (about 40) in memory in a WinForms application. I need to get this array into a corresponding SQL Server table in the fastest way possible. Right now, I am creating...

Windows Forms Databinding DisplayMember a Custom Class's Child Property

I'm trying to set the DisplayMember Property of my ListBox in a windows forms project to a property of a nested class inside a Generic List I am binding to. Here's a simple example: public class Security { public int SecurityId { get; set;} public SecurityInfo Info { get; set;} } public class SecurityInfo { public ...

How would I Practice .NET at Home (gratis)?

How do you manage to use and practice the Microsoft technologies without the ability or desire to pay for all of the software needed? Are there free versions of Visual Studio, SQL Server, and plugins? Are there any tutorials on how to set up ASP.NET Development on a local server? Is it practical to develop and test on my own machine? ...

Repository Pattern - MVC storefront

Have been looking at the MVC storefront and see that IQueryable is returned from the repository classes. Wondering if you are not using LINQ does it makes sense to return that object? In the case of LINQ in makes sense because of deferred execution, so adding filtering in the service layer makes sense, but if you don't use LINQ you wou...

Compare and Contrast NHibernate and OpenAccess from Telerik

Have you used the OpenAccess ORM from Telerik? How does it compare to NHibernate? When should I consider using it over NHibernate? ...

.NET - How can I get more information for an error in my program? Error: "The thread 0x566967f6 has exited with code 0 (0x0)"

Maybe you can help me... I am writing a program in Windows Mobile that connects to a mail-server and retrieves data from a POP3-server. I am using a third-party (free) socket available from here. I am using VS 2008 (in VB.NET) and the device-emulators. I can connect without any problems and execute my various commands (such as logging ...

How do I allow my .net program to compile C# code while running?

I've seen a couple .net applications that allow you to select a C# .cs source file and the program itself will compile this code and run it. How is this done? ...

Parameterised query breaks when doing LIKE condition. Why?

So, I have a method that performs a parametrised LIKE query. The method takes in the search parameter/value in and then it is added to the command ready for the query. It is not working. It should work, and when I code the value to search for directly into the SQL string, sans parametrisation, it does work! When I have it as a paramete...

how did you or do you handle the DataGridCell edit events in WinForm Datagrid .Net 1.1?

Since Winform Datagrid in .net 1.1 lacks of cell edit events like Datagridview in 2.0. i am wondering if there are certain workaounds in order to add validation events when users finishing editing a cell in a datagrid. wishing our customer to let us upgrade his apps to 2.0 at least ...

Fastest way to convert datatable to generic list

I have a data tier select method that returns a datatable. It's called from a business tier method that should then return a strongly typed generic List. What I want to do is very similar (but not the same as) this question: http://stackoverflow.com/questions/208532/how-do-you-convert-a-datatable-into-a-generic-list What's different i...

Need help moving nUnit tests into separate project

Everything works fine when the unit tests class is part of the main project (TestAccount). Every article I've read about unit testing recommends putting the tests in a separate project, so I... added another project (TestAccount.UnitTests) to the solution moved the unit tests class (AccountTests.vb) to TestAccount.UnitTests and ...

Singleton DAL class

Hi, Shouldn't classes in DAL (customerDAL) be singleton? Since my controllers (customerController) exposes "Shared Subs", then on every call, there is no need to create a new DAL object if already existed. Correct? Thanks ...

What Are The Core Classes In C#?

What is the class hierarchy that is most necessary to get a excellent grasp of, for the aspiring C# desktop applications programmer? Not just the totally obvious stuff. EDIT: To clarify, I mean, that as I am learning C#, I would like to know what are the classes I should be acquainting myself with, that aren't necessarily going to be ...

MVC in .NET: How to not duplicate classes?

I have a Person class in the Model and want to assign 15 of its attributes to labels in the View. The View shouldn't access the Model. That means the Controller will handle creating the Person. How does the View get these Person attributes from the Controller? If the Controller contains a member of Type Person, the View can do someth...

How do you implement GetHashCode() on objects?

Duplicate: http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-systemobjectgethashcode If you've written an object with a variety of data-members, how do you intelligently implement GetHashCode()? One developer told me he just XORs (^ operator) the Hash of relevant data-fields, but I am unconvinced ...

How to do robust SerialPort programming with .NET / C# ?

I'm writing a Windows Service for communication with a Serial Mag-stripe reader and a relay board (access control system). I run into problems where the code stops working (i get IOExceptions) after another program has "interrupted" the process by opening the same serial port as my service. Part of the code is as follows: public parti...