C# ,Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)

0

I face this problem when I try the exe at the user's end. The user has MicosoftExcel 2000 and I have execel 2003. Can someone please help me.

I have created this tool in c# and have used COM

if( strDataSheetFile.Trim().EndsWith( ".xls" ) || strDataSheetFile.Trim().EndsWith( ".xlsx" ) )
        {
            System.IO.StreamWriter file = null;
            if (IfAbFile)
            {
                file = new System.IO.StreamWriter(AbaqusDeckFile.ToString(), true);
            }
            else
            {
                string[] strFILEnamesSplit = strDataSheetFile.Split(new Char[] { '\\' });
                string ExpFile = "";
                int ilnt = 0;
                foreach (string strVal in strFILEnamesSplit )
                {
                    if (ilnt < (strFILEnamesSplit.Length - 1))
                    {
                        ExpFile += strVal;
                        ExpFile += "/";
                    }
                    else
                        ExpFile += "Deck.inp";

                    ilnt += 1;
                }

                file = new System.IO.StreamWriter(ExpFile.ToString(), true);
            }

            List<List<double>> List_SheetValues = new List<List<double>>();

            Excel.Application objexcel;
            Excel.Workbook wbexcel;

            Excel.Worksheet wsheet;

            objexcel = new Excel.Application();

            //strDataSheetFile = @"C:\Ajoy\Demos\IsoMount\IsoMount_Springs_database_updated.xls";

            if (File.Exists(strDataSheetFile))
                wbexcel = objexcel.Workbooks.Open(strDataSheetFile);
            else
            {
                MessageBox.Show(" Please state the number of springs", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.UseWaitCursor = false;
                return;
            }
c#
excel
exception
asked on Stack Overflow Nov 14, 2013 by user2982029 • edited Nov 14, 2013 by JMK

2 Answers

1

This is probably happening in you use early (compile time) binding to the Excel type library.

The user has a different version of the type library (2000 vs 2003 on your machine). Have you tried installing Excel 2000 on your machine & compiling your app by linking to the 2000 type library.

Alternatively, if you are not using any 2003 specific features AND the the functions & objects you are using have not changed between those 2 versions, you can try late (runtime) binding.

There'll be a slight performance hit & you lose intellisense in the IDE but should make your app portable across all Excel versions that support those objects & functions

answered on Stack Overflow Nov 14, 2013 by Ashley Pillay
0

i think the problem is you are compiling your Project as 'x64' 64bit instead of that compile it as x86 32 bit Application. Follow the below steps:

 ->Right click on Project
 ->Select Properties
 ->Select Build tab
 ->Change  "Platform Target" to "x86"
 ->now run the Project.
answered on Stack Overflow Nov 14, 2013 by Sudhakar Tillapudi

User contributions licensed under CC BY-SA 3.0