Exception : 0x80010105 sur creation d'un chart

Résolu
neoxaro Messages postés 41 Date d'inscription jeudi 6 août 2009 Statut Membre Dernière intervention 6 mai 2015 - Modifié par neoxaro le 23/08/2013 à 14:15
 Neoxaro - 26 août 2013 à 14:41
Bonjour,

J'ai réaliser une bout de code en vb pour exporter des valeurs vb vers Excel. J'ai tester cela sur mon ordinateur ça marche parfaitement mais lorsque je le lance sur un autre pc avec une version d'Excel plus récente cela me met une exception 0x80010105.

Le code :

 xlCharts = excelWorksheet2.ChartObjects
 msgbox("1")
            myChart = xlCharts.Add(0, 0, 600, 450)
 msgbox("2")
            chartPage = myChart.Chart
 msgbox("3")
            chartRange = excelWorksheet.Range(excelWorksheet.Cells(1, 3), excelWorksheet.Cells(rowsTotal + 1, colsTotal + 1))
 msgbox("4")
            chartPage.SetSourceData(Source:=chartRange, PlotBy:=Microsoft.Office.Interop.Excel.XlRowCol.xlColumns)


J'ai mis des msgbox pour tester et voir quand cela plante exactement et la messagebox ("1") apparait et l'exception apparait juste apres.

Et juste avant :
            excelWorksheet2.Select()
            With excelWorksheet2
                .Cells.Select()
                .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal).ColorIndex = 2
                .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical).ColorIndex = 2
                .Name = "Graphe"
            End With



Ce code est beaucoup plus long à s'exécuter que normalement.




Mon exception :
See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Microsoft.Office.Interop.Excel.ChartObjects.Add(Double Left, Double Top, Double Width, Double Height)
   at WindowsApplication1.graph_data.export(String& cyclename, String& cycleshort, String& axe) in C:\Documents and Settings\AUDUSER.FRLT132375\Bureau\dAVID\GAT_EX_vb2010\GatherPmac_exemple\graph_data.vb:line 378
   at WindowsApplication1.Form2.Button4_Click(Object sender, EventArgs e) in C:\Documents and Settings\AUDUSER.FRLT132375\Bureau\dAVID\GAT_EX_vb2010\GatherPmac_exemple\Form2.vb:line 974
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///E:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
GatherPmac_exemple
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///G:/dAVID/GAT_EX_vb2010/GatherPmac_exemple/bin/Release/GatherPmac_exemple.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 10.0.0.0
    Win32 Version: 10.0.30319.1 built by: RTMRel
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Windows.Forms.DataVisualization
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.DataVisualization/v4.0_4.0.0.0__31bf3856ad364e35/System.Windows.Forms.DataVisualization.dll
----------------------------------------
System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///E:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.Office.Interop.Excel
    Assembly Version: 12.0.0.0
    Win32 Version: 12.0.4518.1014
    CodeBase: file:///E:/WINDOWS/assembly/GAC/Microsoft.Office.Interop.Excel/12.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
----------------------------------------
office
    Assembly Version: 12.0.0.0
    Win32 Version: 12.0.4518.1014
    CodeBase: file:///E:/WINDOWS/assembly/GAC/office/12.0.0.0__71e9bce111e9429c/office.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.





Si quelqu'un peut m'aider

Cordialement

6 réponses

NHenry Messages postés 15113 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 22 avril 2024 159
Modifié par NHenry le 23/08/2013 à 18:06
Bonsjour,

As-tu tenté de reproduire ton code dans une macro pour voir si c'est un truc non (ou mal) géré par Excel ?

En VB.NET pensez à activer Option Explicit et Option Strict et à retirer l'import automatique de l'espace de nom Microsoft.VisualBasic
0
neoxaro Messages postés 41 Date d'inscription jeudi 6 août 2009 Statut Membre Dernière intervention 6 mai 2015
23 août 2013 à 22:04
Bonjour,
Ce que je trouve bizarre c'est que mon application le réalise bien sur mon premier PC, donc les commandes sont bonnes par rapport à Excel mais peut-être pas avec la version 2007 (plus récente) ?
0
NHenry Messages postés 15113 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 22 avril 2024 159
24 août 2013 à 15:40
Bonjour,

