.net-4.0

How to find out field maximum length in Entity Framework in .NET 4?

According to this question, there's no built-in way in EF v1 to figure out the length of a field. Is there a built-in way to do so in the Entity Framework that ships with .NET 4, if so - how? ...

How can I convert this linq.expression from C# to VB?

[QueryInterceptor("Somethings")] public Expression<Func<Something, bool>> OnSomethings() { // Code here } I had a view guesses, looked on msdn, but there are no examples matching the way that that is used. Ideas? ...

How does Entity Framework 4.0 determine which parameters are required for the factory method of an entity ?

Hi, I am working with Entity Framework 4.0 (VS 2010 Beta 2, NOT RC). I can model the EDM and produce the required database. When I ask VS to generate the code for the model, it generates the expected .designer.cs file. When I look at the factory methods for each entity that the designer has generated, I've noticed that it doesn't inc...

Breaking changes in .NET 4.0

There is a lot of information about new features and classes in new 4.0 however there are also changes that may affect existing applications, for example Timespan now implements IFormattable and old string.Format() with invalid options will throw exception instead of calling simple ToString(). However, CLR team provides a nice feature ...

Rehosting Workflow 4 Designer adding foreach activity to toolbox

I am using the designer rehosting samples and am trying to put the generic types into the toolbox, however I can't seem to make it work. I've tried XAML based: <sapt:ToolboxItemWrapper AssemblyName="{StaticResource AssemblyName}"> <sapt:ToolboxItemWrapper.ToolName> System.Activities.Statements.ForEach </sapt:ToolboxIte...

How should I handle this Optimistic Concurrency error in this Entity Framework code, I have?

Hi folks, I have the following pseduo code in some Repository Pattern project that uses EF4. public void Delete(int someId) { // 1. Load the entity for that Id. If there is none, then null. // 2. If entity != null, then DeleteObject(..); } Pretty simple but I'm getting a run-time error:- ConcurrencyException: Store, Update...

How do I upgrade an existing EDMX 1.0 model to the new EDMX 2.0?

I'd like to upgrade an existing EDMX model without having to regenerate it by hand. The database is old, contains virtually no foreign keys and has many tables that had to be merged into single entities. I would like to use the EDMX 2.0 that comes with Visual Studio 2010, but I do not want to recreate the model by hand as that would put ...

Why does adding a reference to project targeting .NET Framework 4.0 fail?

We have two projects that are both class libraries. Project 1 is a VS 2008 project and targets the .NET Framework 3.5. Project 2 is a VS 2010 (release candidate) project that targets the .NET Framework 4.0. When I try to add a reference to Project 2 in Project 1, it fails with a less than informative error message. I know that if I chang...

Windows Live Writer plugin with .NET 4

Has anyone written a plugin for Windows Live Writer that runs against .NET 4? I've read the .NET 4 introduces side-by-side running, so one part of the app can target .NET x and another part can target .NET 4. I thought WLW would be a good starting point to try this as previously it only supported plugins up to .NET 2. But my .NET 4 pl...

Unity The parameter host could not be resolved when attempting to call constructor

When I attempt to instantiate my instance of the base class I get the error: a ResolutionFailedException with roughly the following error "The parameter host could not be resolved when attempting to call constructor" I'm currently not using an Interface for the base type and my instance of the class is inheriting the base type class. ...

This 404 seems unavoidable - what am I doing wrong? [Ninject 2.0 with ASP.NET MVC 2 on .NET 4]

I downloaded the fairly new Ninject 2.0 and Ninject.Web.Mvc (targeting mvc2) sources today, and successfully built them against .NET 4 (release configuration). When trying to run an application using Ninject 2.0, i keep getting 404 errors and I can't figure out why. This is my global.asax.cs (slightly shortified, for brevity): using .....

Installing MSBuild 4.0 without Visual Studio 2010

I installed .NET 4.0 and VS 2010 RC on my laptop and MSBuild was automatically installed. I was hoping to build a continuous integration server by just installing the .NET SDK without VS 2010, so I downloaded the .NET 4.0 Framework from Microsoft at this link. Unfortunately, it doesn't appear to have installed MSBuild with this downloa...

.NET 4, how to execute dynamic vb code like windows workflow 4 does

Just curious how Windows Workflow 4 executes vb code. Can I use the same techique to execute vb.net code at run-time? ...

Is it possible to refactor this C# if(..) statement?

Hi folks, simple question :- i have the following simple if (..) statements :- if (foo == Animal.Cat || foo == Animal.Dog) { .. } if (baa == 1|| baa == 69) { .. } is it possible to refactor these into something like ... DISCLAIMER: I know this doesn't compile .. but this is sorta what i'm trying to get... if (foo == (Animal.Cat |...

Are you using CodeContracts? Do you knowabout any decent-sized project out there which uses is?

Are you using CodeContracts? Do you know about any decent-sized project out there which uses is? ...

ASP.NET MVC 2 with NServiceBus unable to load requested types

I am trying to use NServiceBus with an ASP.NET MVC 2 website (using VS 2010 and the .NET 4.0 framework). However, when I run the site on my local machine, I get the following error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Here are the relevant steps I have ta...

Good .net4 profiler

What is a good profiler for .NET 4.0? I'm willing to spend some money, but not too much (say up to £50) I'm developing games for windows phone and xbox using XNA, which means that the projects are commercial. I mention it because I've seen several which are free for non commercial use. Extra points for Visual studio integration. Nb. I...

Difference between background and concurrent garbage collection?

I read that with .NET Framework 4 the current garbage collection implementation is replaced: The .NET Framework 4 provides background garbage collection. This feature replaces concurrent garbage collection in previous versions and provides better performance. At this page there is an explanation how it works but I am not su...

How to specify generic method type parameters partly

I have an extension method like below: public static T GetValueAs<T, R>(this IDictionary<string, R> dictionary, string fieldName) where T : R { R value; if (!dictionary.TryGetValue(fieldName, out value)) return default(T); return (T)value; } Currently, I can use it in the following way: var dictionary = n...

NServiceBus FullDuplex sample compiled and debugging against .NET 4.0 framework throws exception

I just installed VS2010 RC and launched the FullDuplex sample from NServiceBus 2.0.0.1145 and it ran fine. I then changed the target framework of each project in the solution to ".NET Framework 4", recompiled and launched in the debugger and received the following exception: System.InvalidOperationException was unhandled Message=No e...