interop

Safety of passing HBITMAP handle from unmanaged to managed code for created a System.Drawing.Bitmap

两盒软妹~` 提交于 2019-12-07 22:43:16
问题 I'm pretty new to managed/unmanaged interop, so I'm looking to get some opinions on how safe the following procedure is for getting a bitmap from unmanaged C++ to managed C#. The basic idea is: C# calls an interop function, FetchImage , which is in the unmanaged C++. It passes an out int param. FetchImage has a corresponding long * param. In C++, FetchImage creates a CBitmap somewhere safe, ie not local, draws something on it, uses HandleToLong() to convert the bitmap's HBITMAP handle to a

passing a complex object in c++ to c# through COM

好久不见. 提交于 2019-12-07 20:15:27
This question expands on the existing question here: Passing an object from C++ to C# though COM The previous question deals with a simple object, but I would like to do the same for a complex object. So instead of TestEntity1 having a single property, if it has another property of type TestEntity2, how can I assign the property of type TestEntity2 of the TestEntity1 object in c++ consumer? C#: using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace ClassLibrary1 { [ComVisible(true)] public interface ITestEntity1 { string Name { get;

Java connection to / between Microsoft Windows Office Suite?

我与影子孤独终老i 提交于 2019-12-07 19:44:24
问题 I read elsewhere (a response by "hazzen" here) that .NET has "a binding for the entire Office suite outlined here that allows you to write COM-based methods that you can call from Office. It is intended for automation, but you can write any managed code you want and have Excel call into it." I'm interested in the same thing for Java. My present solution runs a standard Windows program that launches Java, whereupon any results are essentially sent to standard out and the intermediate program

Retrieving table data from a doc file using c#

笑着哭i 提交于 2019-12-07 19:16:52
问题 I am working on a project which involves getting data from a .doc or a .docx file. The input requirements are in a tabular format. Is it possible to retrieve data from table in a row wise manner or as a dataset.I am using Microsoft.Office.Interop.Word to get the data from the doc file. 回答1: You can use the property Tables of the Document interface to get a collection with all the tables in your document. For each Table in this collection you can get the rows and for each row the cells. I.e.

WPF ComboBox doesn't stay open when used in a Task Pane

时间秒杀一切 提交于 2019-12-07 18:31:01
问题 I have a strange bug with WPF Interop and an Excel Addin. I'm using .Net 3.5 SP1. I'm using Add-in Express to create a Custom Task Pane for Excel 2003. Within that taskpane I'm using ElementHost to host a WPF UserControl. The UserControl simply contains a Grid with a TextBox and ComboBox. My problem is that whilst everything displays properly, the ComboBox won't stay dropped-down unless I hold the mouse down over the down-arrow. I don't believe this is necessarily related to Add-in Express

Using .NET class from native C++ using C++/CLI as a 'middleware'

纵饮孤独 提交于 2019-12-07 18:08:56
问题 I have to use a class/assembly made in C# .NET from native C++ application. I suppose I need to make a wrapper class in C++/CLI, that would expose native methods in header files, but use .NET class as needed. Thing that's unclear to me is how to convert data types from .NET to standard C++ types. Does anybody have some sample code to learn from? Only text I have found on this is: http://msdn.microsoft.com/en-us/magazine/cc300632.aspx But text is very old (using Managed C++, not C++/CLI), and

Marshalling of C Struct as return value of C# delegate

元气小坏坏 提交于 2019-12-07 18:01:30
问题 I'm attempting to return a small (8 byte) struct by value from a delegate bound to a native function, but am running into the following error when targeting the .NET Framework 2.0 (the code seems to work correctly when targeting 4.0+): An unhandled exception of type 'System.AccessViolationException' occurred in testclient.exe Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. I suspect I've messed up the managed type

Is it possible to share code between a Silverlight web app and Windows Phone 7 app

↘锁芯ラ 提交于 2019-12-07 15:28:05
问题 I have a simple Silverlight app that I want to run on Windows Phone 7 almost exactly as is. I've created a new Windows Phone 7 project and when I reference the Silverlight app I get a warning that says "Adding a reference to a Silverlight project might not work properly. Do you want to continue?". If I continue and try to run anyway, the WP7 project never starts or sometimes I get "AG_E_PARSER_BAD_TYPE error" and it points to the line in the xaml I used a control from the Silverlight project

How to Call Clojure Code From Java

为君一笑 提交于 2019-12-07 14:37:38
问题 My professor allowed me to practice both Clojure and Java! I'm definitely using the opportunity and want to have my first Java assignment call some Clojure code. Before I go to the actual assignment, I want to create a simple, working example. I need your help. I have read a few links on Java/Clojure interoperability. This, and This. I will use the first link to demonstrate what I have done so far: 1) I have created a Clojure Project, dumped the .cli file from the site in it and use the

COMException (0x80010108 - RPC_E_DISCONNECTED) When Closing Excel.Workbook

杀马特。学长 韩版系。学妹 提交于 2019-12-07 14:22:33
问题 When I run the following code, I get the exception below: ''# NOTE: ExcelApp is a Private main form variable Dim ReportBooks As Excel.Workbooks = ExcelApp.Workbooks Dim ReportBook As Excel.Workbook = ReportBooks.Open(localFilename) Dim ReportSheet As Excel.Worksheet = ReportBook.Sheets("Report") ''# Retreive data from sheet ReleaseCOM(ReportSheet) ReportBook.Close(True) ''# Error raised here ReleaseCOM(ReportBook) ReleaseCOM(ReportBooks) ERROR: COMException was unhandled The object invoked