How to unit test if my object is really serializable?

Here is a generic way: public static Stream Serialize(object source) { IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); formatter.Serialize(stream, source); return stream; } public static T Deserialize<T>(Stream stream) { IFormatter formatter = new BinaryFormatter(); stream.Position = 0; return (T)formatter.Deserialize(stream); } public static T Clone<T>(object source) { return Deserialize<T>(Serialize(source)); }

How to call a VBScript file in a C# application?

The following code will execute a VBScript script with no prompts or errors and no shell logo. System.Diagnostics.Process.Start(@”cscript //B //Nologo c:\scripts\vbscript.vbs”); A more complex technique would be to use: Process scriptProc = new Process(); scriptProc.StartInfo.FileName = @”cscript”; scriptProc.StartInfo.WorkingDirectory = @”c:\scripts\”; //<—very important scriptProc.StartInfo.Arguments =”//B //Nologo vbscript.vbs”; scriptProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //prevent console window from popping up … Read more

Determine which w3wp.exe process belongs to which App Pool in Windows 7 / IIS7.5?

If you open IIS Manager, go to the root node in the tree on the left that represents your computer (should be labeled as your computer name). In the Features View to the right, you’ll see a section called IIS. Under that you’ll see Worker Processes. Select that and it should show you all running … Read more

Compare two Lists for differences

This solution produces a result list, that contains all differences from both input lists. You can compare your objects by any property, in my example it is ID. The only restriction is that the lists should be of the same type: var DifferencesList = ListA.Where(x => !ListB.Any(x1 => x1.id == x.id)) .Union(ListB.Where(x => !ListA.Any(x1 => … Read more

tech