com-interop

“DLL caused an exception” when calling a method that references another DLL

我与影子孤独终老i 提交于 2019-12-24 14:07:50
问题 I developed a DLL, let's call it DomainLogic.dll , with some public methods through [DllExport] annotation. Some of those methods make calls to another DLL, let's call it Utils.dll . I developed a demo WinForm application with some buttons that call methods of DomainLogic.dll and everything works as expected. Currently we have a partner which wants to call our DomainLogic.dll from their existing Visual FoxPro application. They were able to successfully call dll methods that receive and return

Return byte array from C# to VBScript via COM interop

可紊 提交于 2019-12-24 08:57:22
问题 I have C# method that returns a byte array I want to be able to access from VBScript. More or less: namespace ClassLibrary7 { [ClassInterface(ClassInterfaceType.AutoDual)] [Guid("63A77D29-DB8C-4733-91B6-3CC9C2D1340E")] [ComVisible(true)] public class Class1 { public void Create( out byte[] BinaryData ) { // do some work and return BinaryData BinaryData = new byte[] { 1, 2, 3, 4 }; } } } and the vbscript to look like: dim o dim b set o = wscript.CreateObject("ClassLibrary7.Class1") o.Create b

When activating OLEControl in my PowerBuilder application, toolbar items disappear

耗尽温柔 提交于 2019-12-24 05:10:26
问题 I have created a COM Interop Control in C# to use in my PB application. If I add an ole control to my userobject and select my C# object in the painter, then an olecustomcontrol is created and everything works as expected. However, in order to use a 64-bit version of my object when building the project for a 64-bit platform (in PB Classic 12.6) I added an ole control but hit cancel when asked to select an object, so an olecontrol is created and I can use InsertClass to select my object at

Issues Using Midl to create a .tlb from .idl “expecting a type specification”

[亡魂溺海] 提交于 2019-12-24 04:17:12
问题 I have been having a prolonged encounter with the beast known as COM Interop... I am currently trying to generate a .tlb from a .idl file generated by the OLE/COM Object Viewer. However when trying to run Midl.exe to compile it I get an error: .\Sim.API.IDL(236) : error MIDL2025 : syntax error : expecting a type s pecification near "ImportFileStatus" My .idl file is more that 1000 lines long so I don't particularly want to post it here however, I believe the Part of interest is: typedef [uuid

Event handling at calling a third party 32-bit dll from a 64-bit c# WinForms application

旧城冷巷雨未停 提交于 2019-12-24 03:59:08
问题 We have an old 32-bit Visual Studio C# Windows Forms solution, which we want to compile from now on, in 64-bit. Unfortunately, our application uses some external dll-s (for scanners, cameras and so on) which are available only in 32-bit version. Accessing 32-bit DLLs from 64-bit code isn't straightforward, especially, when we want to handle also the events raised by those dll-s. Our knowledge at this area is unsufficient for creating an implementation based on this article, so we are looking

On Windows, with a C# authored COM server, can one return a SAFEARRAY both for early bound and late bound code?

被刻印的时光 ゝ 提交于 2019-12-24 01:07:40
问题 The question is quite long, so I'll format with bullet points for easier discussion Introduction I'm writing a C# COM Server. the COM server is for use in Excel VBA both in early binding and late binding modes. My stumbling block is how to return a SAFEARRAY of instantiated classes that works both in early and late binding mode; I get errors. I have done plenty of work on this (all day): I have done some diagnostics and setup the debugger to shed light on the errors I get. I have done some

Office (Excel) COM interop on Mac OSX using .NET Core?

孤者浪人 提交于 2019-12-24 00:57:18
问题 I work for a team that currently specializes in creating windows desktop applications in C#/.NET that interwork with local user instances of Microsoft Excel via Office COM Interop. I am currently charged with specifying a new product but I’ve been told that the project will not go ahead unless the app can run on Mac as well as Windows – that is, we have to be able to produce a Mac version of the app that can install natively on OSX and interact with the object model of a user’s instance of

Building an COM-interop enabled project without registering it during build

只谈情不闲聊 提交于 2019-12-24 00:51:07
问题 In Visual Studio 2010, I'm trying to build an COM-interop enabled C# project without registering it during build, but I DO require the assembly's typelibrary (.tlb) file, so I can import it from another C++ project in the solution. I haven't found a way of doing this - there once upon a time was a tlbexp.exe tool, but it was deprecated in favor of regasm.exe /tlb (which unlike tlbexp.exe, registers it). 回答1: tlbexp is still available in VS2010 here: C:\Program Files\Microsoft SDKs\Windows\v7

Implementing ISupportErrorInfo on a C# object exposed to COM

醉酒当歌 提交于 2019-12-24 00:34:00
问题 I'm writing a COM object in C# and I'd like to raise errors to vba/asp client software using the mechanism it understands - the Err object. In good ol' days that would have meant implementing ISupportErrorInfo on the COM object but I can't find any information about how to implement that interface in a C# object. Can anybody help? thanks! 回答1: You should be able to simulate this by throwing a custom exception from the Managed code. All CCW's automatically implement ISupportErrorInfo

Printing with Silverlight and com-interop

谁都会走 提交于 2019-12-23 17:33:14
问题 I'm trying to print from silverlight without a print dialog and for that I'm using System.Runtime.InteropServices.Automation; Right now I'm creating a temporary txt file that contain the text to send to printer. using (dynamic fso = AutomationFactory.CreateObject(@"Scripting.FileSystemObject")) { dynamic file = fso.CreateTextFile(cFileName, true); file.Write(printText); file.Close(); } After that I'm using shell.Aplication to print that document. dynamic shell = AutomationFactory.CreateObject