Error - System.InvalidCastException error when opening a map from the Map Control Console

Ref: 201310181153 
Last Edited: October 18th, 2013
 
 

Description

When an attempt is made to open a map from the Process Navigator Map Control Console, an unanticipated 'System.InvalidCastException' error is reported, and the map isn't opened.
The details of the error will depend on the context in which the map was opened and the nature of spurious Registry data.
The error can occur through any action that opens a map, examples of which are:
Edit in Microsoft Visio
Generate Next Level
Export to HTML

Cause

These errors are caused by spurious Visio-related Registry data, which could be, but not necessarily, the remnant of an installation of Visio that has been removed, and replaced with another of a different version.
The following describes a test set-up on which Visio 2007 was installed, but to which Registry information sourced from a Visio 2010 installation on a different PC was added. Although artificial, the results match those reported by others who have experienced the issue.

HKCR\TypeLib\{00021A98-0000-0000-C000-000000000046}\
4.9\
PrimaryInteropAssemblyName = Microsoft.Office.Interop.Visio, Version=10.0.4504.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35                                
4.c\
(Default) = Microsoft Visio 12.0 Type Library
0\
win32\
(Default) = C:\Program Files\Microsoft Office\Office12\VISLIB.DLL
FLAGS\
(Default) = 0
HELPDIR\
(Default) = C:\Program Files\Microsoft Office\Office12\
4.e\
(Default) = Microsoft Visio 14.0 Type Library
PrimaryInteropAssemblyName = Microsoft.Office.Interop.Visio, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C
0\
win32\
(Default) = C:\Program Files (x86)\Microsoft Office\Office14\VISLIB.DLL
FLAGS\
(Default) = 0
HELPDIR\
(Default) = [{00021A98-0000-0000-C000-000000000046}]

where:
4.c - represents Visio 2007 (a valid installation)
4.e - represents Visio 2010 (not installed)


'TYPE_E_CANTLOADLIBRARY' errors

With this configuration, 'TYPE_E_CANTLOADLIBRARY' errors are reported.

Edit in Microsoft Visio

18/10/2013 11:18:47
An unexpected problem occurred loading maps in Visio.

=== Begin For Triaster Support ===
The following content may be useful to the Triaster support team.
Please copy and paste it into an e-mail to support@triaster.co.uk
and attach any referenced files if you would like help understanding
how to avoid this issue reoccurring.
Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
An unexpected problem occurred loading maps in Visio.

System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
   at Microsoft.Office.Interop.Visio.ApplicationClass.get_Documents()
   at Triaster.ProcessNavigator.Common.Helper.VisioSupport.OpenDocument(Application appVisio, String strFileName, Boolean blnEnableVBA)
   at Triaster.ProcessNavigator.Common.Helper.VisioSupport.OpenDocument(Application appVisio, String strFileName)
   at Triaster.ProcessNavigator.Common.ProcessObjects.DocumentsBase.LoadInVisio(String strFullPathAndFileName)
   at Triaster.ProcessNavigator.AnalystEdition.frmMain.mnuEditInMappingEdition_Click(Object sender, EventArgs e)
=== Finish For Triaster Support ===


Generate Next Level

18/10/2013 11:16:22
An error has occurred generating the next level.

=== Begin For Triaster Support ===
The following content may be useful to the Triaster support team.
Please copy and paste it into an e-mail to support@triaster.co.uk
and attach any referenced files if you would like help understanding
how to avoid this issue reoccurring.
Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
An error has occurred generating the next level.

System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
   at Triaster.ProcessNavigator.Common.ProcessObjects.DocumentsBase.CreateOrOpenDocument(String strFullPathAndFileName, String strTemplateFileName)
   at Triaster.ProcessNavigator.Common.ProcessObjects.Maps.CreateOrOpenMap(String strFullPathAndFileName)
   at Triaster.ProcessNavigator.AnalystEdition.clsGNL.GenerateNextLevel()
=== Finish For Triaster Support ===


'TYPE_E_LIBNOTREGISTERED' errors

If the '4.e' key exists, but there's little or nothing within it, 'TYPE_E_LIBNOTREGISTERED' errors occur. For example, such errors were reported with an empty '4.e' key or when the '4.e\0' key was missing.

Edit in Microsoft Visio

18/10/2013 11:45:36
An unexpected problem occurred loading maps in Visio.

=== Begin For Triaster Support ===
The following content may be useful to the Triaster support team.
Please copy and paste it into an e-mail to support@triaster.co.uk
and attach any referenced files if you would like help understanding
how to avoid this issue reoccurring.
Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
An unexpected problem occurred loading maps in Visio.

System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
   at Microsoft.Office.Interop.Visio.ApplicationClass.get_Documents()
   at Triaster.ProcessNavigator.Common.Helper.VisioSupport.OpenDocument(Application appVisio, String strFileName, Boolean blnEnableVBA)
   at Triaster.ProcessNavigator.Common.Helper.VisioSupport.OpenDocument(Application appVisio, String strFileName)
   at Triaster.ProcessNavigator.Common.ProcessObjects.DocumentsBase.LoadInVisio(String strFullPathAndFileName)
   at Triaster.ProcessNavigator.AnalystEdition.frmMain.mnuEditInMappingEdition_Click(Object sender, EventArgs e)
=== Finish For Triaster Support ===

Generate Next Level

An error has occurred generating the next level.

=== Begin For Triaster Support ===
The following content may be useful to the Triaster support team.
Please copy and paste it into an e-mail to support@triaster.co.uk
and attach any referenced files if you would like help understanding
how to avoid this issue reoccurring.
Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
An error has occurred generating the next level.

System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
   at Triaster.ProcessNavigator.Common.ProcessObjects.DocumentsBase.CreateOrOpenDocument(String strFullPathAndFileName, String strTemplateFileName)
   at Triaster.ProcessNavigator.Common.ProcessObjects.Maps.CreateOrOpenMap(String strFullPathAndFileName)
   at Triaster.ProcessNavigator.AnalystEdition.clsGNL.GenerateNextLevel()
=== Finish For Triaster Support ===


Solution

The Registry data associated with any absent versions of Visio should be removed. In the example used, that would mean the deletion of the '4.e' key, which includes removal of the Visio 2010 interop data. The mere presence of that key will otherwise lead to these errors.
In addition, check that this key references the correct version of Visio, which in this test case would be:
HKCR\Interface\{000D0700-0000-0000-C000-000000000046}\TypeLib\
Version = 4.c

Applies to

  • Process Navigator, Visio