FAQ Database Discussion Community


C# COM-Interop dll for C++ COM dll doesn't work between 2 solutions

c#,c++,.net,com,interop
I am trying to reuse an interop DLL that compiled in one project on another, and it doesn't work. I'll elaborate: I compile the C++ COM DLL native_com_object.dll In the same solution I have a C# project called LocalComClient.dll that generates Interop.native_com_objectLib.dll to use the C++ native_com_object.dll. Last, I have...

Propagating errors from C# dll

c#,dll,interop
The main question is simple. I have a c# dll I created to act as a plugin for an access solution. What would be a proper OO design pattern for returning error information from the dll to the solution? I know I use to use things like SetLastError for dlls...

CUDA with OpenGL: all CUDA-capable devices are busy or unavailable

c++,opengl,cuda,interop
I am following the CUDA-by-example tutorial to set up OpenGL for graphics interoperation with CUDA. Here is what I'm following. When I get to the point of registering the buffer with CUDA runtime as a graphics resource and run the code, I get an error stating that all CUDA-capable devices...

Platform::Array^ to char* - conversion and memory

arrays,interop,c++-cx
I have a C code that I want to use in my Windows Store C# application. Not very good at C/C++ but can slam in few lines, so I have a problem and a question. One of the C source functions looks like: send_data(const char *data, size_t len) The wrapper...

Debugging a .NET COM DLL loaded by unmanaged C++ binary in Visual Studio

c++,.net,visual-studio-2010,com,interop
I'm using VS2010. I have an unmanaged EXE written in C++ that's using a .NET COM component which is also part of the same solution. I know that the COM object was created successfully because CoCreateInstance returned without an error. Yet, the component symbols aren't loaded (I can also notice...

Importing Microsoft.VisualStudio.Shell.Interop

vb.net,vba,import,interop
Just wondering how exactly to import this namespace, extensive searching yielded next to no information. The only VB snippet I found was this: http://www.getcodesamples.com/src/B1374D4/E6944922 and it doesn't provide any information on how to import. I want to use the iVsUIShell.FindToolWindow to get the IVsWindowFrame pointer in order to bring a...

Unable to get the Object property of the OLEObject class - Excel Interop

c#,excel,interop,office-2013
I have googled this problem and have not been able to come up with a solution. This code works if the file is saved as an .xls but not .xlsm. I am using Office 2013 (32-bit). I have written a C# class library that is COM exposed. The excel workbook...

C# string to Inno Setup

c#,interop,marshalling,inno-setup
I have a C# DLL in which exposes a method which generates a string. I want to call this Method from Inno Setup and receive the string then. function GetInformationEx():String; external '[email protected]{src}\data\tools\ZipLib.dll stdcall loadwithalteredsearchpath'; procedure ShowProgress(progress:Integer); var information : String; begin WriteDebugString('ShowProgress called'); if(progress > pbStateZip.position) then begin pbStateZip.position :=...

ShellExecute doesnt work if some parameters are just int type

