There are a handful of free third party libraries out there.
Could not create excel instance.( System.Runtime.InteropServices.COMException (0x80080005))
[Win10/Office2016/C#(WPF)]
I am making an Excel automation program using Microsoft.Office.Interop.Excel.
In general, it works normally, but intermittently a problem occurs when generating Excel.
The excel generat code is as follows.
Microsoft.Office.Interop.Excel.Application App = new Microsoft.Office.Interop.Excel.Application();
- Sometimes it takes time to generate Excel (generated after 2-3 seconds / But when there are no problems, it runs almost immediately.)
- After not responding for a long time, the following exception occurs.
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.
System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
I've already tried reinstalling Office and checking the registry above, but it doesn't work.
- Why does it take so long to create Excel?
- Under what circumstances does the 0x80080005 exception usually occur?
- Is there any workaround?
Developer technologies | Windows Presentation Foundation
Developer technologies | C#
4 answers
Sort by: Most helpful
-
Sana'a Ma'rouf Al-Hussien (Al Sabaiba'a) 161 Reputation points
2022-05-24T17:15:38.707+00:00 -
Abdelnaser Ahmedelhady Mohamed Mahmoud 21 Reputation points
2022-05-24T17:48:21.233+00:00 There are a few free third-party libraries.
-
Karen Payne MVP 35,586 Reputation points Volunteer Moderator
2022-05-25T18:58:50.7+00:00 Take a look at EPPlus to read a sheet into a DataTable, convert to a pivot table then import the pivot table into a new sheet followed by removing the original.
Here are starter methods excluding pivot table where there is a article here.
-