Click here to Skip to main content
15,908,906 members
Home / Discussions / C#
   

C#

 
GeneralRe: string comparasion Pin
AndieDu21-Aug-08 15:30
AndieDu21-Aug-08 15:30 
AnswerRe: string comparasion Pin
Christian Graus20-Aug-08 21:54
protectorChristian Graus20-Aug-08 21:54 
GeneralRe: string comparasion Pin
AndieDu21-Aug-08 15:31
AndieDu21-Aug-08 15:31 
QuestionA COM Interop Question Pin
Xiaoming Qian20-Aug-08 21:21
Xiaoming Qian20-Aug-08 21:21 
AnswerRe: A COM Interop Question Pin
AhsanS20-Aug-08 21:37
AhsanS20-Aug-08 21:37 
AnswerRe: A COM Interop Question Pin
Green Fuze20-Aug-08 22:35
Green Fuze20-Aug-08 22:35 
GeneralRe: A COM Interop Question Pin
Xiaoming Qian21-Aug-08 19:04
Xiaoming Qian21-Aug-08 19:04 
AnswerRe: A COM Interop Question [modified] Pin
selcuks20-Aug-08 22:54
selcuks20-Aug-08 22:54 
Here is a code piece from Visio Code Librarian:

/// This method releases all references to a COM object. When
/// Visual Studio .NET calls a COM object from managed code, it
/// automatically creates a Runtime Callable Wrapper (RCW). The RCW
/// marshals calls between the .NET application and the COM object. The
/// RCW keeps a reference count on the COM object. Calling
/// ReleaseComObject when you are finished using an object will cause
/// the reference count of the RCW to be decremented.
/// param name="runtimeObject": The runtime callable wrapper whose
/// underlying COM object will be released.
private void NullAndRelease(object runtimeObject)
{
    try
    {

        if (runtimeObject != null)
        {

            // The RCW's reference count gets incremented each time the
            // COM pointer is passed from unmanaged to managed code.
            // Call ReleaseComObject in a loop until it returns 0 to be
            // sure that the underlying COM object gets released.
            int referenceCount = System.Runtime.InteropServices.
                Marshal.ReleaseComObject(runtimeObject);
    
            while (0 < referenceCount)
            {
                referenceCount = System.Runtime.InteropServices.
                    Marshal.ReleaseComObject(runtimeObject);
            }
        }
}
    finally
    {
        runtimeObject = null;
    }
}


I think you can also use this one for Excel too.

Regards,

Always keep the Murphy Rules in mind!

modified on Thursday, August 21, 2008 6:15 AM

GeneralRe: A COM Interop Question Pin
JoeRip21-Aug-08 2:26
JoeRip21-Aug-08 2:26 
Questionhi friends I need help Pin
Denver Thomas20-Aug-08 21:03
Denver Thomas20-Aug-08 21:03 
AnswerRe: hi friends I need help Pin
Christian Graus20-Aug-08 21:18
protectorChristian Graus20-Aug-08 21:18 
GeneralRe: hi friends I need help Pin
Denver Thomas20-Aug-08 21:52
Denver Thomas20-Aug-08 21:52 
GeneralRe: hi friends I need help Pin
Christian Graus20-Aug-08 22:29
protectorChristian Graus20-Aug-08 22:29 
GeneralRe: hi friends I need help Pin
Denver Thomas21-Aug-08 0:18
Denver Thomas21-Aug-08 0:18 
QuestionSQL srver 2000 and C# Connection error Pin
Gulfaraz20-Aug-08 20:52
Gulfaraz20-Aug-08 20:52 
AnswerRe: SQL srver 2000 and C# Connection error Pin
Blue_Boy20-Aug-08 21:12
Blue_Boy20-Aug-08 21:12 
QuestionHow do i? Pin
Silvyster20-Aug-08 16:05
Silvyster20-Aug-08 16:05 
AnswerRe: How do i? Pin
PIEBALDconsult20-Aug-08 16:40
mvePIEBALDconsult20-Aug-08 16:40 
GeneralRe: How do i? Pin
Silvyster20-Aug-08 16:44
Silvyster20-Aug-08 16:44 
GeneralRe: How do i? Pin
PIEBALDconsult20-Aug-08 17:17
mvePIEBALDconsult20-Aug-08 17:17 
GeneralRe: How do i? Pin
JoeRip20-Aug-08 18:09
JoeRip20-Aug-08 18:09 
GeneralRe: How do i? Pin
TheFM23420-Aug-08 18:52
TheFM23420-Aug-08 18:52 
QuestionDoes Boolean not need an Interlocked.Exchange method? Pin
JoeRip20-Aug-08 15:31
JoeRip20-Aug-08 15:31 
AnswerRe: Does Boolean not need an Interlocked.Exchange method? Pin
Christian Graus20-Aug-08 15:47
protectorChristian Graus20-Aug-08 15:47 
GeneralRe: Does Boolean not need an Interlocked.Exchange method? Pin
JoeRip20-Aug-08 15:52
JoeRip20-Aug-08 15:52 

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.