Colin Pickard
Colin Pickard

Reputation: 46663

Visual Studio 2010 startup: "type initializer for '<Module>' threw an exception."

I'm working on a simple command line project. I changed the properties from .NET 3.5 to .NET 4.0 and restarted Visual Studio 2010. I get this error:

The type initializer for '<Module>' threw an exception.

The type initializer for 'Module' threw an exception.

and Visual Studio does not start.

I have tried starting with devenv.exe /SafeMode and devenv.exe /reset, which make no difference. Google is not helping me either.

Help!


EDIT: I still can't get Visual Studio to do anything. I tried installing SharpDevelop, but that also fails to start, but with a more informative error:

Unhandled exception terminated SharpDevelop Exception thrown: System.TypeInitializationException: The type initializer for 'ICSharpCode.Core.Presentation.MenuService' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load during appdomain initialization. ---> System.DllNotFoundException: C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\wpfgfx_v0400.dll ---> System.ComponentModel.Win32Exception: The specified module could not be found

I don't have .NET 4 at the path in the above error, I have a different version so it is installed at C:\Windows\Microsoft.NET\Framework\v4.0.30319

I have tried uninstalling .NET 4 and re-installing it, but it doesn't make either VS or #develop work, nor does it change the installation path.

Upvotes: 7

Views: 27819

Answers (7)

VisualNoob
VisualNoob

Reputation: 1

If the cause of the problem is the VB program itself not your project code, uninstall all of the frameworks on you computer using uninstaller programs to completely delete all registry and files related to all of these frameworks and components listed below:

VC 90 Runtime (x86)

VC 10.0 Runtime (x86)

VC 10,0 Runtime (x64)

Microsoft NET Framework 4

Microsoft Visual Studio 2010 ó4bit Prerequisites (x64)

Microsoft Visual F# 2.0 Runtime

Microsoft Visual Studio Macro Tools

TFS Object Model (x64)

.NET Framework 4 Multi-Targeting Pack

Microsoft Visual Studio 2010 Ultimate

Microsoft Web Deployment Tool (x64)

Microsoft ASP,NET MVC 2 - Visual Studio 2010 Tools

Microsoft ASPNET MVC 2

Microsoft Silverlight

Microsoft Silverlight 3 SDK

Microsoft Office Developer Tools (x64)

Dotfuscator Software Services - Community Edition

Crystal Reports templates for Visual Studio 2010

Microsoft SQL Server Compact 3.5 SP2 (x86) ENU

Microsoft SQL Server Compact 3.5 5P2 (x64) ENU

Visual Studio 2010 Tools for SQL Server Compact 3.5 5P2 ENU

Microsoft Sync Framework Runtime v1.0 (x64) ENU

Microsoft Sync Services for ADO.NET v2.0 (x64) ENU

Microsoft Sync Framework Services v1.0 (x64) ENU Microsoft Sync Framework SDK vl.0 (x64) ENU VC 10.0 Designtime (x64) Microsoft Visual Studio 2010 Performance Collection Tools (x64)

Microsoft Visual Studio 2010 IntelliTrace (x64)

Microsoft SQL Publishing Wizard 1.4

Microsoft SQL Server System CLR Types

Microsoft SQL Server System CLR Types (x64)

Microsoft SQL Server 2008 R2 Management Objects

Microsoft SQL Server 2008 R2 Management Objects (x64)

Microsoft SQL Server 2008 R2 Data-Tier Application Framework

Microsoft SQL Server 2008 R2 Data-Tier Application Project

Microsoft SQL Server 2008 R2 Transact-SQL Language Service

Microsoft SharePoint Developer Tools

Microsoft Visual Studio 2010 ADO,NET Entity Framework Tools

Microsoft Help Viewer 1.0 x64

After uninstalling restart your computer and install Visual Studio 2010 back again after the installation it will say "Setup Success" if you completely remove the frameworks and reinstall back again using this setup with VB 2010 compatible framework/components.

Upvotes: 0

PedPak
PedPak

Reputation: 177

some times, before installing VS 2010,you have installed .NetFramwork larger than .Netframwork 4 so this problem appears. to solve this problem: you can unInstall that version of .Netframwork (>4) and then reInstall the .Netframwork 4. in my case it worked.

Upvotes: 0

Tri Phuc Vo
Tri Phuc Vo

Reputation: 1

This error is happened because the version of the MSSQL server management studio program is older than the Business Intelligence Data Tools that we installed in order to manipulate SSIS packages.

You can fix it by download the new MSSQL server management studio 2012 SP1 at: http://download.microsoft.com/download/0/1/E/01E0D693-2B4F-4442-9713-27A796B327BD/SQLManagementStudio_x64_ENU.exe After that you can - Uninstalling MSSQL server management studio program - Or, you just need to run the downloaded package(SQLManagementStudio_x64_ENU.exe) then run install with the option of “New SQL Server stand-alone installation or add features to existing installation”. The installation will update all necessary library. After rebooting ther computer, the error will disappear.

Upvotes: 0

Charles Clayton
Charles Clayton

Reputation: 17966

I had this problem for SQL-Server Express 2014 and I found that just running the program as an administrator fixed it.

Upvotes: 0

raminjacobson
raminjacobson

Reputation: 531

I had the same issue and downloaded .NET 4 framework and did a repair and that fix it for me!

Upvotes: 2

Colin Pickard
Colin Pickard

Reputation: 46663

I got it working with a somewhat scary hack.

Trying to run SharpDevelop gave me the same error but with more detail - it was looking for a DLL in C:\Windows\Microsoft.NET\Framework\v4.0.21006\, but my .NET 4 was installed in C:\Windows\Microsoft.NET\Framework\v4.0.30319\.

I couldn't find a way to install the old version or how to change that broken reference so I simply copied to whole v4.0.30319 folder to v4.0.21006, after which everything started working.

I did get this interesting message when I re-opened the solution I had been working on. Clicking OK opened my solution as normal. enter image description here

I guess this is related to how I triggered the problem - I must somehow have been able to set the target framework of the solution to one I don't have installed on my machine (although there was only one entry in the dropdown for .NET 4), which I guess then set some flag somewhere on my machine for my 'current' or 'active' version of .NET... I'm guessing here, but hopefully this might help someone else who stumbles on this problem.

Upvotes: 2

JaredPar
JaredPar

Reputation: 755259

If Visual Studio can't start up then it's very likely a 3rd party component which is loading during startup which is causing this issue. The best way to root it out is to uninstall the extensions if possible. If not try

devenv /resetSettings

After that the next step is to try and repair the installation.

Upvotes: 2

Related Questions