rcw

Removing CompilerOptions directive for an interop

I've created an interop for a COM dll via tlbimp and added it to the assembly cache. To use this in an ASP.net page i need to include the following <%@ Page Language="VB" Debug="true" CompilerOptions='/R:"C:\Program Files\blah\blah\LIBRARY.dll"'%> <%@ Import Namespace=LIBRARY %> Why do i need the CompilerOptions directive if it's in t...

What is the difference between an Interop and a RCW (Runtime Callable Wrapper)?

Is it just terminology? ...

Fastest way to call a COM objects method without using a RCW

I'm trying to find the cleanest and fastest way for calling a COM objects methods. I was using a RCW for the object but every time a new version of the third party COM object comes out its GUID changes which then renders the RCW useless, so I had to change and start using Type mytype = Type.GetTypeFromProgID("MyCOMApp.Application");...

C# wrapper interface error: E_NOINTERFACE

I am trying to produce a C# wrapper for a COM object that I have (named SC_COM.dll), but am having some issues linking it with Visual Studio 2008 (running Vista). I need to do this registration-free with the COM DLL--I'm using a manifest file to let Visual Studio know about SC_COM.dll, and that appears to be working. I used TblImp.exe ...

VS2008 UnitTesting - detached RCW with Office Application objects (PowerPoint, etc.)

BACKGROUND I am automating an PowerPoint 2007 via C# I am writing unittests using the built-in unit testing of Visual Studio (Microsoft.VisualStudio.TestTools.UnitTesting) for my code I am well relatively experienced in automating the Office 2007 apps MY PROBLEM When I run my unit tests, the first unit test method runs fine, all af...

C# 2005 COM and .NET Access Denied 0x80070005 E_ACCESSDENIED

I am rewriting a C++ app in C# 2005. The App has 2 components: one out-of-process COM server which can be started by a C++ service. The COM server uses outgoing interface, meaning it invokes event handler method from the C++ service module upon certain event. I am rewriting the C++ service part. Right now I have jut developed an app t...

Code Coverage in VS2008 on .net runtime callable wrappers

I have a .DLL which contains .NET Runtime callable wrappers for COM/DCOM objects. I have written a testing suite in C# in VS 2008 which calls our server functions which are in the abovementioned .DLL. When code coverage was turned on and testing suite ran, code coverage test results did not yield any statistics and displayed zeroes for...

Does a wrapper class calling a COM component through C# need to implement the Dispose pattern?

I have a class written in c# which is acting as a wrapper around a COM component. The COM component is early bound and the RCW has been generated by Visual Studio. Should I implement a dispose pattern in my wrapper class to clean up the COM reference, or should I just let the GC handle it, as it already has a RCW? ...

Releasing a COM object reference safely from .NET

I have read a lot of articles on the net about releasing RCW's safely, and it seems to me that no one can agree on exactly what needs to be done in what order, so I'm asking you guys for your opinions. For example, one could do this: object target = null; try { // Instantiate and use the target object. // Assume we know what we ...

Why a RaceOnRCWCleanup error when closing a form with WebBrowser control on it?

VS2008, .NET 2, VB.NET, XP ... I have a Windows form, with a WebBrowser control and a Close button, which just does a Me.Close. The form's cancel button is set to the Close button, so that I can hit ESC to close the form. I set the DocumentText property of the WebBrowser control in the load event, and the HTML displays. Running the ...

When does the .NET runtime hold a reference count > 1 for COM objects?

Until recently, I believed that the .NET runtime only increases the reference count of COM objects by 1 when creating a runtime-callable wrapper, and that only one such runtime-callable wrapper is created for any given COM object. If I'm not mistaken, the above implies that Marshal.FinalReleaseComObject and Marshal.ReleaseComObject do t...

How do i transfer this unmanaged code from asp to asp.net 2/mvc?

hi guys, i'm a newbie to ASP.net interop features, so what i have right here is some unmanaged dll that i need to call from my asp.net mvc app. the dll name is CTSerialNumChecksum.dll. i can easily call the dll from asp using just those two lines below and from my trusty response. write everything is working fine. set CheckSumObj = Ser...

Addref on COM RCW

Is it possible to increase the RCW reference count on an unknown interface? (i.e. not the reference count on the underlying COM object) I have some old COM server code int Method1(object comobject) { try { // do something with comobject return 0; } finally { Marshal.ReleaseComObject(comobject); }...

C#: Why am I still getting an RCW error when exiting my application?

To be specific, the error is: An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss. The application in question is a small applet that displays the current clock speed of the CPU as a system tray icon. I...

How to use different credentials with several COM objects (via RCW) in .NET

My understanding is that as soon as .NET fires up the RCW to access a COM object, the security credentials are persisted within the COM context until the .NET application is closed... thereby preventing the use of different credentials later on during execution. There is a RCW wrapper on Codeplex that I think will allow me to take a giv...