.net-4.0

ADO.NET Data Service doesn't Update

Hi I've a problem updating objects with the ADO.NET Data Services. First I've create a service, which can load and store the data. Its a basic data context which implements the IUpdatable-interface. After that, I've created a simple service-client. I just created it with the 'Add Service'-reference in Visual Studio. Basically this se...

add handler by reflection using EventArg inheritance

In .Net 4 this code run with no error class A { public event EventHandler<CustomEventArgs> MyEvent; } where CustomEventArgs derived from EventArgs void Test() { A a = new A(); a.MyEvent += MyFunc; } void MyFunc(object sender, EventArgs args) // EventArgs expect of CustomEventArgs { } Now, when I try to do the same by reflect...

Queue<T> DataContractJsonSerialization in Silverlight 4.0

Can anyone serialize a Queue using the DataContractJsonSerializer in Silverlight 4.0 ? Here is some example code that throws. If not what additional collections can not be serialized using the Json Serializer ? public String Serialize() { String jsonString = String.Empty; using (MemoryStream s = new MemoryStream(...

Event firing a event.

I have a object that is a private in my class. If that object fires a event I want to pass the event on to whatever is using my class. Currently I do it this way, I put in my constructor: cbName.CheckedChanged += ((sender, args) => this.CheckChanged(this,args)); Is there a better way to do this, and are there any gotchas like the clas...

Can you use a ConcurrentDictionary for one-to-many mapping?

I have a mapping where each key could have multiple associated values. I thought that a ConcurrentDictionary might help me more easily code this map for use in a multithreaded environment, but the methods seem to be built around a single value. I see that AddOrUpdate() lets me modify the value if it already exists, but it doesn't guarant...

How do I take a lambda expression as a parameter that returns a method?

I want to be able to do this: var test = SomeMethod(s => s.SomeMethod); I can make it work with properties by making the method signature look like this: SomeMethod<TProperty>(Expression<Func<T, TProperty>> expression) How can I make it work with methods? I know this is simple, I'm just missing something small. ...

My C# app is asking my users to install .net 4 - target framework in my project is 2.0??

I set my target framework in my project properties to .net 2.0 A user running windows 7 is still being prompted to install .net 4... why? ...

ASP.NET 4.0: How do I fix the "'compilerVersion' " IIS error?

System.Configuration.ConfigurationErrorsException: The value for the 'compilerVersion' attribute in the provider options must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET Framework. ...

C#: Compiler optimizations of anonymous types

OK OK, I know this is a hack, but this was for a tiny data-manipulation project and I wanted to play around. ;-) I was always under the impression that the compiler would examine all anonymous types used in a C# program and if the properties were the same, it would only create one class behind the scenes. So let's say I want to create ...

ObjectSet query not returning added EntityObject until SaveChanges() called

I think I'm missing something very simple here. I have an EF4 ObjectContext that contains an ObjectSet of type Thing, which is mapped to a table in my database called Things. If I add a Thing to the Things ObjectSet, that Thing is not visible in Things until I call SaveChanges() on the ObjectContext. So, in the following test fixt...

Strange issue with the VS2010 debugger

Hi, I've installed visual studio 2010. When unhandled exception is thrown, nothing happen... I created new windows form application and wrote 1 line in the form_load function: private void Form1_Load(object sender, EventArgs e) { throw new Exception(""); } And still nothing happen. The only thing I can see is th...

Turn off page-level caching in a user control

I have a page with the following caching defined: <%@ OutputCache Duration="60" VaryByParam="None" %> I have a user control inside that page that i don't want cached. How can I turn it off just for that control? ...

Really tough one... Windows Service throws System.BadImageFormatException on server 2008, x64, .net 4 migrated from 3.5

I'm really hoping someone's seen this before, because I'm dying on this one. I have tried compiling the service exe as AnyCPU, x86, and x64 It works on my win 7 x64 box I'm installing with installutil, the .net 4 version When I start the service, I get an error. It says nothing, but does point to which modules are loaded. Those of ...

How do I see the c# code that caused a crashdump in clr.dll?

I have a Windows Forms application (.NET 4) that runs fine on my development machine but crashes on two other test machines. I can load the minidump that it creates in VS2010. Choosing to "Debug with Mixed" leads to apparently endless (I killed devenv after about 20 minutes) abuse of the CPU by Visual Studio. When I "Debug with Native ...

Why did the digit grouping and decimal separator change for en-ZA from .NET 3.5 to .NET 4.0?

We have code in our system to format numbers and currency according to the regional settings selected by the user. One of our users has selected en-ZA and noticed that the digit grouping and decimal separators have changed with our migration to .NET 4.0. I wrote a snippet of code to illustrate this change: using System; namespace regio...

is there a way to manually create the HttpSessionState object?

There's probably plenty of good reasons why you can't do this, but as work around for a donut caching issue I'm trying to figure out if there's a way i can manually instantiate the HttpSessionState object. Any ideas? ...

Task.Factory.StartNew() Taskscheduler parameter

see: TaskFactory When i want to make a task to be long-running and also to be cancellable, If i am calling this method from ui, how do i pass the taskscheduler parameter? ...

Where do I download these files from and what do I need exactly for AJAX 4.0

MicrosoftAjaxDataContext.js MicrosoftAjaxTemplates.js ...

ASP.NET MVC as a RESTful Service and TransactionScope.

Hi, I'm considering using the MVC 2 Framework as the primary service for a project I'm working on, currently, we're using a WCF based service which works well because I can wrap a TransactionScope on the client and make several calls and be sure that the transaction is successfully transferred to the service. Is that possible using the...

Button clip problem Silevrlight 4

I'm working on an interactive map. I'm using Silverlight 4 within VisualStudio 2010. My problem is that i can't assign a geometry to Button Clip property: Code: bouton1.Clip = (PathGeometry)Forme.Data; //forme is a class that inherits from Path when i run my application i get an ArgumentException: The value is not included in the...