interop

How to marshal a variable sized array of structs? C# and C++ interop help

限于喜欢 提交于 2019-11-30 06:46:24
I have the following C++ structs struct InnerStruct { int A; int B; }; struct OuterStruct { int numberStructs; InnerStruct* innerStructs; }; And a C++ function OuterStruct getStructs(); How can I marshal this to C#? Where the C# definitions is struct OuterStruct { InnerStruct[] innerStructs; }; You'll have to do this manually, since there's no way to tell the P/Invoke layer how much data to marshal from your C++ return value. struct OuterStruct { int numberStructs; IntPtr innerStructs; }; OuterStruct s = getStructs(); // using DllImport var structSize = Marshal.SizeOf(typeof(InnerStruct)); var

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

CUDA/OpenGL interop, draw to OpenGL texture with CUDA

孤者浪人 提交于 2019-11-30 05:15:10
I am writing a rendering system in CUDA and want results to be quickly displayed via OpenGL, without touching main memory. I basically do the following: Create and initialize OpenGL texture, and register it in CUDA as cudaGraphicsResource GLuint viewGLTexture; cudaGraphicsResource_t viewCudaResource; void initialize() { glEnable(GL_TEXTURE_2D); glGenTextures(1, &viewGLTexture); glBindTexture(GL_TEXTURE_2D, viewGLTexture); { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA

Programmatically (C#) convert Excel to an image

China☆狼群 提交于 2019-11-30 05:11:14
I want to convert an excel file to an image (every format is ok) programmatically (c#). Currently I'm using Microsoft Interop Libraries & Office 2007, but it does not support saving to an image by default. So my current work-around is as follows: Open Excel file using Microsoft Interop; Find out the max range (that contains data); Use the CopyPicture() on that range, which will copy the data to the Clipboard. Now the tricky part (and my problems): Problem 1: Using the .NET Clipboard class, I'm not able to get the EXACT copied data from the clipboard: the data is the same, but somehow the

Visual Studio 2010 64-bit COM Interop Issue

风流意气都作罢 提交于 2019-11-30 05:04:59
I am trying to add a VC6 COM DLL to our VS2010RC C# solution. The DLL was compiled with the VC6 tools to create an x86 version and was compiled with the VC7 Cross-platform tools to generate a VC7 DLL. The x86 version of the assembly works fine as long as the consuming C# project's platform is set to x86. It doesn't matter whether the x64 or the x86 version of the DLL is actually registered. It works with both. If the platform is set to 'Any CPU' I receive a BadImageFormatException on the load of the Interop.<name>.dll . As for the x64 version, I cannot even get the project to build. I receive

New .NET 2.0 C++/CLI project has implicit dependency on mscorlib v4?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 04:49:37
问题 I created a new C++/CLI project in Visual Studio 2012, with .NET 2.0 selected as the framework on the project creation page. I have verified the "External Dependencies" (mscorlib.dll, System.Data.dll, System.dll, and System.XML.dll) show "Path" as being c:\Windows\Microsoft.NET\Framework\v2.0.50727\* . When adding a reference to this project from a C# .NET 2.0 project in the same solution, at build time the compiler cannot link against my C++ library with the following error: Warning 2 The

Copy cells in excel using C#

南笙酒味 提交于 2019-11-30 04:45:22
问题 How to copy to specific row in target sheet? I need to copy A1 to J10 from a sheet in one excel to location starting from A15 in second excel sheet. How can I achieve this in c#? In the below Copy method there seems to be no option to specify the location in target excel sheet. ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBookTemp.Sheets[1]; ObjWorkSheet.Copy(Type.Missing, ObjWorkBookGeneral.Sheets[1]); 回答1: I think you are using the wrong method here... you want to use a

interoperation between mercurial and subversion

倾然丶 夕夏残阳落幕 提交于 2019-11-30 04:44:28
A similar question has been asked recently, but is not the same. The Mercurial website has a detailed page listing comparisons for 4 different options for getting Mercurial and Subversion to interoperate. I am wondering if anyone out there has tried one or more of these, and could relate any really good or really bad experiences. The note on the hgsubversion download says hgsubversion is an extension for Mercurial that allows using Mercurial as a Subversion client. Right now it is not ready for production use. You should only be using this if you're ready to hack on it, and go diving into the

L prefix for strings in C++

依然范特西╮ 提交于 2019-11-30 04:37:33
问题 I have a static library. This library have the following function defined int WriteData(LPTSTR s) The sample to call the function is LPTSTR s = (LPTSTR) L"Test Data"; int n = WriteData(s); WriteData return 0 on success and -1 on failure. I am writing a dynamic DLL to export this function. int TestFun(LPTSTR lpData) { return WriteData(lpData); } A C++ test application result LPTSTR s = (LPTSTR) L"Test Data"; TestFun(s); //OK return 0 LPTSTR s = (LPTSTR) "Test Data"; TestFun(s); //Fail return

Assembly generation failed — Referenced assembly 'Interop.Office' does not have a strong name

六眼飞鱼酱① 提交于 2019-11-30 04:22:43
问题 I have a WPF 4 project to interact with word documents made in VS2010 and a win form User Control project to host word application into it. And other com dlls. All com dlls are referred into my main wpf application. I want to publish my project so I can install it on another machine and perform automatic update for it, I get error: "Assembly generation failed -- Referenced assembly 'Interop.Office' does not have a strong name. ". error for each COM Dll. A dll refer to (Interop.word.dll,