.net

To encapsulate database connection in business objects or not?

I usually like to create the database connection myself and control its lifetime manually with `using{}'. For example: SqlConnection sqlConnection = new SqlConnection( connectionString ); using( sqlConnection ) { BusinessObject myBusinessObject = new BusinessObject( sqlConnection ); // do stuff with the business object ... }...

What is the safe way to open URLs in the default browser?

Basically I'm trying to open a URL in my .NET application. This can be achieved easily by doing : Process.Start("http://www.google.com") However in my case the URL can be controlled by external users, therefore I don't want them to execute commands in the system by injecting meta characters etc. So safe way would be : Read registr...

Which collection for storing unique strings?

I'm looking for a collection just like Dictionary(OF Key, Value) but I don't actually need a key and value. Key itself is enough. So something like Collection(Key). It shouldn't accept duplicate keys. I've looked up couple of collections in .NET Framework but couldn't find what I want. Currently I'm abusing Dictionary(OF String, String)...

MS StyleCop and CruiseControl.NET

I wonder if anybody tried to integrate StyleCop into CruiseControl.NET. Does anybody know something about it? or at least did anybody create and publish an xsl file for displaying StyleCop result onto CCNet's dashboard? EDIT: I found this project, it provies cmd interface for StyleCop, produces result in xml format and also provides xs...

Implementing observer pattern using WCF

When I first posted this question I had strong coupling between my web service and application controller where the controller needed to open multiple threads to the service and as it received back data it had to do a lot of processing on the returned data and merge it into one dataset. I did not like the fact that the client had to so m...

How do I pass a Linq query to a method?

I'd like to pass a Linq query to a method, how do I specify the argument type? My link query look something like: var query = from p in pointList where p.X < 100 select new {X = p.X, Y = p.Y} clearly I'm new to Linq, and will probably get rid of the receiving method eventually when I convert the rest of my code, but it se...

How to get offset of a Regex capture ?

I'm trying get the offset of a regex capture in .NET just like .IndexOf() would return. Is there anyway to do that? ...

Safe element of array access

What is the safe method to access an array element, without throwing IndexOutOfRangeException, something like TryParse, TryRead, using extension methods or LINQ? ...

What's the best way to remote Winforms apps?

So I've got a project, running all on a private network. I've got a computer interfacing to some specific pieces of hardware and presenting a user interface via Winforms to control them all. Now, I'd like the ability to split the app, such that all the interface and main business logic runs on one computer, but the GUI runs on anot...

Why is doing a .Net 2.0 build clean solution causing errors?

I have a .net Solution that creates a DLL. It it made up of two projects. (Side information one contains a number of my special functions/classes etc. written in VB.Net. The second is some functions/classes etc. that are specific to a client and these use my classes) After some this and that and the other work I can build and rebuild t...

Database for an embedded system

I'm looking for a very high performance and cheap (hopefully free) database engine to be used on an x86 embedded platform in Windows CE. Can anyone give some suggestions? The important things I'm looking for are: High Performance (for a real-time system) Low cost Usable with Compact .NET framework Thanks ...

Operator as and generic classes

I'm writing .NET On-the-Fly compiler for CLR scripting and want execution method make generic acceptable: object Execute() { return type.InvokeMember(..); } T Execute<T>() { return Execute() as T; /* doesn't work: The type parameter 'T' cannot be used with the 'as' operator because it does not have a class type constraint nor a...

comparing two double values

I use an acceleration sensor to calculate the current accelerations and it returns the double value. However I would like to compare the current acceleration with value 9.8. Before doing that i have to round the value received from the sensor so the question is: How to round a doble value to a selected number of decimals in .NET? ...

Can’t access an aspx page via IIS

Hello, I’m running IIS 5 on Windows XP professional I created new Web project and configured VS 2008 to save this application to location c:\Inteput\wwwroot. Thus VS saved the project into directory: c:\Inteput\wwwroot\WebApplication1 I then transformed this WebApplication1 folder into virtual directory (this virtual directory ...

Extending enums via user input

I have the below enum that I use for one of my filters and suit well to my object model public enum ColorGroups { White = 1, Brown = 2, Red = 3, Black = 4 } My concern is in the future when a client want to another color to the collection how do I extend the collection. I want the system to be fully dynamic and does no...

LINQ InsertOnSubmit loses formatting

I have a table with a nullable field of type text. When I run an InsertOnSubmit(), it inserts successfully but all formatting is lost. Specifically, I'm storing the stack trace of an error. Each entry has been formatted into its own line and it looks nice, but when I retrieve it from SQL it loses all its crlf4's. I have other text fiel...

Starting out with Silverlight

Exactly what do I need to get started from scratch in order to develop with Silverlight? ...

Running RESTful service in its own thread: how to start and stop the thread appropriately?

Hi, I created an application which hosts a RESTful service in its own thread. When I close the application I noticed that some resources are still running. I would be very thankful if anyone could take a look at the code for initializing, starting and stopping the thread and suggest some better way for doing it. These are the methods...

Any OSS .Net FTP (client) with TLS and SSL?

Does anyone know of an open source library that does ftp-client with TLS and SSL for dotNET? We are using a commercial library now but we are not very happy with it, so we are thinking of switching. So instead of rolling our own, are there any lgpl (or equivalent) librarys out there? Or - If we have to roll our own (it will be a LGPL ...

What is the best way to run a continuous process in its own thread?

I created an application which has to periodically perform some tasks using threads. I am not sure if this is the best way for doing it so I would really appreciate if anyone could suggest a better way. This is the way I did it: This is the class which includes the functions for a continuous process (looking for inactive sessions and c...