interop

Getting the helpstring attribute applied to C# properties exposed via COM interfaces

风流意气都作罢 提交于 2019-12-18 04:14:33
问题 I'm currently working on a library that's to be exposed to COM for use in a legacy project that's being upgraded. I'm creating interfaces that are to be exposed, and they have properties on them with long, int, etc types. Using the DescriptionAttribute, I can get helpstrings generated in the .tlb for interfaces, classes, and methods, but for some reason it doesn't seem to want to work for properties. Is there anyway to get a helpstring generated in the TLB output for properties ? 回答1: You

Getting the helpstring attribute applied to C# properties exposed via COM interfaces

淺唱寂寞╮ 提交于 2019-12-18 04:14:11
问题 I'm currently working on a library that's to be exposed to COM for use in a legacy project that's being upgraded. I'm creating interfaces that are to be exposed, and they have properties on them with long, int, etc types. Using the DescriptionAttribute, I can get helpstrings generated in the .tlb for interfaces, classes, and methods, but for some reason it doesn't seem to want to work for properties. Is there anyway to get a helpstring generated in the TLB output for properties ? 回答1: You

DllImport - PreserverSig and SetLastError attributes

喜你入骨 提交于 2019-12-18 04:12:13
问题 On the MSDN I've found the following description for the two attributes: PreserveSig Set the PreserveSig field to true to directly translate unmanaged signatures with HRESULT or retval values; set it to false to automatically convert HRESULT or retval values to exceptions. By default, the PreserveSig field is true. SetLastError Enables the caller to use the Marshal.GetLastWin32Error API function to determine whether an error occurred while executing the method. In Visual Basic, the default is

DllImport - PreserverSig and SetLastError attributes

ぐ巨炮叔叔 提交于 2019-12-18 04:12:09
问题 On the MSDN I've found the following description for the two attributes: PreserveSig Set the PreserveSig field to true to directly translate unmanaged signatures with HRESULT or retval values; set it to false to automatically convert HRESULT or retval values to exceptions. By default, the PreserveSig field is true. SetLastError Enables the caller to use the Marshal.GetLastWin32Error API function to determine whether an error occurred while executing the method. In Visual Basic, the default is

How do I marshal a pointer to an array of pointers to structures?

本小妞迷上赌 提交于 2019-12-18 04:04:00
问题 I have a C function with the following signature: int my_function(int n, struct player **players) players is a pointer to an array of pointers to struct player objects. n is the number of pointers in the array. The function does not modify the array nor the contents of the structures, and it does not retain any pointers after returning. I tried the following: [DllImport("mylibary.dll")] static extern int my_function(int n, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] player_in [

Access VBA equivalent to a C# List<T>

不羁岁月 提交于 2019-12-18 03:45:36
问题 I have a COM-visible object written in C# that accepts a list of string arrays. Could I send a Collection of string arrays from Access 2000 to this object and it work? If not, then what is the best way to send multiple string arrays to my C# object from Access 2000? 回答1: You can't marshal generics but using Collection on the VB6 side is a workable solution. Effectively convert your List to a standard collection. Here's something that elaborates more: http://www.codeproject.com/KB/COM

Call function from DLL?

自闭症网瘾萝莉.ら 提交于 2019-12-18 03:03:29
问题 I'm new to C# and I'm trying to learn to usage of DLLs. I'm trying to wrap my objects in a DLL, and then use it in my program. public class Foo // its in the DLL { public int ID; public void Bar() { SomeMethodInMyProgram(); } } So I try to pack this to a DLL but I can't, because compiler doesn't know what the SomeMethodInMyProgram() is. I would like to use it like: class Program // my program, using DLL { static void Main(string[] args) { Foo test = new Foo(); test.Bar(); } } 回答1: Add the DLL

Excel Interop - Add a new worksheet after all of the others

三世轮回 提交于 2019-12-18 03:03:12
问题 I am trying to add a new worksheet to an Excel workbook and make this the last worksheet in the book in C# Excel Interop. It seems really simple, and I thought the below code would do it: using System.Runtime.InteropServices; using Excel = Microsoft.Office.Interop.Excel; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { var excel = new Excel.Application(); var workbook = excel.Workbooks.Open(@"C:\test\Test.xlsx"); workbook.Sheets.Add(After: workbook.Sheets

What should I know when developing interoperable WCF web service?

时光毁灭记忆、已成空白 提交于 2019-12-18 02:55:19
问题 I'm starting this Wiki to collect best practices about creating interoperable web services (not clients) in WCF. Please share your experience if you know any feature which is not generally interoperable or which is not interoperable with specific platform. 回答1: Fairly simple: avoid any .NET specifics like Exceptions (turn them into SOAP faults) don't use any binding that start with net like netTcp, netNamedPipes, netMsmq and so forth - use wsHttpBinding for secure WS-* services, and

C# Marshalling double* from C++ DLL?

ⅰ亾dé卋堺 提交于 2019-12-18 02:41:29
问题 I have a C++ DLL with an exported function: extern "C" __declspec(dllexport) double* fft(double* dataReal, double* dataImag) { [...] } The function calculates the FFT of the two double arrays (real and imaginary) an returns a single double array with the real an imaginary components interleaved: { Re, Im, Re, Im, ... } I'm not sure how to call this function in C#. What I'm doing is: [DllImport("fft.dll")] static extern double[] fft(double[] dataReal, double[] dataImag); and when I test it