1

I'm getting an error message saying that Excel can't continue this task with the available ressources and then an Exception from HRESULT: 0x800A03EC, and I think it has something to do with my Excel Application which I try to use only once and use for all the operations in My App, This is My Declaration of the instance:

namespace VID
{
    public partial class VID_MAIN_FORM : Form
    {
        [DllImport("user32.dll")]
        static extern int GetWindowThreadProcessId(int hWnd, out int lpdwProcessId);
        public static Excel.Application xlApp = new Excel.Application();
        System.Threading.ManualResetEvent _busy = new System.Threading.ManualResetEvent(false);
        Dictionary<string,Tuple<string, Dictionary<string, string>, List<Tuple<string, string>>,string>> FinalReportErrorList = new Dictionary<string, Tuple<string, Dictionary<string, string>,List<Tuple<string,string>>,string>>();
        Tuple<string, Dictionary<string, string>,List<Tuple<string,string>>,string> Creator_Error;
        Dictionary<string,Tuple<string, string, string,Dictionary<string,Tuple<string,string>>,string>> SFinalReportErrorList = new Dictionary<string, Tuple<string, string, string, Dictionary<string, Tuple<string, string>>,string>>();
        Tuple<string, string, string, Dictionary<string,Tuple<string,string>>,string> ServiceErrors;
        //TaskCompletionSource<bool> _tcs;

and the error occurs over here when I call xlWorkbook = xlApp.Workbooks.Open(xlFile);:

    private Tuple<string,string,string> VerifyProvider(Tuple<string,string> Provider, string xlFile, string xlSpreadsheet)
    {
        Tuple<string, string, string> ProviderInfos;
        Excel.Workbook xlWorkbook;
        string xlFileName = xlFile.Remove(0, xlFile.LastIndexOf('\\') + 1);
        bool exist = false;
        if (SrcIsOpen(xlFileName))
        {
            xlWorkbook = xlApp.Workbooks[xlFileName];
        }
        else
        {
            xlWorkbook = xlApp.Workbooks.Open(xlFile);
        }
        Excel.Worksheet xlWorksheet = xlWorkbook.Sheets[xlSpreadsheet];
        Excel.Range xlRange = xlWorksheet.UsedRange;

Thanks for Your Help In Advance !

Sybarium
  • 51
  • 7
  • 1
    Did you look at [this](http://stackoverflow.com/questions/1699936/error-while-opening-an-excel-workbook-using-c-sharp-code) and [this](http://stackoverflow.com/questions/27706258/workbooks-open-method-throwing-hresult-0x800a03ec)? – Alex Butenko Jan 15 '16 at 13:54
  • Sorry for leaving this unanswered, thanks @AlexButenko, I've found out a solution to the problem using the links you provided, thank you for the help :) – Sybarium Dec 03 '16 at 14:11

0 Answers0