This project has moved and is read-only. For the latest updates, please go here.

EPPlus.dll failure,VB

Sep 21, 2015 at 9:55 PM
Our developer had quite recently and a week ago and our application runs a daily report that's stopped running. Whenever attempt to run it gives error:

Exception thrown: 'System.InvalidOperationException' in EPPlus.dll
The program '[13388] Stuffstuff.vshost.exe' has exited with code 2 (0x2).
The program '[13388] Stuffstuff.vshost.exe: Program Trace' has exited with code 0 (0x0).




The code:

/*
  • I will try to explain what needs to be changed here as best as I can.
  • The underscore SKUs are identified by what number they appear in inventory in alphabetical order.
  • For example: _Actacel60ct = 0, _ActacelCream = 1, _BookletOptimize = 4
  • If a new "_" SKU was added to inventory, determine what number it is.
  • Please see below for more green comment texts on what needs to be added/changed
    */
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data.SqlClient;
    using System.IO;
    using System.Linq;
    using System.Net.Mail;
    using System.Reflection;
    using System.Text;
    using System.Threading.Tasks;
using OfficeOpenXml;

namespace StuffstuffReturns
{
class Program
{
    static void Main(string[] args)
    {
        string sqlClients = "SELECT SKU, ItemName, Description, OnHand, BillQty " +
                            "FROM tblfscInventory " +
                            "WHERE ClientNumber = 1470;";
        /*
         *  Increment the number inside the "[]" by 1
         */
        string[][] items = new string[31][];
        bool check = true;

        FileInfo file = new FileInfo(@"C:\Tools\Stuffstuff\Reports\fsc Inventory " + DateTime.Now.ToString("MM-dd-yyyy") + ".xlsx");
        if (file.Exists)
            file.Delete();

        ExcelPackage excel = new ExcelPackage(file);
        ExcelWorksheet worksheet = CreateSheet(excel, "Inventory");

        worksheet.Cells[1, 1].Value = "SKU";
        worksheet.Cells[1, 2].Value = "ItemName";
        worksheet.Cells[1, 3].Value = "Descrption";
        worksheet.Cells[1, 4].Value = "OnHand";

        using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SQL"].ToString()))
        using (SqlCommand com = new SqlCommand(sqlClients, con))
        {
            con.Open();
            using (SqlDataReader read = com.ExecuteReader())
            {
                while (read.Read())
                {
                    string item = read["ItemName"].ToString();

                    while (check)
                    {
                        /*
                         *  Increment the 2nd number by 1.  Leave the 0 alone
                         */
                        for (int i = 0; i < 31; i++)
                        {
                            items[i] = new string[4];
                            items[i][0] = read["SKU"].ToString();
                            items[i][1] = read["ItemName"].ToString();
                            items[i][2] = read["Description"].ToString();
                            items[i][3] = read["OnHand"].ToString();
                            read.Read();
                        }
                        check = false;
                        break;
                    }

                    /*
                     *  When you have determined the number for the new SKU, you need to do the following:
                     *  
                     *  If you see ANY number in the first set of "[]" at the beginning of each row that EQUALS OR GREATER THAN the number for the new SKU,
                     *  you MUST increment that number by 1.
                     *  For example:
                     *       If the line begins with "items[15][3]" and your number is 15, change the 15 to a 16 in the first "[]".  LEAVE THE 3 ALONE!
                     *       
                     *  You need to go line by line and do these changes.
                     *  
                     *  If the number is LESS THAN your number, LEAVE IT ALONE!
                     *  
                     *  One more comment lies near the end of this block.
                     */
                    if (read["ItemName"].ToString().Contains("Neurocet"))
                        items[16][3] = (Int32.Parse(items[16][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                    else if (read["ItemName"].ToString().Contains("Eucalyptus"))
                    {
                        for (int i = 9; i < 14; i++)
                            items[i][3] = (Int32.Parse(items[i][3]) + Int32.Parse(read["OnHand"].ToString())).ToString();
                    }
                    else if (read["ItemName"].ToString().Contains("Peppermint") && !read["ItemName"].ToString().Contains("Eucalyptus"))
                    {
                        for (int i = 12; i < 14; i++)
                            items[i][3] = (Int32.Parse(items[i][3]) + Int32.Parse(read["OnHand"].ToString())).ToString();
                    }
                    else if (read["ItemName"].ToString().Contains("Hydraburst"))
                    {
                        if (read["ItemName"].ToString().Contains("Booklet"))
                        {
                            items[3][3] = (Int32.Parse(items[3][3]) + Int32.Parse(read["OnHand"].ToString())).ToString();
                            items[5][3] = (Int32.Parse(items[5][3]) + Int32.Parse(read["OnHand"].ToString())).ToString();
                            if (read["ItemName"].ToString().Contains("All 3"))
                            {
                                items[4][3] = (Int32.Parse(items[4][3]) + Int32.Parse(read["OnHand"].ToString())).ToString();
                                items[15][3] = (Int32.Parse(items[15][3]) + (Int32.Parse(read["OnHand"].ToString()) * (Int32.Parse(read["BillQty"].ToString()) - 3))).ToString();
                            }
                            else
                                items[15][3] = (Int32.Parse(items[15][3]) + (Int32.Parse(read["OnHand"].ToString()) * (Int32.Parse(read["BillQty"].ToString()) - 2))).ToString();
                        }
                        else
                            items[15][3] = (Int32.Parse(items[15][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                    }
                    else if (item.Contains("Thin 7"))
                    {
                        if (item.Contains("Vial"))
                        {
                            if (item.Contains("Apple"))
                                items[25][3] = (Int32.Parse(items[25][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                            else if (item.Contains("Carmel"))
                                items[26][3] = (Int32.Parse(items[26][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                            else if (item.Contains("Chocolate"))
                                items[27][3] = (Int32.Parse(items[27][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                            else if (item.Contains("Cotton"))
                                items[28][3] = (Int32.Parse(items[28][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                            else if (item.Contains("Bubble"))
                                items[29][3] = (Int32.Parse(items[29][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                            else if (item.Contains("Peanut"))
                                items[30][3] = (Int32.Parse(items[30][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();

                        }
                        else if (item.Contains("Inhaler"))
                            items[24][3] = (Int32.Parse(items[24][3]) + Int32.Parse(read["OnHand"].ToString())).ToString();
                        else if (item.Contains("Warranty"))
                            items[23][3] = (Int32.Parse(items[23][3]) + Int32.Parse(read["OnHand"].ToString())).ToString();
                        else
                            items[22][3] = (Int32.Parse(items[22][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                    }
                    else if (item.Contains("Reset"))
                        items[21][3] = (Int32.Parse(items[21][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                    else if (item.Contains("Actacel"))
                    {
                        if (item.Contains("Cream"))
                            items[1][3] = (Int32.Parse(items[1][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                        else
                            items[0][3] = (Int32.Parse(items[0][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                    }
                    else if (item.Contains("Regenify"))
                        items[19][3] = (Int32.Parse(items[19][3]) + Int32.Parse(read["OnHand"].ToString()) * Int32.Parse(read["BillQty"].ToString())).ToString();
                    else if (item.Contain

Sep 21, 2015 at 9:57 PM
Nothing has changed since the following week, same issue with VB 2013 and VB 2015. The path for EPPlus.dll has not changed and the paths are correct. At the moment running out of ideas and I am not really a developer.