c#,windows,shell,interop
I have the below code which is to launch any .exe (in this example its notepad.exe). But this code is not working. though there are no compilation issues. [DllImport("shell32.dll", CharSet = CharSet.Auto)] static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo); public static void exev() { SHELLEXECUTEINFO info = new SHELLEXECUTEINFO(); info.cbSize =...

Create Outlook meeting on SharePoint page

sharepoint,sharepoint-2010,outlook,interop,meeting-request
Is it posible to create outlook meeting on Sharepoint page behalf on current sharepoint user? I try to create meeting by button click with next code Application oApp = new Microsoft.Office.Interop.Outlook.Application(); AppointmentItem appointment = (AppointmentItem)oApp.CreateItem(OlItemType.olAppointmentItem); appointment.Start = DateTime.Now.AddHours(1); appointment.End = DateTime.Now.AddHours(2); appointment.Subject = "Some subject"; appointment.Body = "Some body"; appointment.Recipients.Add("[email protected]");...

Calling C# function from a C++/CLI function

c#,c++,c++-cli,interop,marshalling
My project requires me to use C# to provide a user interface to C++. One of the C++ function I call does a bunch of work and provides periodic progress updates through another "object." Here's a example of what I mean. C++ class AppDelegate : public ProgressDelegate { void AppDelegate::UpdateStatusText(const...

C++ and java , SQLITE server acces same Time

java,c++,sqlite,interop,server
I have a probleme, I need to create a dll for software un c++, this dll need to communicate with SQLITE. But at the same time I have Java application who need to communicate to the database too. So i need to create a server for taking the request from...

PInvoke with a void * versus a struct with an IntPtr

c#,interop,pinvoke
Imagine I have a function called Myfunction(const void * x); My C# declaration could be MyFunction(IntPtr x); Is this functionally and technically equivalent to struct MyStruct { IntPtr P; } MyFunction(MyStruct x); Or will there be a difference in how they are marshalled. I'm asking this because the library I'm...

Call native method from Swift that has uint8_t ** as output parameter

swift,pointers,interop,pointer-to-pointer
I have a C method with the interface size_t foo(uint8_t ** output) This gets imported to Swift as func foo(_ output: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>>) -> Int How can I call this method from Swift?...

Is this an ok way of calling a C++ function from C#?

c#,c++,interop,clr
I am not super experienced in interlanguage calls between C# and C++. However, I created a VS2013 solution with 2 projects. One project is a C# project. The other project is a C++ project (DLL with CLR). I would like to know if my example code looks ok? The example...

Why does my C++ interop works on .Net 4.5 but not on 4

c#,.net,windows,dll,interop
In my project, I have to use a third party C++ dll (not COM). I have developed an interface C# dll which is used by my main program. This is the setup : IDE : VS Express Desktop 2013 x64 Legacy.dll (C++) Interface.dll (C# .Net4.5 AnyCPU) Program.exe (C# .Net4.5 AnyCPU)...

How to get CustomDocumentProperties using Excel Interop?

c#,excel,interop,vsto
The below code is used to get the custom document properties for Excel workbook. var xlApp = Globals.ThisAddIn.Application; // This works in VSTO Excel Add-in var xlApp = new global::Microsoft.Office.Interop.Excel.Application(); // This doesn't work anywhere xlApp.Visible = true; global::Microsoft.Office.Interop.Excel.Workbook workbook = xlApp.Workbooks.Open(file, false, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,...

Where can I find Microsoft.Office.Interop.Word.dll (2010)?

c#,.net,dll,interop,ms-office
I got the sources of a .NET project that I am trying to compile. Although, the project uses the reference (namespace) Microsoft.Office.Interop.Word from Office 2010 that I cannot find anywhere. I was able to download the file microsoft.office.interop.word.dll but apparently the one from Office 2007 since it still doesn't compile...

BizTalk and COM+

.net,interop,biztalk,com+
We have a legacy CRM system which can only send out events to COM+ components. This is done via a component written in VB6 so it we are very limited in what we can do with it. We have a legacy custom written Delphi interop COM+ component which passes these...

Microsoft Interop OutLook C#- Cannot save attachments of type OLE

c#,outlook,interop,office-interop,com-interop
I have a C# program saving attachments from unread emails from Outlook mail box to a folder and the below line of code breaks(first line) for attachment types that are of OLE type with the error "Outlook cannot perform this action on this type of attachment"(Where 'it' is of type...

How to make a Swift String enum available in Objective-C?

objective-c,swift,enums,interop
I have this enum with String values, which will be used to tell an API method that logs to a server what kind of serverity a message has. I'm using Swift 1.2, so enums can be mapped to Objective-C @objc enum LogSeverity : String { case Debug = "DEBUG" case...

Exception HResult 0x800a03ec when trying to open Excel with Microsoft.Office.Interop.Excel.Workbooks.Open()

excel,wcf,windows-services,interop
Following Exception is thrown if I try to open an excel file on a client machine: Exception from HRESULT: 0x800A03EC Inner Exceptions: (empty) Stack Trace: at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter,...

How does Spark interoperate with CPython

scala,pandas,apache-spark,interop,pyspark
I have an Akka system written in scala that needs to call out to some Python code, relying on Pandas and Numpy, so I can't just use Jython. I noticed that Spark uses CPython on its worker nodes, so I'm curious how it executes Python code and whether that code...

VC++/CLI: How to prevent an unmanaged object from being destroyed when it goes out of scope?

c++,.net,visual-c++,c++-cli,interop
I have a third-party unmanaged C++ library which has two classes, let's call them ClassA and ClassB. ClassA has a method, let's call it getTheB(), which returns an instance of ClassB - it does not return a pointer to the instance, but the instance itself. I now wrote a managed...

C#: Cdecl DllExport with a pointer to class instance in the arguments

c#,c++,interop
I'm thinking of writing an addon for a software called SmartDVB. It requires me to export the following function (this is a c++ example): BOOL RegisterAddOn(UINT iAddOnId, IAddOnInterfaces *pInt, AddOnSettings &settings) { /* ... */ return TRUE; } Where IAddonInterfaces is an abstract class (interface): class IAddOnInterfaces { public: virtual...

Clojure interop with Java: how to call a class?

java,maven,clojure,interop,leiningen
I have a Java app that has a class at this address, inside a standard Maven layout: src/main/java/com/ollio/nlp/Transformer.java The class and method that I want looks like this: package com.ollio.nlp; public class Transformer { public String transform(String JSONInput) { I store the jar artifact locally in my Clojure app at...

Pass structure (or class) from C++ dll to C# (Unity 3D)

c#,c++,dll,plugins,interop
I am writing a wrapper to get some data from a sensor. While I have no problems with passing int, float and arrays of them, I have difficulties to grasp how to pass a structure. Code summary C++ side The structure is as follows: struct HandInfo { int id; float...

Interop service does not work with NuGet WatiN

c#,.net,interop,nuget,watin
I'm trying to use WatiN; I've installed the latest version through NuGet. Everything worked great, until I changed the EmbedInteropTypes to false - for some reason, I get a new error now; My system cannot locate Interop.SHDocVw. This triggers on the first line of the first test they feature on...

C++-Python Interop: Marshalling data faster

python,c++,interop,python-c-api
I'm working on an app that has a C++ and Python API, and am implementing an API call that needs to be used in both languages. Part of the data this API sends back is an array of structs representing color information: struct { float r; float g; float b;...

Interop between C++ classes inside an WinRT component

c#,c++,dll,windows-runtime,interop
Currently iam working on a WinRT dll component using native C++ to render directx and like to use this component in a C# project. The idea is to have one class (for example A) doing the drawing and exposing relevant public methods to WinRT. This is working fine. But now...

Excel file operations using interop in multithreaded C# application fails

c#,.net,multithreading,interop,export-to-excel
I've an application that automates some file related jobs. Every job is executed inside separate threads. One kind of job is exporting an Excel file to HTML format. I use Microsoft.Office.Interop.Excel namespace for this purpose. My application was working fine under Windows Server 2008 environment but we upgraded our server...

Align text in Excel cell with new line c#

c#,excel,styles,interop,excel-interop
How can I align the text in Excel when a cell has 2 lines? I tried this: for (int j = 1; j <= RowsCount; j++) { for (int i = 1; i <= 18; i++) { ws.Cells[j, i].Style.VerticalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Cells[j, i].Style.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; } } But this works...

SerialPort check CTS

c#,winapi,serial-port,interop
How to check CTS line value of opened SerialPort? Idea is to set this value from device on other side while using 3-wire serial interface without handshaking. Here is some code to start discussion (adapted msdn example): [DllImport("kernel32.dll")] static extern bool SetCommMask(IntPtr hFile, uint dwEvtMask); [DllImport("kernel32.dll")] static extern bool WaitCommEvent(IntPtr...

Run Java computation engine from .Net

java,vb.net,interop
I have a scenario where we have written a domain specific computation engine in Java as a part of a heavy-weight Swing application. So far so good. Emerging requirements now have us integrating part of this capability, namely the computation engine and its output, with another legacy product which is...

Casting Range.Value2 of Excel interop to string

c#,excel,interop
I import some values from Excel sheets in C# application. One column is a text basically but can contain any values. I used the following: Range range = ... // getting this from Excel, works fine string myString = (string)range.Value2; When the cell contains text, this is working. But when...

Interop Outlook - Sending Appointment from another mailbox

c#,email,outlook,interop,appointment
I have two mailboxes setup in Outlook. I'll refer to them as "[email protected]" and "[email protected]". I would like to use Interop to create and send an appointment to a specific email address calender, not just to the default outlook account. Currently, I have found a close solution from this source...

Convert C# string to C++ WCHAR* over COM

c#,c++,string,com,interop
I have a COM local server (implemented in C++) which I am trying to call from C# code. The method that's giving me trouble looks like this: HRESULT Foo([in] const WCHAR* bar); The parameter shows up in on the C# side as a ref ushort, but I want to pass...

Unable to assign formula to cell range in Excel

vb.net,excel,excel-formula,interop,excel-2010
Someone else's code in the project, that I am trying to fix up. listO.Range(i, j).FormulaR1C1 = FormulaMatrix(i, j) where FormulaMatrix(i, j) is always a String value. Whatever random/test value, I try with, is being assigned successfully, except when it is a formula, eg. =IF(LENGTH([@Units])>0;[@SalesAmount]-[@DiscountAmount]0) If I remove the = sign...

Unload addin .xla when uninstall Excel interop add-in

excel,interop,action,add-in,uninstall
I have an Excel interop module A (that display on the menu bar) which in turn load another Excel add-in B.xla when Excel is loaded. A is installed into Excel by an msi installer. B.xla is charged via AddIn addin = excelApp.AddIns.Add(xlaFile); if (!addin.Installed) addin.Installed = true; When I uninstall...

Calling overloaded scala case apply from java using java generic

java,scala,generics,interop
There are several methods I need to write in Java, most of the system is in scala. Interop is not much of an issue except for one case. I have a java method which takes a generic T in the call to a method, the generic being passed in is...

Immediate Access Violation when debugging Windows.Devices.Sensors project in Windows 7

c++-cli,interop
I have a large solution with 50+ unmanaged projects in it. I have recently added a project with managed code in it to the solution. The managed code accesses Windows.Devices.Sensors in a .NET dll. This dll is eventually wrapped by unmanaged code and called from another unmanaged project. My problem...

Need Clarification On Answer For Cleaning Up Excel Interop Objects Properly

.net,excel,interop,com-interop
In regards to the answer to the question here by Hans Passant... Clean up Excel Interop Objects with IDisposable ... He enlightened me to the fact that I don't need to follow the two dot rule... declaring all com objects so I can release via Marshal.ReleaseComObject when done with them....

How to enforce generic type with Kotlin interop

java,generics,interop,kotlin
I have method in Kotlin which returns an Rx Observable of a generic list: public fun getObservable(): Observable<List<FooBar>> { return Observable.just(theList) } Because the Kotlin list trait is defined as List<out T>, Java will see the return type as Observable<List<? extends FooBar>>. Is there a way do tell the Kotlin...

Get pages of word document

c#,.net,ms-word,interop
I'm trying to get all pages of MSWord document via Microsoft.Office.Interop.Word (I'm using C# in VS2012). What I would like to get is List< String > Pages, where index is the number of page. I understand (at least I think so) that there is no direct way to do that....

Print lists in a list to excel, randomly stops printing after 0.5-6 lists. Comexpection 0x800AC472

c#,string,excel,list,interop
First of all I have have some codes which is filling some lists of strings, after that it puts all the lists in 1 big list. Now when I want to print those lists in my excel sheets, it stops after pint half of the first list, or stops after...

Using Microsoft.Office.Interop.Outlook without Outlook Client installed

c#,outlook,interop,office-interop
I'm trying to enumerate Outlook Global Address List and I don't have Outlook Client installed on a development server. I'm getting following error An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error:...

The type 'System.Runtime.InteropServices.SafeHandle' exists in both 'System.Runtime.InteropServices.dll' and 'System.Runtime.Handles.dll'

c#,dll,reference,compiler-errors,interop
I'm currently porting a Windows 8.1 app to a Windows 10 UAP app which uses interop to communicate between C++ and C# and I'm having the following error popping up : $(ProjectName).Interop.g.cs : error CS0433: The type 'System.Runtime.InteropServices.SafeHandle' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5.1\System.Runtime.InteropServices.dll' and 'c:\Program Files (x86)\MSBuild\Microsoft.NetNative\x86\ilc\lib\McgDependencies\System.Runtime.Handles.dll' From...