Click here to Skip to main content
15,919,898 members
Home / Discussions / C#
   

C#

 
AnswerRe: Load Assembly At Run Time if Implements Interface Pin
Bernhard Hiller6-Feb-17 22:28
Bernhard Hiller6-Feb-17 22:28 
QuestionInsert selected combobox item into database table Pin
rattlerrFx6-Feb-17 8:35
rattlerrFx6-Feb-17 8:35 
AnswerRe: Insert selected combobox item into database table Pin
NotPolitcallyCorrect6-Feb-17 8:48
NotPolitcallyCorrect6-Feb-17 8:48 
GeneralRe: Insert selected combobox item into database table Pin
rattlerrFx6-Feb-17 8:57
rattlerrFx6-Feb-17 8:57 
AnswerRe: Insert selected combobox item into database table Pin
Richard Deeming6-Feb-17 10:12
mveRichard Deeming6-Feb-17 10:12 
GeneralRe: Insert selected combobox item into database table Pin
rattlerrFx6-Feb-17 16:58
rattlerrFx6-Feb-17 16:58 
GeneralRe: Insert selected combobox item into database table Pin
Richard Deeming7-Feb-17 3:00
mveRichard Deeming7-Feb-17 3:00 
QuestionI am getting error while saving outlook file in folder and when i am opening outlook file i am getting error Pin
Member 126658716-Feb-17 0:13
Member 126658716-Feb-17 0:13 
AnswerRe: I am getting error while saving outlook file in folder and when i am opening outlook file i am getting error Pin
Nathan Minier6-Feb-17 1:35
professionalNathan Minier6-Feb-17 1:35 
QuestionHow to complete the following C# program on Custom datatypes using interface? Pin
Member 129842755-Feb-17 16:08
Member 129842755-Feb-17 16:08 
AnswerRe: How to complete the following C# program on Custom datatypes using interface? Pin
Pete O'Hanlon5-Feb-17 22:13
mvePete O'Hanlon5-Feb-17 22:13 
GeneralRe: How to complete the following C# program on Custom datatypes using interface? Pin
Member 129842756-Feb-17 5:26
Member 129842756-Feb-17 5:26 
AnswerRe: How to complete the following C# program on Custom datatypes using interface? Pin
Richard MacCutchan5-Feb-17 22:17
mveRichard MacCutchan5-Feb-17 22:17 
QuestionC# Winform: How play powerpoint slide inside webbrowser control Pin
Tridip Bhattacharjee5-Feb-17 10:44
professionalTridip Bhattacharjee5-Feb-17 10:44 
AnswerRe: C# Winform: How play powerpoint slide inside webbrowser control Pin
Richard MacCutchan5-Feb-17 22:12
mveRichard MacCutchan5-Feb-17 22:12 
QuestionHow to run ppt slide one after one by Process.Start Pin
Tridip Bhattacharjee5-Feb-17 8:18
professionalTridip Bhattacharjee5-Feb-17 8:18 
AnswerRe: How to run ppt slide one after one by Process.Start Pin
Dave Kreskowiak5-Feb-17 10:05
mveDave Kreskowiak5-Feb-17 10:05 
GeneralRe: How to run ppt slide one after one by Process.Start Pin
Tridip Bhattacharjee5-Feb-17 10:43
professionalTridip Bhattacharjee5-Feb-17 10:43 
GeneralRe: How to run ppt slide one after one by Process.Start Pin
Dave Kreskowiak5-Feb-17 17:52
mveDave Kreskowiak5-Feb-17 17:52 
GeneralRe: How to run ppt slide one after one by Process.Start Pin
Pete O'Hanlon5-Feb-17 21:05
mvePete O'Hanlon5-Feb-17 21:05 
GeneralRe: How to run ppt slide one after one by Process.Start Pin
Tridip Bhattacharjee5-Feb-17 22:51
professionalTridip Bhattacharjee5-Feb-17 22:51 
GeneralRe: How to run ppt slide one after one by Process.Start Pin
Dave Kreskowiak6-Feb-17 3:00
mveDave Kreskowiak6-Feb-17 3:00 
QuestionRegistries in Windows 10 Pro Pin
picasso23-Feb-17 14:40
picasso23-Feb-17 14:40 
AnswerRe: Registries in Windows 10 Pro Pin
Richard MacCutchan3-Feb-17 22:10
mveRichard MacCutchan3-Feb-17 22:10 
QuestionCOM object that has been separated from its underlying RCW cannot be used. Pin
hpjchobbes3-Feb-17 4:48
hpjchobbes3-Feb-17 4:48 
I am using a third party reference, which is a COM object. The COM object has an Open and Close function and I need to make sure that Close is always called whenever possible. I wrote a wrapper class that implements IDisposable and in the Dispose function, I try to call the Close function. However I get a System.Runtime.InteropServices.InvalidComObjectException when I try to call the close function with additional details of "COM object that has been separated from its underlying RCW cannot be used."
public class MyWrapper : IDisposable
{
    private Session _mySession = new Session(); // This is the COM object

    public void Open() { _MySession.Open(); }
    public void Close() { _MySession.Close(); }

    public void Dispose() {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public void Dispose(bool disposing) {
        _MySession.Close(); // Calling close without having called open is OK
    }
    ~MyWrapper() { Dispose(false); }    
}

From my (limited) understanding, there are two reasons why I am getting the exception.
1) The Finalizer is running and calling the destructor, but because the finalizer is on a separate thread I get the error.
2) Based on this Stack Overflow[^] post, the Runtime Callable Wrapper (RCW) has it's own finalizer which is being called before mine, and getting rid of the COM object.

I don't know if either of these, or both of these are true, but what is the recommended way to implement a COM object that needs to have finalizer code run?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.