Click here to Skip to main content
15,895,606 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# How to Copy Files of the same extension from One Server to multiple Servers on the same network simultaneously Pin
Pete O'Hanlon23-May-16 0:28
mvePete O'Hanlon23-May-16 0:28 
QuestionUDP communication and CRC16 calculations Pin
MaWeRic19-May-16 22:58
MaWeRic19-May-16 22:58 
GeneralRe: UDP communication and CRC16 calculations Pin
harold aptroot19-May-16 23:55
harold aptroot19-May-16 23:55 
GeneralRe: UDP communication and CRC16 calculations Pin
MaWeRic20-May-16 0:12
MaWeRic20-May-16 0:12 
GeneralRe: UDP communication and CRC16 calculations Pin
harold aptroot20-May-16 1:05
harold aptroot20-May-16 1:05 
QuestionEnableRaisingEvents automatically sets to false Pin
IT - Researcher19-May-16 21:58
IT - Researcher19-May-16 21:58 
QuestionMigrating C# desktop application to Windows 10 Pin
UnlockSecrets4WeightLoss19-May-16 19:19
UnlockSecrets4WeightLoss19-May-16 19:19 
AnswerRe: Migrating C# desktop application to Windows 10 Pin
Richard MacCutchan19-May-16 21:25
mveRichard MacCutchan19-May-16 21:25 
AnswerRe: Migrating C# desktop application to Windows 10 Pin
Richard Deeming20-May-16 1:47
mveRichard Deeming20-May-16 1:47 
QuestionBuild navigation with routed URL in ASP.NET MVC Pin
Member 1204569219-May-16 19:16
Member 1204569219-May-16 19:16 
AnswerRe: Build navigation with routed URL in ASP.NET MVC Pin
Richard MacCutchan19-May-16 21:24
mveRichard MacCutchan19-May-16 21:24 
QuestionASP.NET MVC. Specific URL for partial views Pin
Member 1204569219-May-16 14:02
Member 1204569219-May-16 14:02 
AnswerRe: ASP.NET MVC. Specific URL for partial views Pin
Richard MacCutchan19-May-16 21:23
mveRichard MacCutchan19-May-16 21:23 
QuestionHow can I download a picture in powershell and display it in C#? Pin
turbosupramk319-May-16 10:34
turbosupramk319-May-16 10:34 
AnswerRe: How can I download a picture in powershell and display it in C#? Pin
Richard MacCutchan19-May-16 21:22
mveRichard MacCutchan19-May-16 21:22 
GeneralRe: How can I download a picture in powershell and display it in C#? Pin
turbosupramk324-May-16 9:11
turbosupramk324-May-16 9:11 
QuestionRe: How can I download a picture in powershell and display it in C#? Pin
Richard MacCutchan24-May-16 9:23
mveRichard MacCutchan24-May-16 9:23 
AnswerRe: How can I download a picture in powershell and display it in C#? Pin
turbosupramk324-May-16 10:46
turbosupramk324-May-16 10:46 
GeneralRe: How can I download a picture in powershell and display it in C#? Pin
turbosupramk324-May-16 12:04
turbosupramk324-May-16 12:04 
QuestionIDisposable with COM Pin
hpjchobbes19-May-16 5:13
hpjchobbes19-May-16 5:13 
I have an application that uses a COM object to make a connection to an application. I need to make sure that when my application ends that I call the EndSession and CloseConnection methods of this COM object. I was reading this article: Implementing IDisposable and the Dispose Pattern Properly[^] as I think this is what I would need to do to make sure my closing code always gets called, but it doesn't seem to happen when I stop debugging. The application that I am connecting to still thinks my program is connected. It seems like when I stop debugging (or if I have a program crash, that the Dispose methods don't get called. I also tried to add a Finalizer but that causes a System.Runtime.InteropServices.InvalidComObjectException stating that the COM object that has been separated from it's underlying RCW cannot be used.


C#
private bool disposed;
protected virtual void Dispose(bool disposing)
{
    if (!disposed)
    {
        if (_Session != null) // _Session is the COM object.
        {
            _Session.EndSession();       // These are the COM functions to close and end the 
            _Session.CloseConnection();  // session that must be called, but this is where I
            _Session = null;             // get the InvalidComObjectException.
        }
        disposed = true;
    }
}
public void Dispose()
{
    Dispose(true);
    GC.SuppressFinalize(this);

}
~SessionConnection() // This was added, which seems to be the root cause of the COM exception
{
    Dispose(false);
}


I'm not sure what is the best way to ensure that the EndSession and CloseConnection methods of my COM object get called even if my program crashes or I stop debugging.
AnswerRe: IDisposable with COM Pin
Gerry Schmitz19-May-16 5:35
mveGerry Schmitz19-May-16 5:35 
AnswerRe: IDisposable with COM Pin
Dave Kreskowiak19-May-16 5:36
mveDave Kreskowiak19-May-16 5:36 
GeneralRe: IDisposable with COM Pin
OriginalGriff19-May-16 6:16
mveOriginalGriff19-May-16 6:16 
GeneralRe: IDisposable with COM Pin
hpjchobbes19-May-16 7:19
hpjchobbes19-May-16 7:19 
GeneralRe: IDisposable with COM Pin
Dave Kreskowiak19-May-16 7:23
mveDave Kreskowiak19-May-16 7:23 

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.