.net-4.0

How to distribute both 32 and 64 bit versions of the library

倖福魔咒の 提交于 2019-12-04 01:17:42
I have a C# library that is called by various clients (both 32-bit and 64-bit). Up to now it was compiled as AnyCPU, so there was no issues. Recently I added a dependency to SQLite .NET library which come in both 32 and 64-bit flavors (but not AnyCPU). So, now, I have to have 2 builds - for both bitnesses. In the past, I've seen other libraries (MS SQL Compact comes to mind) that had a scheme where a single .NET assembly would have Private\amd64 and Private\x86 folders in the folders with the appropriate native libraries in them and it would call each one as necessary. Is this approach viable

How to empty a BlockingCollection

南楼画角 提交于 2019-12-04 01:09:58
I have a thread adding items to a BlockingCollection . On another thread I am using foreach (var item in myCollection.GetConsumingEnumerable()) If there is a problem I want to break out of my foreach and my method and clear whatever is left in the BlockingCollection however I can't find a way to do it. Any ideas? Jon Skeet Possibly use the overload of GetConsumingEnumerable that takes a CancellationToken ; then, if anything goes wrong from the producing side, it can cancel the consumer. I'm using this extension method: public static void Clear<T>(this BlockingCollection<T> blockingCollection)

What is the scope of StaticResource within a WPF ResourceDictionary?

左心房为你撑大大i 提交于 2019-12-04 01:04:51
I have a WPF ResourceDictionary with the following TextBlock: <TextBlock Visibility="{Binding Converter={StaticResource MyBoolProp ResourceKey=BoolToVis}}"> </TextBlock> The ResourceDictionary is included in App.xaml under MergedDictionaries: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MyResourceDictionary.xaml"/> Within the App.xaml I have defined the BoolToVis converter (again, under Application.Resources ) <BooleanToVisibilityConverter x:Key="BoolToVis" /> When I start my app up - I get the following XamlParseException:

What .NET 4.5 (or earlier) higher-level constructs make Threading easier?

余生颓废 提交于 2019-12-04 01:02:19
Delegates are a few of the objects that make threading easier in .NET reference . They can be used to asynchronously invoke a method. What other objects exist in framework 4.5 (or earlier) that make the use of threads easier or less error prone? What are the other abstractions make concurrency and multithreading easier? Note: This question updates this . I tend to answer a lot of questions related to multithreading and I often see the same basic question asked in various different ways. I will present the most common problems as I have seen them over the years and explain how the newer

How should I disable Entity Framework table reference(foreign) list from each objects?

偶尔善良 提交于 2019-12-04 01:01:17
问题 I'm using Sqlite database and System.Data.SQLite 1.0.92 There is 2 table here: Table Person : PersonId PersonName Table Student : StudentId PersonId(reference table Person FK) StudentNo Now every time I get the Persons Collection in EF5: using (var ctx = new myEntities) { AllPersons = ctx.Persons.ToList(); } There is also has AllPersons.student collection will include in the result; But I don't need it. Of course that's just an example, There is a lot of big table has so many references, it

Using Entity Framework 4.0 in a .Net 3.5 Application [duplicate]

混江龙づ霸主 提交于 2019-12-04 00:44:05
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Using EF 4 on .NET 3.5 SP1 Is it possible to use Entity Framework v4.0 in a .NET 3.5 application? I mean, can i just reference the related assemblies for EF 4.0 and use it in my .NET 3.5 application? Thanks. 回答1: No, the EF 4.0 uses the .NET 4.0 framework, which is newer and completely separate from the .NET 3.5 framework. 来源: https://stackoverflow.com/questions/2876887/using-entity-framework-4-0-in-a-net-3-5

Doesn't .NET 4.0 contain .NET 2.0?

帅比萌擦擦* 提交于 2019-12-04 00:38:08
I've encountered a strange problem. I've installed "Visual Studio 2010 ultimate". While installing it showed that it sucessfully installed .NET 4.0. While installing some other softwares. They complain that .NET 2.0 is missing and asking me to install it. How is it possible? .NET 4.0 must include .NET 2.0 right? EDIT: Now, I'm confused. According to this http://en.wikipedia.org/wiki/File:DotNet.svg CLR is part of .NET 2.0. Installing .NET framework 4.0 implies installing the entire stack. which also includes a .NET 2.0. Please clear this confusion. No. .NET 4.0 is a standalone CLR, it is NOT

UnauthorizedAccessException on MemoryMappedFile in C# 4

久未见 提交于 2019-12-04 00:28:51
问题 I wanted to play around with using a MemoryMappedFile to access an existing binary file. If this even at all possible or am I a crazy person? The idea would be to map the existing binary file directly to memory for some preferably higher-speed operations. Or to atleast see how these things worked. using System.IO.MemoryMappedFiles; System.IO.FileInfo fi = new System.IO.FileInfo(@"C:\testparsercap.pcap"); MemoryMappedFileSecurity sec = new MemoryMappedFileSecurity(); System.IO.FileStream file

C# to VB.NET syntax conversion for class instantiation with properties

北城以北 提交于 2019-12-04 00:28:48
问题 I am working with Workflow Foundations 4 (in C#) and am trying to write a VB.NET expression. Is there a way to do the following in VB.NET on one line? SomeObj instance = new SomeObj() { SomeStringProp = "a", SomeIntProp = 17 }; 回答1: Here's an example: Dim instance = new SomeObj() With { .ISomeStringProp = "a", .SomeIntProp = 17 } If you want more info take a look at VB.NET 9.0: Object and Array Initializers . 来源: https://stackoverflow.com/questions/3936224/c-sharp-to-vb-net-syntax-conversion

Does Parallel.ForEach require AsParallel()

天大地大妈咪最大 提交于 2019-12-04 00:22:47
ParallelEnumerable has a static member AsParallel . If I have an IEnumerable<T> and want to use Parallel.ForEach does that imply that I should always be using AsParallel ? e.g. Are both of these correct (everything else being equal)? without AsParallel : List<string> list = new List<string>(); Parallel.ForEach<string>(GetFileList().Where(file => reader.Match(file)), f => list.Add(f)); or with AsParallel ? List<string> list = new List<string>(); Parallel.ForEach<string>(GetFileList().Where(file => reader.Match(file)).AsParallel(), f => list.Add(f)); It depends on what's being called, they are