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 !