com-interop

Raise positive VB style error codes via COM interop from C#

守給你的承諾、 提交于 2019-12-07 18:12:31
问题 I have a base library created in VB6 that exposes a standard COM interface that is used in a number of applications. This also exposed a number of error code constants, used with Err.Raise to indicate certain conditions. Public Enum IOErrors IOErrorBase = 45000 IOErrorConnectionFailed IOErrorAuthFailed IOErrorNotConnected IOErrorInvalidPortDirection IOErrorGettingValue IOErrorNoValueYet End Enum Come on 10 years and we're creating C# objects implementing the same set of interfaces and want to

Custom COM class factory for managed in-proc server

假装没事ソ 提交于 2019-12-07 17:22:20
问题 I'm looking at implementing custom COM activation logic for a managed class library, in MkParseDisplayName/BindToObject manner. This way, creating an object from VB might look like this: obj = GetObject("clsid:12341234-1234-1234-1234-123412341234:!UniqueObjectId") That would not be a problem for an out-of-proc server (using CoRegisterClassObject ). However, for an in-proc server, I'd need to alter the implementation of DllGetClassObject , which is normally provided by mscoree.dll . Is this

Error activating IInterceptor… only through COM?

痴心易碎 提交于 2019-12-07 16:25:10
问题 TL;DR: Kernel.Get<T> works when called from a .net/WPF app, but blows up with an inner ActivationException (inside a TargetInvocationException ) when called from a VB6 app. WTH? This is a bit of a follow-up on this question where I configured an abstract factory with Ninject conventions, in such a way that I never need to actually implement one, the Ninject factory extension takes care of generating one on-the-fly. This worked beautifully... until I needed to run my library from VB6 code.

COMException (0x80010108 - RPC_E_DISCONNECTED) When Closing Excel.Workbook

杀马特。学长 韩版系。学妹 提交于 2019-12-07 14:22:33
问题 When I run the following code, I get the exception below: ''# NOTE: ExcelApp is a Private main form variable Dim ReportBooks As Excel.Workbooks = ExcelApp.Workbooks Dim ReportBook As Excel.Workbook = ReportBooks.Open(localFilename) Dim ReportSheet As Excel.Worksheet = ReportBook.Sheets("Report") ''# Retreive data from sheet ReleaseCOM(ReportSheet) ReportBook.Close(True) ''# Error raised here ReleaseCOM(ReportBook) ReleaseCOM(ReportBooks) ERROR: COMException was unhandled The object invoked

Inspecting an instance of a COM / Interop class properly in VS.Net's debugger?

故事扮演 提交于 2019-12-07 13:15:57
问题 Does anyone know if and how it's possible to see COM / Interop objects properly (in their correct type) in VisualStudio's debugger? All I get is the ' evil ' System.__ComObject value (even though it correctly identifies the type)? E.g.: 回答1: So, this isn't an answer, but check out these two screen shots. This is from the same application, just at two different break points. In both cases the COM objects are from the same COM/AX library. I've no idea why in one case I see "System.__ComObject"

How to clean up COM references in .NET when app will be left running?

旧时模样 提交于 2019-12-07 12:49:50
问题 I am working on a .NET program that starts a new instance of Excel, does some work, then ends, but must leave Excel running. Later, when the program runs again, it will attempt to hook into the previous instance. What is the best way to handle the releasing of COM objects in this situation? If I do not do a "ReleaseComObject" on the app object the first time, then on the second run get the active object, then finally release the com object, do I have a memory leak? The following simplified

Do the new NoPIA and Type Equivalence features in C#/.NET 4.0 mean Microsoft.mshtml.dll is no longer needed

安稳与你 提交于 2019-12-07 11:40:30
问题 I'm maintaining a WPF based application which contains a WinForms based WebBrowser control that based on the IE web browser control. When we deploy, we have had to also supply Microsoft.mshtml.dll and do some custom configuration stuff for our ClickOnce publishing process as well in order to get things to work. I'm curious that with the new NoPIA and Type Equivalence features and dynamic type capabilities in C# 4.0 can we expect that if we upgrade that we can remove the dependencies on the

Can a managed ref-class directly implement a COM interface?

匆匆过客 提交于 2019-12-07 09:49:26
Is there a built-in way to allow a managed ref-class to implement and expose a COM inerface that is safely callable from native code? Looking at the C# side, this is easily done by decorating the target interface with the proper COM-interop attributes, for example: Native Interface interface ISampleGrabberCB: public IUnknown { virtual STDMETHODIMP SampleCB( double SampleTime, IMediaSample *pSample ) = 0; virtual STDMETHODIMP BufferCB( double SampleTime, BYTE *pBuffer, long BufferLen ) = 0; }; static const IID IID_ISampleGrabberCB = { 0x0579154A, 0x2B53, 0x4994, { 0xB0, 0xD0, 0xE7, 0x73, 0x14,

Error closing Word doc: “The message filter indicated that the application is busy.”

泪湿孤枕 提交于 2019-12-07 08:42:24
问题 I'm using Microsoft Interop to save a Word Doc as an HTML file, and I'm getting this error when I try to close the document: The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) Here's my code: // word interop setting object visible = true; object readOnly = true; object missing = Type.Missing; object saveChanges = true; object htmlFile = (object)Server.MapPath(@"worddoc.html"); object fileType = (object)Microsoft.Office

COM Interop, RPC server is unavailable in c#

*爱你&永不变心* 提交于 2019-12-07 06:24:25
问题 I am using a COM Interop and i am instantiating the COM class object from the interop dll So, few times the object is instantiated successfully and make remote procedure calls without any problem but sometimes it throws an exception like RPC Server is unavilable. The COM Component i am using is written in VB and i am consuming that component in c#. So, can anybody tell me the possible reasons for the problem(RPC Server is Unavailable) and solutions to this problem. I am helpless with this