interop

In C#, how do I invoke a DLL function that returns an unmanaged structure containing a string pointer?

I have been given a DLL ("InfoLookup.dll") that internally allocates structures and returns pointers to them from a lookup function. The structures contain string pointers: extern "C" { struct Info { int id; char* szName; }; Info* LookupInfo( int id ); } In C#, how can I declare the structure layout, declare ...

Referencing Google's V8 engine from a .NET app

I'm building a .NET 3.5 application and have the need to evaluate JS code on the server - basically a user provided rule set that can work within a browser or on the server. Managed JS is not an option, because the JS code would be provided at runtime. Aptana's Jaxer is also not an option. So I was looking into using a build of the V8 en...

Access x86 COM from x64 .NET

I have an x64 server which, since my libraries are compiled to AnyCPU, run under x64. We are needing to access a COM component which is registered under x86. I don't know enough about COM and my google searches are leading me nowhere. Question: Can I use a symbolic registry link from x64 back to x86 for the COM component? Do I need t...

Entlib and interop: does it work, and where does the config file go?

I'm trying to use the EntLib 3.1 within .net code for a dll which is registered for COM interop. Where do I put the config file? Alternatively, is there a way to specify within the dll code where it should get the entlib config from? Since my dll will be called from COM I don't always know what exe will be calling it. I created a simp...

Interop'ing between C# and an unmanaged C library

I have a small C library in a DLL and I need to call a handful of its methods. It uses pointers and a few structs but is otherwise quite simple. Problem is I'm not terribly knowledgable on .NET's interop with the unmanaged world and my attempts so far keep hitting memory access violation exceptions (presumably due to me not getting the ...

JavaFX and java

Simple question...Can I mix in my desktop application java and javafx code? If it is possible could you provide me with some link with examples? Or could I pack my custom made javafx CustomNode-s in a jar and use them in my project side by side with standard SWING components? ...

Building an OCX with VS.NET?

What happened to OCX's? Are they no longer possible to create with the latest tools? I need to create an ActiveX control that I can place in Word, PowerPoint and Excel documents. If I use VS.NET, I can only create a UserControl DLL with COM Interop, but I don't think I can add that using the "More Controls" toolbox of PowerPoint's Devel...

Is it possible to test a COM-exposed assembly from .NET?

I have a .NET assembly which I have exposed to COM via a tlb file, and an installer which registers the tlb. I have manually checked that the installer works correctly and that COM clients can access the library. So far, so good... However, I am trying to put together some automated system tests which check that the installer is working...

Runtime C# knowing if 32-bit or 64-bit version of COM Interface is being used

I want to build a DLL Class Library use COM Interop, with C#, target ANY CPU, and register it as 32-bit and 64-bit interfaces. I want to be able to, at runtime, display what interface was used - if I am using the 32-bit version, or 64-bit version. Any ideas? ...

C# COM DLL - do I use REGASM, or REGSVR32?

I am building a C# ActiveX DLL... do I use REGASM or REGSVR32 to register it? How do I register the 64-bit interface vs the 32-bit interface? ...

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

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 l...

How to preserve COM DLL version in an auto-generated interop assembly in VS2005?

I've added a reference to a co-worker's COM DLL -- MyLogic.dll -- to my C# project in Visual Studio 2005. As expected, this auto-generates Interop.MyLogicLib.dll in my output folder. However, the version number of the COM DLL is 2.1.0.180, whereas the version number of the auto-generated interop assembly is 1.0.0.0. How do I get Visual S...

VMware VIX API FindItems() method never returns when querying for registered VMs

Hi, I am using VMware Workstation 6.5 on Windows Vista x64. I am trying to write some C# code that uses VMware Vix v1.6.1 COM API to get a list of registered virtual machines. The code I am using is as follows: using System; using VixCOM; namespace ConsoleApplication48 { internal class Program { private static void Main(...

System.Runtime.InteropServices.ComTypes.IStream to System.IO.Stream

In a .NET 3.0 project, I need to make some calls via P/Invoke (specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ). The framework has a managed definition of the COM IStream interface: System.Runtime.InteropServices.ComTypes.IStream I need this as System.IO.Stream so that I can easily use .NET clas...

Strange DLL + InterropServices problem

I'm trying to learn the basics of tying up unmanaged C++ and .NET. So, I've got the DLL compiled and callable from C#. Great. Now I run into this weird problem: Here's my C++ file, Main.cpp: #include <stdio.h> extern "C" __declspec(dllexport) void DisplayHelloFromDLL() { printf ("Hello from the World of 1986!\n"); } and C# file,...

.NET Interop: Find All instances of of a running COM object with C#

Background I am automating some Office application (Word and PowerPoint) via command-line tool. One thing my tool needs to do is locate all the running instances of Word. I know how to get a reference to one of the instances... Object running_obj = null; { running_obj = System.Runtime.InteropServices.Marshal.GetActiveObject(progi...

When should I explicitly specify a StructLayout?

I'm fiddling with calling DLLs from C#, and came across the need to define my own structs. Lots of articles force a sequential layout for the struct with [StructLayout(LayoutKind.Sequential)] struct Foo ... So, I followed suite, and my programme worked. Now, when I took the line out, it still works. Why do I need it? ...

Java connection to / between Microsoft Windows Office Suite?

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...

.NET / COM events interoperability

I have an interop assembly generated by TlbImp.exe, the generated classes are heavily evented and the performance is very important. But there's a problem, the events seem to be registered/unregistered/invoked in such a manner that even empty event handlers are counted in. Given a set of 1..N events, when you register a handler to an ev...

The memory could not be "read" error when opening a VB6 form from a .Net application

I have an application written in C#.Net (Framework 2.0 if it matters). It calls a VB6 exe that exposes a COM class with one method - that shows a form. When the VB form is closed, I get a system error (Windows message): The memory location could not be read. Then, Windows asks me whether to close the application or debug it. It doesn't ...