Could not load file or assembly ‘PresentationCore’ or one of its dependencies. An attempt was made to load a program with an incorrect format. : A solution

Few days back, I was migrating my application for VS2008 to VS2010 and it was done successfully except  some people started running the application. They faced the error as below

Could not load file or assembly ‘PresentationCore’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

I tried to diagnose the problem and tried to find a solution.<!–more Continue reading… –>

So whenever you  upgrade to VS 2008 to VS 2010 and also upgrade ASP.NET version to 4.0. And if your website hosted on IIS, when you open your VS 2010 IDE it prompt a message asking to upgrade to asp.net version to 4.0. When you say yes it upgrades the version at IIS.

So let’s come back to our original problem. When I diagnosed I found the machine was having 64bit OS.

And at IIS, there is setting “Enable 32-bit Applications” at application pool level that is by default set false . So if you are having 64 bit OS and your application target 32-bit applications then this property must be true.

So how to set it. I have included the images for IIS7.  So first you need to know, which application pool your virtual directory points. So to check this

Goto -> cmd prompt -> type inetmgr -> click on your virtual directory and click on basic settings

Basic settingsNow you can see the Red oval that that is the name of Application pool set for this directory.

Now click on Application pool-> Click on DefaultAppPool -> and click on Advance settings.

App pool advance settings

Here you can see Red oval, I have set Enable 32-bit Applications to true.  Now restart the IIS.

Now run your application and it must be working.

Cheers,

Brij

ASP.NET: Asynchronous Programming

Click here to download the sample code

Introduction:

Have you ever tried using Async pages in asp.net? Did you ever explore it in
respect of ASP.NET?

If No. This is the article for you. In this, I will be discussing, what is Async
programming? what are the benefits? Async in respect of ASP.NET and its uses
and lots more.

Async programming:

In a literal meaning, Asynchronous operation means that a process operates independently of other processes. If there are multiple operations, All that can be handled different processes/thread without waiting to complete the other ones. So here in coming sections, we will be discussing, how Asynchronous programming comes into the picture in ASP.NET.

Async Programming in ASP.NET:

Normally the kind of websites that we make are not scalable enough that could have been. These websites are very limited and confined. ASP.NET provides us a way to develop our websites more scalable. Continue reading…

Error While Serailize/De-Serailize DateTime in JSON format : A Solution

Sometimes back, I was working on one my modules in my application. Here I had an of a Class which has some properties of DateTime type. Actually I was serializing the object using JavaScriptSerializer to serialize it in JSON format but later could not be able to deserialize it again.

So I thought of digging deep to this problem. So  I will be discussing it with an example. Let’s have a class Continue reading…