.net

Best Practices For Mapping DTO to Domain Object?

I've seen a lot of questions related to mapping DTOs to Domain Objects, but I didn't feel they answered my question. I've used many methods before and have my own opinions but I'm looking for something a little more concrete. The Situation: We have many domain objects. We are using a CSLA model so our domain objects can be pretty co...

How can I define my own columns in a WPF DataGrid?

I've got a AutoGenerateColumns WPF-DataGrid getting bound in code-behind to LINQ-to-SQL, which works fine. But when I take off teh autogeneratecolumns and define my own columns, it tells me "The items collection must be empty before using ItemsSource." But I'm not binding the ItemSource in my XAML so I don't see why it isn't empty. Wha...

What is the fastest way to load data into a ORACLE database with .NET?

I currently have a daily process that loads a large amount of data from a TXT file into a ORACLE database, using a shell script that calls sql_loader. I want to migrate that to a .NET service, but don't want to rely on executing sql_loader from my service. What is the best (and fastest) way to accomplish that? ...

Is there a read-only generic dictionary available in .NET?

I'm returning a reference to a dictionary in my read only property. How do I prevent consumers from changing my data? If this were an IList I could simply return it AsReadOnly. Is there something similar I can do with a dictionary? Private _mydictionary As Dictionary(Of String, String) Public ReadOnly Property MyDictionary() As Dicti...

Hidden Features of Nant

Continuing the Hidden Features series for Nant. One of the things I learned recently was <xmlpoke> Allows you to replace text in an xml file. e.g. http://stackoverflow.com/questions/678096/setting-debugfalse-in-web-config-as-part-of-build/678137#678137 Question will be updated to show the top voted answers ...

What are good programming practices to prevent malware in standalone applications?

Does anyone have any thoughts on how to prevent malware attacks on standalone applications. Let's say this is a program on a Windows machine connected to the internet, this is the most common scenario. I'm also wondering what type of attacks are possible. I believe .NET will do some type of static check on the code before it runs it, ...

Cache data. Sql and Sybase

Hey all, Ive been tasked to upgrade our existing extranet from .net 2.0 to 3.5. One of the main issues i had during the build phase for the 2.0v was the data was coming from SQL server 2005 and a legacy db in Sybase 9. To achieve this i basically made to Dataset's accordingly based on SPROCS and a third DS to merge. This then would...

Does .NET's HttpWebResponse uncompress automatically GZiped and Deflated responses?

I am trying to do a request that accepts a compressed response var request = (HttpWebRequest)HttpWebRequest.Create(requestUri); request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate"); I wonder if when I add the second line I will have to handle the decompression manually. ...

Column limitation on CSV using Microsoft Jet OLEDB

Hi, I'm importing data from a CSV that contains approx 350 columns. This CSV import is fixed and I have absolutely no control over it. If I attempt to open the CSV in Excel 2003, it only partially loads due to the column limit of 255 (IV). When I load the CSV into a DataSet using OleDb and Microsoft.Jet.OLEDB.4.0 it also only shows 25...

Precompile XmlSerializers with XmlAttributeOverrides

When constructing XmlSerializer instances in .NET, assemblies for serializing and deserializing the specified type are generated dynamically. This is a time-consuming process. The sgen.exe tool from Microsoft can be used to precompile XmlSerializer instances to use them later without generating them dynamically. Unfortunately this is not...

.Net RegularExpressionValidator matches differently than Regex class

Hello all, When I use the .Net RegularExpressionsValidator control the Validation expression matches EXACT text. When I say this I mean, for the string I give it to validate, if it deviates from the regex pattern at all the string does not validate. ex: (([0-1][0-9])|([2][0-3])):([0-5][0-9]) if given in the RegularExpressionsValidator...

.Net Excel Interop Deleting a worksheet

I'm trying to delete a worksheet from a excel document from a .Net c# 3.5 application with the interop Excel class (for excel 2003). I try many things like : Worksheet worksheet = (Worksheet)workbook.Worksheets[1]; worksheet.Delete(); It's doesn't work and doesn't throw any error ... ...

Best resources for a Java developer working on .NET solutions

My company has acquired several companies lately. We are a Java shop but have both VB .NET and C# .NET code bases now. I am about to start supporting these systems and am having trouble find good resources for finding the parallels/differences in .NET and Java. I have seen a few books but cannot decide which to buy, they all seem basical...

Dynamically Populated TableLayoutPanel Performance Degredation

I have a user control that contains a 2-column TableLayoutPanel and accepts commands to dynamically add rows to display details of an item selected in a separate control. So, the user will select a row in the other control (a DataGridView), and in the SelectedItemChanged event handler for the DataGridView I clear the detail control and ...

How to develop using WIA 1 under Vista?

I'm using VS2008 SP1 under Vista SP1. My .Net-program uses a COM reference to WIA (Microsoft Windows Image Acquisition Library v2.0). I'm using CommonDialogClass.ShowAcquireImage to scan a document and it's working fine. One of my customers is running XP. As I understand WIA, under XP you have to use WIALib (WIA 1.0). Is it possible to d...

Using Transactions with Business Processes and the Repository pattern

I have a situation (I'm guessing is pretty standard) where I need to perform some business calculations and create a bunch of records in the database. If anything goes wrong at any point I need to roll everything back from the database. Obviosly I need some kind of transaction. My question is where do I implement transaction support. Her...

Best practice for removing Database calls from MVC Controller classes

Hi All, I have an Action method in an ASP.NET MVC Controller class that handles form posts from a fairly basic "create/edit a user" page. I'm new to MVC so I've been following code samples from various Microsoft tutorials, this is how the method looks currently: [AcceptVerbs(HttpVerbs.Post)] public ViewResult Save([Bind(Prefix = "Servi...

What tooling do you use to do Design by Contract?

I used to use Microsoft CodeContracts for three weeks and now half of my code is just contracts. I have dozens of unproved places, I cannot use runtime-check because IL rewrite prevents coverage tool to show something and compile time is less then acceptable. I do not like this. And seems now is a good time to ask a help. What tooling ...

Combining URIs and Paths

I am retro-fitting an application to make use of a PHP HTTP proxy (for caching) instead of the actual API server, the application currently combines the server URI and the path with the code: methodUri = new Uri(apiUri, method.Path) Where: apiUri = "http://api.eve-online.com/" (System.Uri Object) method.Path = "/char/SkillIntraining...

custom templatefield using ASP.NET Gridview

Hi, I can figure out a couple of hack ways of doing this,...but no really neat ".NET" way. I am displaying a table of data using Gridview...one of the columns is dedicated to displaying the status of a boolean variable. The spec I am trying to meet is to have a "On" and "Off" button in the column representing this variable....and click...