Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Excel VSTO Addin: Error HRESULT 0x80028018 InteropServices.COMException: Old format or invalid type library
 
Problem:
When reading values ​​in MS Excel from a VSTO application, an error occurs: System.Reflection.TargetInvocationException with the detail message that an old format is present.
 
Reason:
The error occurs when you want to access MS Excel via a VSTO application, where the country language of the installed Office product is not in English.
VSTO applications interact with Offce via an English proxy interface, which is always set to English en-US.
 
Status: Open

 
Suggested solution:
According to service info:
1) You should switch the CultureInfo to English before accessing an Excel document
2) You should also install the English language pack for Office
 
Example in C # Code:


//*Problem HRESULT 0x80028018
//< change Language to English >
System.Globalization.CultureInfo original_Language = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
//</ change Language to English >
 
//< open Excel Worksheet >
Excel.Worksheet activeWorksheet = Globals.ThisAddIn.Application.ActiveSheet;
//< open Excel Worksheet >
 
//< get Cell.Value >
Excel.Range actCell = Globals.ThisAddIn.Application.ActiveCell;
if (actCell.Value2 != null)
{
string sValue = actCell.Value2.ToString();
string sText = actCell.Text;
}
//</ get Cell Value >
 
//< restore language >
System.Threading.Thread.CurrentThread.CurrentCulture = original_Language;
//< restore language >

 
Conclusion:
Despite errors, the error in Office 2016 remains.
 
Additional solution:
For the debugging machine you should completely delete Microsoft Office and install the English version, so that MS Office and MS Visual Studio are both in English.
 
 
 
* VSTO: Visual Studio Tools for Office
VSTO are projects in Visual Studio that access Microsoft Office products such as Excel, Word, Outlook, Powerpoint.
The projects are based on the programming language C # or vb.net.
 
 
Download the language pack for Office products:
Language Accessory Pack at Language-Accessory-Pack-f%C3%BCr-Office-2016

 
Error log in breakpoint under Visual Studio
Error Log:

Value2

 

 

{System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.Runtime.InteropServices.COMException: Altes Format oder ungültige Typbibliothek.

 

(Ausnahme von HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

--- Ende der internen Ausnahmestapelüberwachung ---

 

bei System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)

 

bei System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

 

bei System.Dynamic.IDispatchComObject.GetMembers(IEnumerable`1 names)} System.Reflection.TargetInvocationException

 

 

Mobile
»
Excel Addin: Creating a Ribbonbar Buttons for a vba Excel Addin
»
Remove custom toolbars
»
Simple list of all Ribbonbar icons with OfficeIconID
»
Office Icons: List of icons for the Ribbonbar
»
Excel Addin: create a Ribbonbar via VSTO Addin
»
Note: Installing the English Office Developer Tools for Visual Studio VSTO
»
Note: What is Interop and PIA in Microsoft Office
»
Excel VSTO Addin: Error HRESULT 0x80028018 InteropServices.COMException: Old format or invalid type library

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de