.net

How do you log error when the process is halted or computer went down?

How do you log a event if the program process is halted or when the processing computer is down? I'm using Microsoft Enterprise library to do all my logging but I'm not sure how to log the above situation. ...

Any good security encoding libraries for .NET out there ?

Hi all.. Been reading up on various injection-type attacks, and it seems like the best way to get rid of these vulnurabilities is to encode all user input to remove / replace some characters with others (< > ; etc). What's my best bet here? Are there any nice libraries out there to aid me with this? Or something that could help me spot...

How can I send emails that preserve the formatting that a user provides in RTF in a RichTextBox?

What I'm trying to do is provide a form where a user can type or cut and past formatted text and be able to send it as an email (similar to outlook). This is required because it's closely resembles the current work flow and these emails aren't being saved anywhere besides people's inboxes. This is obviously a bandage on a bigger proble...

How can you cast objects from different assemblies into each other?

I've run into this apparently not uncommon problem -- I have a interface in Assembly A. I am dynamically loading Assembly B, and trying to cast an object from it into my interface from Assembly A. It's failing with an InvalidCastException. I've come to understand why -- a class in Assembly A and a class in Assembly B, even with the s...

Can you use a .net 3.5 DLL with a .net 2.0 website?

I have some DLLs that it would be much easier to use .net 3.5 internally (to take advantage of Linq, etc). I want to use these DLL with asp.net websites that are currently running asp.net 2.0. Is this scenario possible? Are there any restrictions or gotchas (e.g. asp.net doesn't make any calls to methods which return .net 3.5 objects l...

How to dynamically select the URI for a WCF service?

I'm trying to construct a WCF client object using a run time URI string. This seems simple enough but I'm running out of thing to try that don't seem like "the wrong way to do it". The original code is this: IPrototype p = new prototype.PrototypeClient(); and I was sort of expecting it to work something like this. string uri = GetM...

Convert an array of objects

how can i convert from: object[] myArray to Foo[] myCastArray ...

Ignore read-only class properties when using DataContext.ExecuteQuery<T>

How do I tell a LINQ data context to ignore either specific properties, or all readonly properties, when binding a result set to an object? I am working with some T-SQL statements that are difficult to express using LINQ, so I'm using the ExecuteQuery method of the data context to pass the straight T-SQL to the database. If my class T ...

Can I configure the DataContractSerializer to not create optional (i.e. Nullable<> and List<>) elements in output XML?

I am using the new .NET 3.0 DataContractSerializer. I have both Nullable<> and List<> objects I am going to serialize. Example: [DataContract(Namespace = "")] class Test { public static void Go() { Test test = new Test(); var dcs = new DataContractSerializer(typeof(Test)); dcs.WriteObject(new StreamWri...

Hashtable vs Dictionary

My understanding is that Dictionary does not have boxing issues and faster in performance. Are there cases that the usage of Hashtable would be more advisable compared to Dictionary? Thanks ...

Does this Caching function work how I think it does?

I've tentatively written this method: public static Func<T> WeakCacheFor<T>( Func<T> provider ) where T: class { var cache = new WeakReference(null); return () => { var x = (T)cache.Target; if( x == null ) { x = provider(); cache.Target = x; } return x; }; } S...

Best Open Source Business Rule Management System

Does anyone know of a solid free and/or open source business rule management system. The organization I work for is developing increasingly more complex (business-wise) applications and it would be really nice to have a rule based system for saving, maintaining and allowing inter-relation of those business rules over time. Edit: Additio...

Modifying a type after it has been created with TypeBuilder.CreateType

I'm creating a dynamic class in a dynamic assembly at runtime, and want to be able to Define methods for that class on demand. Ex. Build the Type X Define Method GetA on Type X Create Type X Call GetA use same type builder for Type X Define new Method GetB on Type X Recreate type X, that now has both GetA and GetB if that is impossi...

Command Line Compiling a Win Forms C# Application

I'm trying to create a script to compile an Windows Forms C# 2.0 project from the command line (I know, I know.. I'm reinventing the wheel.. again.. but if somebody knows the answer, I'd appreciate it). The project is a standard Windows Forms project that has some resources and references a couple external assemblies. Here is a list of...

How do you hide encapsulation in C#?

Socket.Dispose() is an inaccessible member. However, we can bypass this by doing the following: ((IDisposible)Socket).Dispose() Two questions: Why is this allowed? How does this work internally? ...

The Value of Unit Testing

Here are some typical answers(ranked in ascending order of corniness) I get from managers/bosses whenever I bring up the importance of having unit tests and code coverage as an integral part of the development cycle "That is the job of QA, just focus on features and development" "The application is not mission critical, if there are ...

Entity framework memory usage

The entity framework appears to use excessive amounts of memory when inserting new objects into a database. for(int i = 0; i < numOwners; ++i) { var owner = Owner.CreateOwner(); db.AddToOwnerSet(owner); for(int j = 0; j < numChildren; ++j) { var child = Child.CreateChild(); owner.Childs.Add(child); ...

Using statement and Close methods.

Does the using statement really call the close method when used with a database connection object? The MSDN documentation says it ensures that the Dispose method is called but makes no mention of close. I see posts on Stack Overflow where people say that it does both. Does someone have a concrete answer one way or another on this from Mi...

Unicode Collations problem ?

(.NET 3.5 SP1, VS 2008, VB.NET, MSSQL Server 2008) I'm writing a small web app to test the Khmer Unicode and Lao Unicode. I have a table that store text in Khmer Unicode with the following structure : [t_id] [int] IDENTITY(1,1) NOT NULL [t_chid] [int] NOT NULL [t_vn] [int] NOT NULL [t_v] [nvarchar](max) NOT NULL I can use Linq to SQL...

Cruise control.NET

Hi , I am just a beginner in cruise control.NET.My doubt is that is there any way by which cruise control.NET can detect changes in the local folder itself(for eg:C:/MYSource)rather than look for changes in the source control repository.I need to force the build all the time from the web dashboard to build.I want cruise control.NET ...