Error Message
Running an application from Visual Studio 2005 or 2008 on 64-bit computers, displays the following error message:
"Error : Class not registered(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)"
Cause
When running a Visual Studio application, the default Common Language Runtime (CLR) platform in the Visual Studio is set to Any CPU. This default must be changed on 64-bit computers to compile the assemblies with the 32-bit, x86 compatible CLR.
Solution or Workaround
Change the default Platform Target CPU to allow applications to run on 64-bit machines.
If working in Microsoft Visual Studio:
- Right-click on the solution in the Visual Studio Solution Explorer and open the Properties window.
- Click the compile tab: Visual Basic, or the build tab: Visual C#.
- For Visual Basic, click the Advanced tab.
- Select x86 as the Target CPU (Visual Basic) or Platform Target (Visual C#).
- Rebuild the solution.
If working in Microsoft Visual Basic or Visual C# Express Editions:
- Open the solution in the Express Edition.
- File > Save All, and save the project to a different location.
- Using Windows Explorer, browse to the newly saved project, and open the project file (.csproj or .vbproj) with a text editor.
- Insert the text <PlatformTarget>x86</PlatformTarget> into the 'Debug|AnyCPU' and 'Release|AnyCPU' sections.
- Save the project file.
- Open the solution in the Express Edition, and build and run the application.