As-tu essayé en mode debug ?
Pour voir exactement sur quelle ligne ça bug.

Sinon, je ne vois pas la cause, mais as-tu essayer de le faire en macro ?
0
Ca bug sur l'instruction :
 myChart = xlCharts.Add(0, 0, 600, 450)


Et tout ce code n'a pas encore était testé dans une macro
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
neoxaro Messages postés 41 Date d'inscription jeudi 6 août 2009 Statut Membre Dernière intervention 6 mai 2015
Modifié par neoxaro le 26/08/2013 à 10:33
J'ai peut-être une idée, mon fichier Microsoft.office.core.dll dans la description il est écrit 11.0 object library. D'après mes recherches, cette library est pour microsoft office 2003 il me faudrait donc la version 12.0, pour le faire tourner sur les ordinateurs en version 2007. Ou puis-je trouver le dll en version 12.0 ? sachant que j'ai microsoft office 2007 installé sur mes autres ordinateurs mais pas sur l'ordinateur sur lequel je programme.

PS : par contre j'ai micrsoft.office.interop.Excel il m'est écrit version 11.0.0.0 donc même problème je suppose ? Du moins si cela est un problème.


Mon code complet est le suivant :

(j'ai mis la msgbox : msgbox("jusque là ça marche nickel ensuite ça plante sur myChart = .ChartObjects.Add(0, 0, 600, 450)") pour dire ou cela plante à l'éxecution (sur MS office 2007)






Dim rowsTotal, colsTotal As Short
        Dim I, j, iC As Short
        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
        Dim xlApp As New Microsoft.Office.Interop.Excel.Application
        Dim excelBook As Microsoft.Office.Interop.Excel.Workbook = xlApp.Workbooks.Add
        Dim excelWorksheet As Microsoft.Office.Interop.Excel.Worksheet = CType(excelBook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
        Dim excelWorksheet2 As Microsoft.Office.Interop.Excel.Worksheet = CType(excelBook.Worksheets(2), Microsoft.Office.Interop.Excel.Worksheet)

        ' Define a title for the message box.
        Dim title = "Exportation"

        ' Display the message box and save the response, Yes or No.
        Dim response = MsgBox("Exportation des données, veuillez patienter.", , title)

        Try
            xlApp.Visible = True
            rowsTotal = Form2.DataGridView1.RowCount - 1
            colsTotal = Form2.DataGridView1.Columns.Count - 1


            With excelWorksheet
                .Name = "Données"
                .Cells.Select()
                .Cells.Delete()
                For iC = 0 To colsTotal
                    .Cells(1, iC + 1).Value = Form2.DataGridView1.Columns(iC).HeaderText
                    .Cells(1, iC + 1).Interior.ColorIndex = 3
                Next

                With excelWorksheet.Cells.Range(excelWorksheet.Cells(1, 1), excelWorksheet.Cells(1, colsTotal + 1))
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom).ColorIndex = 0
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight).ColorIndex = 0
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft).ColorIndex = 0
                End With

                For I = 0 To rowsTotal - 1
                    For j = 0 To colsTotal
                        .Cells(I + 2, j + 1).value = Form2.DataGridView1.Rows(I).Cells(j).Value
                    Next j
                Next I

                With excelWorksheet.Cells.Range(excelWorksheet.Cells(2, 1), excelWorksheet.Cells(rowsTotal + 1, colsTotal + 1))
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom).ColorIndex = 0
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight).ColorIndex = 0
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft).ColorIndex = 0
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal).ColorIndex = 0
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin
                    .Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical).ColorIndex = 0
                End With

                .Rows("1:1").Font.FontStyle = "Bold"
                .Rows("1:1").Font.Size = 10
                .Cells.Columns.AutoFit()
                '.Cells.Select()
                '.Cells.EntireColumn.AutoFit()
            End With

            'create chart
            Dim chartPage As Microsoft.Office.Interop.Excel.Chart
            '   Dim xlCharts As Microsoft.Office.Interop.Excel.ChartObjects
            Dim myChart As Microsoft.Office.Interop.Excel.ChartObject
            Dim chartRange As Microsoft.Office.Interop.Excel.Range


            msgbox("jusque là ça marche nickel ensuite ça plante sur myChart = .ChartObjects.Add(0, 0, 600, 450)")



            excelWorksheet2.Select()

            With excelWorksheet2
                .Name = "Graphe"
                myChart = .ChartObjects.Add(0, 0, 600, 450)
            End With

            '   With excelWorksheet.Cells.Range(excelWorksheet.Cells(1, 1), excelWorksheet.Cells(1, colsTotal + 1))
            '.Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
            '.Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical).Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin
            '.Cells.Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical).ColorIndex = 0
            'End With

            Dim misValue As Object = System.Reflection.Missing.Value
            xlApp = New Microsoft.Office.Interop.Excel.Application
            excelBook = xlApp.Workbooks.Add(misValue)

            '   xlCharts = excelWorksheet2.ChartObjects
            '   myChart = excelWorksheet2.ChartObjects.Add(0, 0, 600, 450)

            chartPage = myChart.Chart
            chartRange = excelWorksheet.Range(excelWorksheet.Cells(1, 3), excelWorksheet.Cells(rowsTotal + 1, colsTotal + 1))
            chartPage.SetSourceData(Source:=chartRange, PlotBy:=Microsoft.Office.Interop.Excel.XlRowCol.xlColumns)
            chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlLine

            Dim NameFile As String
            If cyclename = "" Or cycleshort = "" Then
                If Directory.Exists(Application.StartupPath.ToString() & "\" & "enregistrement manuel") = False Then
                    Directory.CreateDirectory(Application.StartupPath.ToString() & "\" & "enregistrement manuel")
                End If
                NameFile = Application.StartupPath.ToString() & "\" & "enregistrement manuel" & "\" & "_axe" & axe & "_manu" & "_" & Date.Now.Hour & "h" & Date.Now.Minute & ".xls"
                If File.Exists(NameFile) Then
                    NameFile = Application.StartupPath.ToString() & "\" & "enregistrement manuel" & "\" & "_axe" & axe & "_manu" & "_" & Date.Now.Hour & "h" & Date.Now.Minute & "min" & Date.Now.Second & ".xls"
                End If
            Else
                If Directory.Exists(Application.StartupPath.ToString() & "\" & cyclename) = False Then
                    Directory.CreateDirectory(Application.StartupPath.ToString() & "\" & cyclename)
                End If
                NameFile = (Application.StartupPath.ToString() & "\" & cyclename & "\" & cycleshort & "_axe" & axe & "_auto" & "_" & Date.Now.Hour & "h" & Date.Now.Minute & ".xls")
                If File.Exists(NameFile) Then
                    NameFile = Application.StartupPath.ToString() & "\" & cyclename & "\" & cycleshort & "_axe" & axe & "_auto" & "_" & Date.Now.Hour & "h" & Date.Now.Minute & "min" & Date.Now.Second & ".xls"
                End If
            End If


            excelWorksheet2.Cells(1, 1).select()
            excelWorksheet2.SaveAs(NameFile)
            excelBook.Close(False)
            ' xlApp.Quit()
            releaseObject(xlApp)
            releaseObject(excelBook)
            releaseObject(excelWorksheet)
            ' MsgBox("Excel file created , you can find the file" & Chr(13) & NameFile)

            Dim style = MsgBoxStyle.MsgBoxSetForeground
            MsgBox("Exportation terminée avec succès.", style)

        Catch ex As Exception
            MsgBox("Export Excel Error " & ex.Message)
        Finally
            'RELEASE ALLOACTED RESOURCES   
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
            xlApp = Nothing
        End Try



        Return (True)


Cordialement
0
Bonjour,


J'ai résolu mon problème par moi même après une semaine de recherche, donc je viens donner ma solution.

Après recherche l'instruction qui ne fonctionnait pas était bien dû a la mauvaise version du interop.Excel qui était en v11.0. J'ai donc était sur un ordinateur qui était sous office 2007 et j'ai extrait le fichier microsoft.office.interop.Excel.dll de l'assembly avec l'invite de commande cmd, un simple "dir vers l'assembly" et ensuite un "copy" m'a permis de récuperer le dll et ensuite le mettre sur le PC avec office 2003 pour l'intégrer comme référence à mon projet

Cordialement
0
Rejoignez-nous