Error "System.TypeInitializationException"

Product(s): WaterCAD, WaterGEMS, HAMMER, SewerGEMS, SewerCAD, StormCAD, CivilStorm
Version(s): 08.11.XX.XX and 10.XX.XX.XX
Area: Installation

Problem

The following error is appearing:

"System.TypeInitializationException"

When closing the program:

System.TypeInitializationException: The type initializer for 'Haestad.Domain.LibraryObjects.EngineeringLibraryService' threw an exception. ---> System.Runtime.InteropServices.SEHException: External component has thrown an exception.
  at DAO.Workspace.CreateDatabase(Workspace* , _com_ptr_t<_com_IIID>* , _bstr_t* Name, _bstr_t* Connect, _variant_t* Option)
  at CDaoDatabase.CreateDatabase(CDaoDatabase* , _bstr_t* filename, SByte*locale)
  at Haestad.Domain.DaoInterop.DaoDatabase.CreateDatabase(String fileName,CultureInfo locale)
  at Haestad.Domain.LibraryObjects.JetAppSettings.OpenRegistryDatabase(StringfileName)
  at Haestad.Domain.LibraryObjects.EngineeringLibraryService.OpenImpl()

When opening the program:

System.TypeInitializationException: The type initializer for 'Haestad.Domain.LibraryObjects.EngineeringLibraryService' threw an exception. 

Haestad.Domain.DaoInterop.DAOException (0x80040154): COMerror not documented
   at Haestad.Domain.DaoInterop.InteropLibrary.ThrowCOMException(_com_error* e)
   at Haestad.Domain.DaoInterop.DaoDatabase.CreateDatabase(String fileName, CultureInfo locale)
   at Haestad.Domain.LibraryObjects.JetAppSettings.OpenRegistryDatabase(String fileName)
   at Haestad.Domain.LibraryObjects.JetAppSettings..ctor(String filename)
   at Haestad.Domain.LibraryObjects.EngineeringLibraryService.OpenImpl()
   at Haestad.Domain.LibraryObjects.EngineeringLibraryService..cctor()

When opening a file:

System.TypeInitializationException: The type initializer for 'Haestad.Domain.LibraryObjects.EngineeringLibraryService' threw an exception.

   at Haestad.Domain.LibraryObjects.EngineeringLibraryService.set_ProjectWiseManager(ProjectWiseManager value)
   at Haestad.Framework.Application.ProjectManagerBase.get_ProjectWiseManager()
   at Haestad.Framework.Application.ProjectManagerBase.get_IsProjectWiseAvailable()
   at Haestad.Framework.Application.HaestadParentFormModel.get_IsProjectWiseAvailable()
   at Haestad.Drawing.Control.Application.GraphicalParentFormUIModelBase.Initialize()
   at Haestad.Drawing.Control.Forms.GraphicalDrawingParentForm.DoLazyInitialization(Boolean lazyInitialize)
   at Haestad.Drawing.Control.Forms.GraphicalDrawingParentForm.FileNew()
   at Haestad.Montana.Forms.MontanaXMParentForm.FileNew()
   at Haestad.Framework.Windows.Forms.Forms.WelcomeForm.buttonCreateNewProject_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

Solution

Option 1: Register the DAO File

The error could be occurring because of unregistered DAO. See this article for steps to register the DAO360.dll file.

Option 2: Perform a clean uninstall and re-install of the program

You can find the steps to perform clean uninstall and re-install the program here.

Option 3: Upgrade to the latest version of the program

You can find the steps to upgrade to the latest version here.

Option 4: Delete Engineering Libraries 

You can find the steps to delete engineering libraries here.

See Also

How do I download the Water and Storm-Sewer hydraulics and hydrology products?

How do I perform a clean uninstall and reinstall of the Hydraulic and Hydrology products?

How to register DAO360.dll or a dll file

How to Delete Engineering Libraries

Recommended
Related