.net-4.0

Class library usable by both .NET 3.5 (2.0?) and 4.0 applications?

I am starting a new class project, and I'd like for it to be usable by both .NET 3.5 and 4.0 projects. If I build it for .NET 3.5, do I need to do anything beyond that? Will it be safely usable by .NET 4.0 projects without having to be compiled for it? Are there any incompatibilities? I know that, as an example, .NET 1.1 was supposed to...

Typed configuration data in a separate config file in ASP.Net 4.0?

I have an asp.net 4.0 web application. I need extensive configuration data for this web application, that is strongly typed and the structure of this configuration data is going to be fairly complex (cannot do with key-value pairs). In the past I remember having done this in .Net 2.0 but cannot figure out how I will do it in .Net 4.0. T...

Index out of range exception when using Parallel for loop

I am trying to execute the following code and I keep getting an Index out of range exception when trying to assign array values to the list:- int[] array = new int[1000000]; for (int i = 0; i < array.Length; i++) { array[i] = i; } List<int> list = new List<int>(); Parallel.For...

Performing a type of union of two IEnumerable collections

Let's say you have two collections of integers: IEnumerable<int> col1=new List<int> {2,3,3,5,7,11,11,11,13}; IEnumerable<int> col2=new List<int> {5,7,7,7,11,19}; Now I would like to create a third collection, col3, such that for every distinct element that appears in either col1 or col2, col3 will contain that element with at least as...

MSpec in Visual Studio 2010 still does not work properly

Someone asked a similar question before, getting the following error when I run MSpec in Visual Studio 2010: Could not load file or assembly 'Machine.Specifications.dll' or one of its dependencies. The system cannot find the file specified. The solution in the other post was to download the .net4 specific version of MSpec. But, that'...

Cruise Control .NET, .NET 4.0, WS 2008 R2, NUnit seems to require COMPLUS_Version ?

Trying to configure NUnit 2.5.8.10295 in Cruise Control.NET on Windows Server 2008 R2, .NET 4.0, my NUnit task times out, and nunit-agent.exe seems stuck running. It works fine from the command line. The only solution I've found is to define the environment variable COMPLUS_Version. Is there a better solution to this problem? C:...

C# .net 4 charting development in Visual Studio 2008

Hi, A previous user of my old computer had managed to develop charting controls in a c# project using Visual Studio 2008. Now, the computer has been replaced and I can no longer do this. I have read that .net 4 is incompatible with VS2008 - but then I know that the charting was working before. Does anyone have any ideas how this prob...

why does (sender,e) => SomeAction() works on winforms and not in asp.net

Hello, I have the following code: btnTest.Click += (sender,e) => SomeAction() why does this code works in WinForms and not in asp.net. In asp.net I had to do the following: btnTest.Click += new EventHandler(SomeAction); target framework in both cases is .net 4.0 ...

Mixed mode assembly is built against version 'v1.1.4322'

Hello! i've included a directX player in c# .net 4.0 app that is included here ( answer2 ) . The problem is that when i try to initialize the object ( i.e. Player mPlayer=new Player()) this error occurs : Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional co...

C# Method which may execute any code in the loop

For example if i have to type something like that multiple time, is there any way to put this loop in the method with parameters like LoopMethod(Code lines, int count) for (int i = 0; i <= 1000; i++) { code line 1; code line 2; ... code line N; } for (int i...

Need a sample of single producer / single consumer pattern with .NET 4.0 new features

.NET for added new concurrency features under System.Collection.Concurrent and some synchronization classes. Is there any good sample for single producer - single consumer pattern using these feature ? (Actually I will add a circular buffer pattern to it if it already doesn't implement it as the shared buffer) ...

How to set the maxAllowedContentLength to 500MB while running on IIS7?

I changed the maxAllowedContentLength to <security> <requestFiltering> <requestLimits maxAllowedContentLength="5024000000" /> </requestFiltering> </security> In my web.config, but when running on IIS7 I get this error: The 'maxAllowedContentLength' attribute is invalid. Not a valid unsigned integer but when I ...

WPF: Add a dropshadow effect to an element from code-behind

I thought this would be something simple but so far i found nothing. How do you do it? ...

LINQ to XML and DataGridView

Hi I’m trying to use a DataGridView for the first time and with LINQ. Here’s what I’m trying to do: I want to use it (although it doesn’t have to the DataGridView ) to read and display the contents of an XML file (this bit is working code below) but I want to have an add row button on the form or in the DataGridView that takes the conte...

What advantages does one big database query have over many small ones

I inherited the app and what it does is get data from 4 views with an (xml file in it) in chunks of 1000 records then writes them down in an xml file all this split up by a type parameter that has 9 different possibilities. That means in a worst case there will be 36 connections to the database for each 1000 of that type/view combination...

Visual Studio 2010 ASP.NET 4.0 WebForms Routing Not Working in IDE Debug Mode

Greetings, I am using Visual Studio 2010 and ASP.NET 4.0 to build a WebForms project that uses the new routing features in System.Web.Routing. When I build my solution and run it from within VS.NET's debugging environment only routes with RouteUrl's that include a ".aspx" extension are being properly routed to the PhysicalFile. It app...

Enum Intellisense Display Attribute??

I want to do this: enum Foo { [Display="Item One"] ItemOne, } So that Intellisense will display it like in the attribute instead of the actual name. I know it's possible, I've seen it before. ...

Enabling and disabling CDN via ScriptManager

I want to use the Microsoft's CDN for hosting the AJAX Library for my .NET 4.0 web application. However, I was asked to implement a fallback for when the CDN isn't available or when developers want to develop locally without internet. In these scenarios the ScriptManager should send the locally hosted copies rather than the CDN copies ...

Based on a declared constraint, the navigation property is required.

Hi! Im dealing with code first .NET 4 and i'm having trouble with a 1 to 1 relation. breifing of database: -POccurrence -Id -POccurrenceRiskAssessment -OccurrenceId in my class Poccurrence I have a property named RiskAsessment, of the type POccurrenceRiskAssessment. Not all POccurrences have riskassessments, so it needs to be null...

Dynamic tables from a stored procedure using Linq to Entities

Hi, I have a question about Entity Framework and Linq to Entities. My .NET version is 4.0. I'm refactoring the database access layer of an existing application, and I plan to use Linq to Entities (instead of today's DataReaders and SQL strings). The structure of the database cannot be altered. My problem comes from a stored procedure, ...