.net-4.5

Using IReadOnlyCollection<T> instead of IEnumerable<T> for parameters to avoid possible multiple enumeration

你说的曾经没有我的故事 提交于 2019-12-19 05:35:08
问题 My question is related to this one concerning the use of IEnumerable<T> vs IReadOnlyCollection<T> . I too have always used IEnumerable<T> to expose collections as both return types and parameters because it benefits from being both immutable and lazily executed. However, I am becoming increasingly concerned about the proliferation of places in my code where I must enumerate a parameter to avoid the possible multiple enumeration warning that ReSharper gives. I understand why ReSharper suggests

Using IReadOnlyCollection<T> instead of IEnumerable<T> for parameters to avoid possible multiple enumeration

耗尽温柔 提交于 2019-12-19 05:35:08
问题 My question is related to this one concerning the use of IEnumerable<T> vs IReadOnlyCollection<T> . I too have always used IEnumerable<T> to expose collections as both return types and parameters because it benefits from being both immutable and lazily executed. However, I am becoming increasingly concerned about the proliferation of places in my code where I must enumerate a parameter to avoid the possible multiple enumeration warning that ReSharper gives. I understand why ReSharper suggests

Cannot find `ZipArchive` in the “System.IO.Compression” namespace

风流意气都作罢 提交于 2019-12-19 05:16:24
问题 My question is related to I didn't find "ZipFile" class in the "System.IO.Compression" namespace But I have referenced the DLL's for my 4.5.1 webforms project: Properties of my project give me: Target framework: .Net Framework 4.5.1. and the web.config: <compilation debug="true" targetFramework="4.5" /> What am I missing? The solution was to manually reference the assemblies in the web.config But why? Why wasn't the checkbox in the add reference dialog insufficient? <assemblies> <add assembly

Disposing of FileSystemWatcher

孤人 提交于 2019-12-19 04:10:00
问题 So my understanding is that whenever using a class that implements IDisposable, it's parent also needs to implement IDisposable interface. (FileWatcher using FileSystemWatcher) So when using FileSystemWatcher what is the proper way of disposing of FileSystemWatcher? I want FileWatcher not to be disposed/(watching) until application is closed. Would I use Responsible Owner Pattern?(try/finally) or something else? Should my FileWatcher also implement IDisposable? I won't be able to use using{}

EPPlus save two million rows with 200+ columns datatable to multiple excel files

隐身守侯 提交于 2019-12-19 04:09:29
问题 I have function that saves all records from SQL table to excel worksheet using EPPlus. If I export small amount of data everything works fine, but with 200+ columns and 500 000+ rows I get OutOfMemory exception. I'd like to modify my code in a way to be able to save 50 000 records per file. Here is my code that works for small data: private Task SaveAsync(string tableName) { return Task.Run(() => { try { using (var conn = new SqlConnection(_connectionString)) { using (var cmd = new SqlCommand

Are the SmtpClient.SendMailAsync methods Thread Safe?

亡梦爱人 提交于 2019-12-19 03:22:15
问题 The SmtpClient Class states that instance members are not thread safe. This can be seen if concurrent calls are made to Send or SendAsync. Both methods will throw a InvalidOperationException on the second call if the first has not yet completed. The method SendMailAsync, introduced in .NET 4.5, does not list InvalidOperationException as a thrown exception. Do the new .NET 4.5 methods implement some sort of queuing? Reflector isn't able to shed any light on the implementation details of this

Are there technical reasons EF 5 isn't fully supported on .NET4.0?

北战南征 提交于 2019-12-18 20:49:29
问题 I wanted to upgrade my app to EF 5 to take advantage of features like support for enum spatial etc. However, I was not able to upgrade unless I move to .Net 4.5. I would like to know what features of .Net 4.5 does EF 5 use that it can not be done in .Net 4.0? 回答1: My understanding is that EF >= 4.1 (including EF 5) consists of the EF "core libraries" like ( System.Data.Entity.dll ) which are part of the .NET Framework the additional package/assembly you can download via Nuget which contains

Why HashSet<T> does not implement IReadOnlyCollection<T>?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 18:53:47
问题 I've just found that .NET Fx now has 3 useful interfaces: IReadOnlyCollection<T> IReadOnlyList<T> IReadOnlyDictionary<K,V> And I'm bit confused why HashSet<T> do not implement IReadOnlyCollection<T> ? Are there any reasons, or Microsoft just forgot about sets again? UPD After two-hours googling I've found that there are many collections in BCL which has .Count property but do not implement IReadOnlyCollection<T> interface. UPD2 I've found this post http://social.msdn.microsoft.com/Forums/en

Installing Visual Studio 2012 Ultimate on Windows 8

China☆狼群 提交于 2019-12-18 18:49:11
问题 While trying to install the visual studio 2012 ultimate trial on Windows 8 Release Preview I got the following error message The .Net Framework installed on this machine does not meet the minimum required version: 4.5.50709. So I tried installing the required .net framework version, but that gave me the following error Microsoft .NET Framework 4.5 is already a part of this operating system. You do not need to install the .NET Framework 4.5 redistributable. I am running the windows 8 release

Cannot have two operations in the same contract with the same name (Async & Non)

那年仲夏 提交于 2019-12-18 14:15:04
问题 I get the following exception (Cannot have two operations in the same contract with the same name, methods ExecuteAsync and Execute) when the following service is activated. [ServiceContract] public interface IMyService { [OperationContract] byte[] Execute(MyRequest request); [OperationContract] Task<byte[]> ExecuteAsync(MyRequest request); } I guess this makes sense if you are using the svcutil.exe to create your service reference, because the task-based operations are created automatically