com-interop

How to invoke a method of a private COM interfaces, defined in a base class?

╄→гoц情女王★ 提交于 2019-11-30 09:07:31
问题 How can I invoke a method of a private COM interface, defined in a base class, from a derived class? For example, here is the COM interface, IComInterface (IDL): [ uuid(9AD16CCE-7588-486C-BC56-F3161FF92EF2), oleautomation ] interface IComInterface: IUnknown { HRESULT ComMethod([in] IUnknown* arg); } Here's the C# class BaseClass from OldLibrary assembly, which implements IComInterface like this (note the interface is declared as private): // Assembly "OldLibrary" public static class

an unhandled win32 exception occurred in w3wp.exe

↘锁芯ラ 提交于 2019-11-30 08:57:06
I get the following exception when trying to load an ASP.NET MVC website: Unhandled exception at 0x07070a91 in w3wp.exe: 0xC0000005: Access violation reading location 0x00000000. The Visual Studio Just-In-Time Debugger opens and the only information I can see in the debugger is this: Call stack location: msvbvm60.dll!06c00a91() The website uses some COM objects and everything worked fine until last week. This problem appeared out of the blue. This is the error log from Windows Event Viewer: Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8 Faulting module

How does COM select how to marshal an interface?

拥有回忆 提交于 2019-11-30 05:25:16
As I get it there're three ways to implement marshalling in COM: typelib marshalling proxy/stub marshalling implementing IMarshal by the object now how does the component consumer (user) choose which one will be used? Does it decide on its own and use the preferred way or does it call some built-in function and it solves the problem for it? I currently experience the following: my component implements a custom interface ICustomInterface that is also implemented by a component from another company. My component doesn't have a typelib and doesn't implement IMarshal. The system registry contains

Passing strongly typed arguments in .NET COM interop

人盡茶涼 提交于 2019-11-30 04:57:50
问题 I have two .NET classes exposed via COM interop - let's say Foo and Bar, and I need to pass an argument of type Foo to a method defined in Bar. Something like this: [ComVisible(true)] public class Foo { // whatever } [ComVisible(true)] public class Bar { public void Method(Foo fff) { // do something with fff } } When I run the following VBS (using cscript.exe): set foo = CreateObject("TestCSProject.Foo") set bar = CreateObject("TestCSProject.Bar") call bar.Method(foo) I get an error: D:\test

COMException (0x800A13E9) - Word interop services

允我心安 提交于 2019-11-30 03:49:05
问题 I am getting this stacktrace: System.Runtime.InteropServices.COMException (0x800A13E9): Word ðú÷ì ááòéä. at Microsoft.Office.Interop.Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible) at Crm.DocumentGeneration.Printing.DocumentsPrinter.MergeDocuments(ApplicationClass& wordApp, IEnumerable`1 printDataItems, String tempDirectory, String template) in C:\Work\Danel.Nursing\Crm.DocumentGeneration.Printing\DocumentsPrinter.cs:line 249 After googling a

CoInitialize() / CoUninitialize() calls pairing

不羁岁月 提交于 2019-11-29 17:51:51
I have a single-threaded application that uses COM objects. At the beginning I in effect call CoInitialize(0) twice - once in my code and the second time in the code of another subsystem of the application. The first call returns S_OK , the second returns S_FALSE - exactly as MSDN says. When the application stops it calls CoUninitialize() twice but between those calls it tries to call methods of some COM objects - those calls just crash with access violation because I suppose the COM objects are finalized and released at the first call to CoUnitialize() . If I remove the duplicating calls to

Lots of build warnings when COM objects ActiveDs or MSXML2 are referenced

ぃ、小莉子 提交于 2019-11-29 17:37:28
问题 After moving a project from .NET 1.1 to .NET 2.0, MsBuild emits lots of warnings for some COM objects. Sample code for test (actual code doesn't matter, just used to create the warnings): using System; using System.DirectoryServices; using ActiveDs; namespace Test { public class Class1 { public static void Main(string[] args) { string adsPath = String.Format("WinNT://{0}/{1}", args[0], args[1]); DirectoryEntry localuser = new DirectoryEntry(adsPath); IADsUser pUser = (IADsUser) localuser

Do I need to release the COM object on every 'foreach' iteration?

好久不见. 提交于 2019-11-29 17:10:13
问题 Here's the (potential) problem: I create a COM object, and then use a 'foreach' to iterate through each element in a collection it returns. Do I need to release each individual element I iterate through in the collection? (See code below.) If so, I can't think of a way to effectively to release it from within a 'finally' statement, just in case there is an error as the item is being operated upon. Any suggestions? private static void doStuff() { ComObjectClass manager = null; try { manager =

Setting up a DLL for registration-free COM Interop with C# / Managed code

ⅰ亾dé卋堺 提交于 2019-11-29 15:59:41
I am new to COM and have to create a COM wrapper for a C++ dll, to make some functionality in it accessible for managed code. I mainly followed this tutorial on code project to create a COM ATL dll. I created a post-build-step that calls tlbimp.exe on the COM dll to create the wrapping. Adding a reference to the dll that tlbimp.exe creates works, and I get code completion for methods on my COM dll, and can compile managed code that uses that dll. However, running that code leads to the following exception: Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM

How to get specific Range in Excel through COM Interop?

安稳与你 提交于 2019-11-29 14:32:29
问题 i have the following problem. I have to read an excel file through COM interop. I am new to programming with COM interop. I search for a specific string using this: this.sheet = (Excel.Worksheet)this.excelApp.Workbook.Sheets.Item[this.sheetname]; this.sheet.Activate(); Excel.Range firstRow = this.sheet.Range["A1", "XFD1"]; Excel.Range foundRange = firstRow.Find( this.StringISearch, Type.Missing, Type.Missing, Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns, Excel.XlSearchDirection