com-interop

How Do I serialize a COM object in .Net?

主宰稳场 提交于 2019-12-11 09:21:55
问题 I need serialize a Com Object using .net using c# or Delphi .Net is this possible? 回答1: You could probably do this by wrapping the COM object in a (serializable) .NET class, exposing the fields that you want serialized. 回答2: Check to see if you COM object implements IPersistStream, IPersistMemory or any other of the IPersist variants -- that would be your best bet. 回答3: You can get a Managed Object through GetObjectForIUnknown Method. And then, you can serialize this managed object. 回答4: Not

Merging two .IDL files or two .tlb files into one file

跟風遠走 提交于 2019-12-11 08:27:11
问题 I have 2 .net dll's which I expose to COM using REGASM. In order to simplify referencing within a COM client I would like to make these into one file. I have tried converting both files to IDL and then copying the contents of the Library section of one into the other and then compiling back to .tlb with MIDL. This works fine for the TypeDefs within the second IDL however it seems to fail when it comes to the interfaces I copied in. OLE/COM viewer can see the interface definitions but when I

Responsibility for memory deallocation in COM Interop

匆匆过客 提交于 2019-12-11 08:14:49
问题 I'm working on a C++ code consuming services provided by a .NET dll, which I'm accessing via COM Interop. I'm writing both the C++ and C# side. One of the methods that is exposed by the dll and is called from the C++, asks the dll to return an allocated byte array containing some information. After creating that method in my C# code, the .tlb generator exposed it as follows: HRESULT _stdcall DownloadData( [out] SAFEARRAY(unsigned char)* outputBuf); Testing has shown that when I send the

Best way to keep COM-exposed assemblies in sync with .NET-referenced assemblies

痞子三分冷 提交于 2019-12-11 07:59:40
问题 I have a C#, COM-exposed .NET assembly, which I use heavily as a library for VB6 clients (Office VBA). I am extremely happy with it. That same COM-exposed library is useful for me in some newer, .NET clients I have written as well. From Googling, the consensus is that the only way to do this is to reference the .NET libraries themselves (link 1, link 2), which I have done. When these .NET apps are deployed, VS naturally wants to bring my COM .NET assemblies with them. But I now have several,

Entlib and interop: does it work, and where does the config file go?

↘锁芯ラ 提交于 2019-12-11 06:53:46
问题 I'm trying to use the EntLib 3.1 within .net code for a dll which is registered for COM interop. Where do I put the config file? Alternatively, is there a way to specify within the dll code where it should get the entlib config from? Since my dll will be called from COM I don't always know what exe will be calling it. I created a simple app which uses entlib Logging, with two classes: 'CallingApp' and 'MyComThing'. When I call a method of MyComThing from CallingApp it logs using the

How-to: Remove text from Word document footer using C#

纵然是瞬间 提交于 2019-12-11 06:51:47
问题 I'm trying to remove a footer from a Word document using C# 4. The footer looks like this: Page 1 April 18, 2012 Actually, this the text for the footer when displayed in Word VBA: Page 1 ( April 18, 2012 There's actually a bullet character between "Page 1" and "April". In the end the footer should look like this: April 18, 2012 Anyway, in Word VBA, I'm able to do it using this code: Dim rngFtr As Range Set rngFtr = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range rngFtr

.Net to COM Interop Tester

五迷三道 提交于 2019-12-11 06:31:33
问题 I made a class in C# that I am exposing to COM. I can register it just fine using RegAsm.exe. I would like to test it before I send it off, but using TlbImp.exe gives me an error of "Type libaray was exported from a CLR assembly and cannot be re-imported as a CLR assemply." What is a good way to test this? 回答1: You can create a VB macros in word\excel\etc: Dim obj As Object Set obj = CreateObject("progid here") Call obj.SomeMethodForTest() 回答2: Use PowerShell: $myObj = new-object -comObject

Automation Error in VB 6.0 from a C# class

北城以北 提交于 2019-12-11 06:28:42
问题 I have created a C# class library and I am using it through a VB 6.0 application. But when I try to call any method (which returns a string) it gives me an automation error. The C# class is running fine otherwise. Any idea why? 回答1: As fbinder says, you should strong sign your assembly, and use some attributes. The attributes we use (successfully) are: [ComVisible( true )] [ClassInterface( ClassInterfaceType.None )] [Guid( "00000000-0000-0000-0000-000000000000" )] [ComDefaultInterface( typeof

How do I do COM Interop in Java?

江枫思渺然 提交于 2019-12-11 06:25:29
问题 I am a .NET programmer working with a Java Spring Boot project to create a REST API. I need to do some COM interop with an Excel spreadsheet from within the Spring Boot application. How do I go about doing that? I know the code to write. I just don't know the tools. Specifically, what jar files do I need to reference? Where do I get them from? 回答1: I would prefer https://poi.apache.org/ Otherwise you can use "Java Access Bridge", here is an overview https://docs.oracle.com/javase/8/docs

C# COM dll has REGDB_E_CLASSNOTREG error in C++ project

大憨熊 提交于 2019-12-11 05:52:24
问题 I have a C# dll that I properly have registered for COM Interop, and made COM visible. Using cppbuilder, I imported the type library, which generated the wrapper classes, and I am now attempting to use to create an instance of my C# class. However, I'm getting a REGDB_E_CLASSNOTREG error in my C++ code. I verified the dll is in the registry, and even re-registered it with regasm. No change. What could I be missing? Here is my C++ code: _MyClassPtr obj; HRESULT hr = obj.CreateInstance(__uuidof