Why doesn’t generic ICollection implement IReadOnlyCollection in .NET 4.5?

There are probably several reasons. Here are some: Huge backwards compatibility problems How would you write the definition of ICollection<T>? This looks natural: interface ICollection<T> : IReadOnlyCollection<T> { int Count { get; } } But it has a problem, because IReadOnlyCollection<T> also declares a Count property (the compiler will issue a warning here). Apart from … Read more

Which versions of SSL/TLS does System.Net.WebRequest support?

When using System.Net.WebRequest your application will negotiate with the server to determine the highest TLS version that both your application and the server support, and use this. You can see more details on how this works here: http://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_handshake If the server doesn’t support TLS it will fallback to SSL, therefore it could potentially fallback to … Read more

Differences between .NET 4.0 and .NET 4.5 in High level in .NET

What is new in .NET Framework 4.5 & What’s new and expected in .NET Framework 4.5: Support for Windows Runtime Support for Metro Style Applications Support for Async Programming Garbage Collector Improvements Faster ASP.NET Startup Better Data Access Support WebSockets Support Workflow Support – BCL Support differences in ASP.NET in these frameworks Compare What’s New … Read more

What does the Microsoft.Bcl.Build NuGet package do?

From looking at Microsoft.Bcl.Build.targets, it has a bunch of project configuration targets, eg: EnsureBindingRedirects – Determine which references are opted in for binding redirects, and update the app.config with them BclBuildValidateNugetPackageReferences – This target validates that any Nuget packages installed in the current project also have their dependencies (transitive dependencies) installed in the current project. … Read more

SignalR Typenamehandling

This can be done by taking advantage of the fact that your types and the SignalR types are in different assemblies. The idea is to create a JsonConverter that applies to all types from your assemblies. When a type from one of your assemblies is first encountered in the object graph (possibly as the root … Read more

Getting System.Net.Mail.MailMessage as a MemoryStream in .NET 4.5 beta

Managed to figure out how to get this working again in .NET 4.5 beta. The private API Send() method in MailMessage has changed to: internal void Send(BaseWriter writer, bool sendEnvelope, bool allowUnicode) Please find updated code below. Assembly assembly = typeof(SmtpClient).Assembly; Type mailWriterType = assembly.GetType(“System.Net.Mail.MailWriter”); using (MemoryStream stream = new MemoryStream()) { ConstructorInfo mailWriterContructor = … Read more

Create zip file from byte[]

After a little more playing around and reading I was able to figure this out. Here is how you can create a zip file (archive) with multiple files without writing any temporary data to disk: using (var compressedFileStream = new MemoryStream()) { //Create an archive and store the stream in memory. using (var zipArchive = … Read more

tech