Serializing anonymous delegates in C#

Did you see this post that I wrote as a followup to the CountingDemo: http://dotnet.agilekiwi.com/blog/2007/12/update-on-persistent-iterators.html ? Unfortunately, Microsoft have confirmed that they probably will change the compiler details (one day), in a way that is likely to cause problems. (e.g. f/when you update to the new compiler, you won’t be able to deserialise the stuff … Read more

Does the .Net Framework 4.0 Installer include the .Net Framework 3.5?

The .NET 4.0 installer doesn’t include the .NET framework 3.5. There is some information on this topic in MSDN: The .NET Framework 4 is highly compatible with applications that are built with earlier .NET Framework versions, except for some changes that were made to improve security, standards compliance, correctness, reliability, and performance. The .NET Framework … Read more

What is a good way to shutdown Threads blocked on NamedPipeServer#WaitForConnection?

This is cheesy, but it is the only method I have gotten to work. Create a ‘fake’ client and connect to your named pipe to move past the WaitForConnection. Works every time. Also, even Thread.Abort() did not fix this issue for me. _pipeserver.Dispose(); _pipeserver = null; using (NamedPipeClientStream npcs = new NamedPipeClientStream(“pipename”)) { npcs.Connect(100); }

Dapper and SQL Injections

How does Dapper help protect against SQL injections? It makes it really, really easy to do fully parameterized data access, without ever needing to either concatenate input. In particular, because you don’t need to jump through lots of “add parameter, set the parameter type, check for null because ADO.NET has sucky null-handling, rinse/repeat for 20 … Read more

Dependency Injection wcf

When you use svcutil.exe or the Add Service Reference wizard in Visual Studio, one of the many types auto-generated will be a client interface. Let’s call it IMyService. There will also be another auto-generated interface called something like IMyServiceChannel that implements IMyService and IDisposable. Use this abstraction in the rest of your client application. Since … Read more

SetWindowsHookEx failing in .NET 4.0 on 32-bit machine with “module not found”?

Yup, I think you understand what’s going on. SetWindowsHookEx() requires a valid module handle, and verifies it, but it doesn’t actually use it when you set a low-level hook. You just need a valid handle, it doesn’t matter which specific one. Calling LoadLibrary(“user32.dll”) is a good way to get a handle, that DLL will always … Read more

Store Dictionary in application settings

You can use this class derived from StringDictionary. To be useful for application settings it implements IXmlSerializable. Or you can use similar approach to implement your own XmlSerializable class. public class SerializableStringDictionary : System.Collections.Specialized.StringDictionary, System.Xml.Serialization.IXmlSerializable { public System.Xml.Schema.XmlSchema GetSchema() { return null; } public void ReadXml(System.Xml.XmlReader reader) { while (reader.Read() && !(reader.NodeType == System.Xml.XmlNodeType.EndElement && … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)