interop

interop Shapes.AddPicture creates incorrect dimension for image

五迷三道 提交于 2019-12-25 05:27:24
问题 I am using interop to create powerpoint presentation.i use Shapes.AddPicture to add images to slide. Shapes.AddPicture(strImagePath, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Convert.ToInt32(shape.Left), Convert.ToInt32(shape.Top), Convert.ToInt32(xmlTempNode.Attributes["imgwidth"].Value), Convert.ToInt32(xmlTempNode.Attributes["imgheight"].Value));//load new image to shape i am passing imageheight as 127, however final slide contains image with

AccessViolationException outside Visual Studio?

别来无恙 提交于 2019-12-25 04:52:04
问题 I'm developing a small C# winforms application that consumes an unmanaged C++ library. I have no access to the code of this library. If I'm in Visual Studio and I runt my application, do my calls to the library everything is working find. Once I run CTRL + F5 I get an AccessViolationException. I did some testing, created another winforms application in .NET 2.0 (others were in .NET 4.0) and there I don't receive the AccessViolationException. So I thought i'd create a .net 2.0 class library in

C# P/Invoke and array of structs containing byte arrays

泄露秘密 提交于 2019-12-25 04:46:35
问题 I need to invoke a native DLL from C# code. As I am not very familiar with C/C++, I can't figure out how a structure defined in C should be declared in C# so it can be invoked. The problem is that two parameters seems to be an array of structs, which I don't know how to declare this in C# (see last code block): c++ header file: typedef enum { OK = 0, //others } RES typedef struct { unsigned char* pData; unsigned int length; } Buffer; RES SendReceive(uint32 deviceIndex Buffer* pReq, Buffer*

.NET C#: Is it possible to import TLB (semi-)automatically and add PreserveSig to one type?

会有一股神秘感。 提交于 2019-12-25 04:42:56
问题 I have this large IDL that I am importing into a C# project. Everything was fine until I had to use one interface that is not quite compatible with HRESULT -> COMException conversion (I can go into details here but that shouldn't be relevant). Is it possible to add PreserveSig to that one type somehow? I would like to avoid the option of declaring all COM interfaces manually in C#. If there was a way to get a c# source file instead of assembly from tlbimp, that would suit me, but AFAIK there

Creating .msg file without COM Interop

可紊 提交于 2019-12-25 04:32:05
问题 I have some issues with the COM Interop, the company i'm working for refuse to add the COM dll on the server, so I can't send mail directly via Interop. I would like to know if there is an existing library that exist to create .MSG files, so I can save them in a folder? I tried to find one first, but it seems that we have to pay for them and of course the company refuse to pay :) Thanks in advance, 回答1: MSG file format is documented, so in theory you can access or create MSG files using

How to write numbers to a file and make them readable between Java and C#

时光怂恿深爱的人放手 提交于 2019-12-25 04:28:24
问题 I'm into a "compatibility" issue between two versions of the same program, the first one written in Java, the second it's a port in C#. My goal is to write some data to a file (for example, in Java), like a sequence of numbers, then to have the ability to read it in C#. Obviously, the operation should work in the reversed order. For example, I want to write 3 numbers in sequence, represented with the following schema: first number as one 'byte' (4 bit) second number as one 'integer' (32 bit)

WICBitmapSource.CopyPixels to GDI Bitmap Scan0

一世执手 提交于 2019-12-25 04:04:08
问题 I've modified the C# IWICBitmapSource.CopyPixels interface to allow both array marshaling and passing a pointer: void CopyPixels( WICRect prc, uint cbStride, uint cbBufferSize, [Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pbBuffer ); new void CopyPixels( WICRect prc, uint cbStride, uint cbBufferSize, IntPtr pbBuffer ); I'm calling it like this public static Bitmap FromWic(IWICBitmapSource source) { Guid format; source.GetPixelFormat(out format); PixelFormat gdiFormat =

Clr Dll loaded by test prog but not by calling app

人盡茶涼 提交于 2019-12-25 01:49:45
问题 I want to develop a plugin for a program (EXE) to interop with an external C# module. The plugin is one of the three dlls needed: this dll (A) calls a wrapper dll (Native/Managed, in C++/Cli) (B) to interop with a C# dll (C). A is supposed to be loaded by a calling program (EXE) when deployed. In testing, a message from the C# dll is displayed, which tells me dll A is correctly loaded by a C++ tester and subsequently has made successful call to other dlls. In deployment, dll A is loaded by

Close MS Office C# Console

强颜欢笑 提交于 2019-12-25 01:48:43
问题 I'm writing an automated test to determine whether or not rtf files are successfully opened by MS Word. So far I looping through all the rtfs within a given directory and opening them. Later I will have to catch exceptions to generate a report (log the file name that crashed word). I am processing a large number of files. My application is currently opening a new instance of Word for each file. Can someone tell me how to close Word? public class LoadRTFDoc { private object FileName; private

c# and excel automation - ending the running instance

十年热恋 提交于 2019-12-25 01:25:20
问题 I got the same problem. I read the whole thread and tried the examples given. I added these lines to the sample code: xlRange = (Excel.Range)xlWorkSheet.get_Range("B1", "C1"); xlRange.Merge(Type.Missing); xlRange = (Excel.Range)xlWorkSheet.get_Range("H5", "M5"); xlRange.Merge(Type.Missing); xlRange = (Excel.Range)xlWorkSheet.get_Range("N5", "V5"); xlRange.Merge(Type.Missing); xlRange = (Excel.Range)xlWorkSheet.get_Range("W5", "Z5"); xlRange.Merge(Type.Missing); // up to here everything seems