Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
.dll blues
Message
 
À
11/03/2013 13:32:13
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
01568002
Message ID:
01568005
Vues:
37
Thanks Craig.

The IDisposable seems to work alright. I use it to "wrap" Excel and thanks to the "using" construct, Excel gets deallocated on "end (using)".

Kind regards,

Marc

FWIW here's my implementation and to the best of my knowledge, I don't get that warning.
Public Class fwExcel
    Implements IDisposable
    Public oApp As New Excel.Application
    Public oWBs As Excel.Workbooks
    Public oWB As Excel.Workbook
    Public Selection As Excel.Range
    Public lTest As Boolean

    Public originalCulture As System.Globalization.CultureInfo
    Dim thisThread As System.Threading.Thread
    Dim lQuit As Boolean = True
    Dim lDisposed As Boolean = False

    Public cPrinter As String
    Public nCopies As Integer
    Public cXlsRoot As String
    Sub New()
        Me.thisThread = System.Threading.Thread.CurrentThread
        Me.originalCulture = thisThread.CurrentCulture
        Me.thisThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
        Me.oWBs = Me.oApp.Workbooks
        Me.oApp.DisplayAlerts = False
    End Sub
    Sub Dispose() Implements IDisposable.Dispose
        If Me.lDisposed Then Exit Sub
        If lQuit Then Me.oApp.Quit()
        Me.releaseObject(Me.oWB)
        Me.releaseObject(Me.oWBs)
        Me.releaseObject(Me.oApp)
        Me.thisThread.CurrentCulture = Me.originalCulture
        Me.lDisposed = True
    End Sub
    Protected Overrides Sub finalize()
        Me.Dispose()
    End Sub
    Public Sub releaseObject(ByVal o As Object)
        If o Is Nothing Then Exit Sub
        Runtime.InteropServices.Marshal.FinalReleaseComObject(o)
        o = Nothing
    End Sub
>Nothing in here http://msdn.microsoft.com/en-US/library/ms244737(v=VS.80).aspx about a constructor, but it may show you what's wrong
>
>>I have this vb project that I compile separately to a .dll.
>>
>>I referenced the .dll in this other ("client") project.
>>
>>Here's one of the classes that I defined in the vb .dll project:
>>
>>
>>Imports Microsoft.Office.Interop
>>Public Class fwExcel
>>    Implements IDisposable
>>
>>
>>In the client project I cannot "using" it, because it's "IDsposable" is not recognised.
>>
>>Under that fwExcel class I also defined :
>>
>>   Public Class fwWorksheet
>>
>>
>>This class does have a constructor :
>>
>>
>>        Public Sub New(oXl As fwExcel)
>>            Me.oXlParent = oXl
>>            Me.oXl = oXl.oApp
>>        End Sub
>>
>>
>>Interestingly, for some reason, the client does not "see" this fwWorksheet Class.
>>
>>On the other hand, it does recognize a fwSQL.sqlBulider that was defined similarly but does not have a constructor. I'm mentioning that because that's the only difference that I can think of.
>>
>>Am I missing something when I reference the .dll. Is there something more I have not done when I "built" the vb.dll as a "second" project within another solution?
>>
>>TIA and kind regards,
>>
>>Marc

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform