Wednesday, December 24, 2008

.NET Runtime version 2.0.50727.42 - Fatal Execution Engine Error (7C812AEB) (800703e9)

This error will not allow you to open VS 2005 IDE. All that will happen is you 'll see the VS2005 splash screen and then "puff" devenv.exe vanishes, and no trace of it in process manager too.

When I saw it for the first time, I lost my cool. I dinlt know what was happening and itr took me one full night to diagnose the problem and identify solution. But I have to acknowledge that it was fun doing that

First and foremost, be a developer and own the problem. Solution can come only when you know what the problem is. Seaching in google at this point won't help will not help as you don'w know what the problem is

Here are tips to identify the problem
1. Clear all the logs in Event Viewer (Application, Security, System). Control Panel -> Adminiutrative tools ->Event Viewer
2. Open Visual Studio
3. If it fails to open, check the log messages in Application, security and System section of event viewer

Now that you know the error, you can hunt for it in google/MSDN/Microsoft's website
If the error you see in the system is

".NET Runtime version 2.0.50727.42 - Fatal Execution Engine Error (7C812AEB) (800703e9)"
Here are somethings that you can try to resolve it
1. uninstall the .NET Framework 2.0 security hot"fix" 922770.
Check if VS 2005 is alright - If yes, you are all set
2. Uninstall Visual Studio 2005 Extensions for Windows Workflow Foundation
Check if VS 2005 is alright - If yes, you are all set
3. Reinstall Visual Studio 2005 Extensions for Windows Workflow Foundation
Check if VS 2005 is alright - If yes, you are all set

Visual Studio 2005 Extensions WCF, WPF

I had heck of a time installing Visual studio 2005 extensions for WPF, WCF

To go through the installation process without any issues follow process mentioned by Microsoft with some tricks. Strictly follow the order of installation/uninstallation suggested by Microsoft

If you have any higher version of .NET installed in your system, I'm sure you are going to have fun time.

Visual Studio 2005 already installed with .NET Framework 2.0, then all that you need to do it install .NET Framework 3.0 and/or .NET Framework 3.0 SP1, I believe it will be dotnetfx30SP1setup.exe or dotnetfx3setup.exe

Install VS 2005 Entension for WCF - vsextwfx.msi

One of the common problem/error people received is
"Setup has detected that a prereqisite is missing. To use Visual Studio 2005 Extension for .NET Framework 3.0(WCF, WPF), November 2006 CTP, you must have .NET Framework 3.0 runtime installed. Please install .NET Framework 3.0 runtime and restart setup."

This problem could be because, you do not have .NET Framework 3.0 installed - In this case first install .NET 3.0 and then continue
If you haad installed .NET Framework 3.0 SP1 and you still receive this error, don't fret. This is Microsoft BUG. Visual Studio 2005 Extension for .NET Framework 3.0 Installer is not able to understand .NET 3.0 SP1 as .NET 3.0. to get rid of the issue, you have to manually say to the installer that you already have right version of .NET Framework.

Here are the steps to do it
1. Open command prompt
2. Browse to the directory that contains the installer vsextwfx.msi
3. Execute msiexec /i vsextwfx.msi WRC_INSTALLED_OVERRIDE=1
4. You'll receive a couple of message boxes, click OK.
5. It'll take a while for installation
6. Restart, and you are all set

Tuesday, December 16, 2008

Business delegate pattern

Step 1

Create the following directories in your web/windows application (within App_Code directory).
1. business
2. common
3. services
4. delegates

Step 2

Let’s presume that you are working on a Project named “sample” and you have decided to use Business-Delegate model for it. To test the feasibility of the pattern, let’s take Invoice module. This module can have variety of sub-modules, like add, get, set, list, update, delete, save etc. For now let’s implement “Save” method

Step 3

Create a file IInvoice.cs in common folder

namespace Sample.common
{
public interface IInvoice
{
int Save();
}
}

Step 4

Create a file Invoice.cs in service folder with the following contents

Using Sample.common;
namespace Sample.services
{
public class Invoice : IInvoice
{
public Invoice()
{
}
public int Save()
{
return 0;
}
}
}

Step 5

Save this file as ServiceLocator.cs in delegate directory

Using Sample.common;
Using Sample.service;

namespace Sample.delegates
{
public class ServiceLocator
{
public ServiceLocator()
{
}
public IInvoice getInvoice()
{
return new Invoice();
}
}
}

Step 6

Save the following contents as BusinessDelegate.cs in the directory business

Using Sample.delegate;

namespace Sample.business
{
public class BusinessDelegate
{
private ServiceLocator sLocator;
public BusinessDelegate()
{
sLocator = new ServiceLocator();
}
//you can have a cutom name for this function
public int Save()
{
return sLocator.getInvoice().Save();
}
}
}

Step 7

You are all set to use this from your view

Using sample.business;
Public button_save_click(object sender, EventArgs e)
{
BusinessDelegate bDelegate = new BusinessDelegate();
bDelegate.Save();
}

If you wish to add additional functionalities like add, list…then you add them to you IInvoice interface, and Invoice class. Create a new method for invocation in BusinessDelegate and ServiceLocator class

Sunday, December 7, 2008

Page Controller


Let’s say in every page we need to get username and email ID, there are 2 ways we can do it. We could use file include (.inc files) or use page cotroller logic

SiteSettings has 2 properties, Name and Email ID. You can have your own logic to fetch information from database – may be use Table data gateway logic


SiteSettings.cs


using System;

using System.Data;

using System.Configuration;

///

/// Summary description for SiteSettings

///

public class SiteSettings

{

public SiteSettings()

{

}

private string _name;

public string Name

{

get { return _name; }

set { _name = value; }

}

private string _emailAddress;

public string EmailAddress

{

get { return _emailAddress; }

set { _emailAddress = value; }

}

#region Load functions

public void FetchData()

{

//implement your logic to fetch data from config file, DB or other datasources

_name = "xyz";

_emailAddress = "xyz@abc.com";

}

#endregion

}


Create a new BasePage class derived from System.Web.UI.Page. Create an event for ‘Init’ . In the event, load SiteSettings values


BasePage.cs


using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

///

/// Summary description for BasePage

///

public class BasePage : Page

{

protected SiteSettings siteSettings;

public BasePage()

{

Init += new EventHandler(BasePage_Init);

}

void BasePage_Init(object sender, EventArgs e)

{

siteSettings = new SiteSettings();

siteSettings.FetchData();

}

}

Now that we have the base class let’s implement BasePage


Page1.cs


using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Page1 : BasePage

{

protected override void OnInit(EventArgs e)

{

base.OnInit(e);

this.Load += new EventHandler(Page_Load);

}

//protected System.Web.UI.WebControls.Label pageNumber;

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

DisplaySettings();

}

pageNumber.Text = "2";

}

private void DisplaySettings()

{

eMail.Text = siteSettings.EmailAddress;

userName.Text = siteSettings.Name;

}

}