interop

How to generate AxInterop files?

一世执手 提交于 2019-12-09 17:23:27
问题 We have a .NET project that relies on an old VB6 OCX (The entire thing was originally VB6 and C++ and we are gradually migrating it all to .Net but we need it working in its present half-migrated state). One of our developers can build the project but no-one else can. The developer finds that he has references to an interop.foo.dll file and an AxInterop.foo.dll, both of which exist. I have built the VB6 project and added a reference to the OCX into my copy of the .NET project by browsing to

Using Interop.MODI Throws 0x80040154 Exception

倖福魔咒の 提交于 2019-12-09 16:06:24
问题 I am currently trying to implement the Interop.MODI.dll (From Microsoft Office) to use the Image -> Text features it should Provide. But when doing var modi = new MODI.DocumentClass(); I get: "COMException 80040154 with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B}". What have I tried to solve that problem? I registered the DLL using the regasm tool: -Problem still exists I tried setting the BuildPlatform to x86: -Problem still exists I use the Visual Studio 2010 Ultimate with Windows 7

CEFSharp (Chromium Embedded Framework) in Interop User Control

喜夏-厌秋 提交于 2019-12-09 13:56:08
问题 I am trying to use the CefSharp CLR bindings for the Chromium Embedded Framework to create an alternative web browser control that we can embed into an application that only supports legacy ActiveX controls (WonderWare InTouch HMI) in an attempt to gain some HTML5 support for some reeaaallly old machines. So far, I've created an Interop User Control using the Microsoft InteropForms Toolkit and embedded a CefSharp.WinForms WebView onto the control in a pretty bare-bones manner, i.e. Private

How do I create a Microsoft Jet (Access) database without an interop assembly?

放肆的年华 提交于 2019-12-09 13:33:00
问题 I need to create an access (mdb) database without using the ADOX interop assembly. How can this be done? 回答1: Before I throw away this code, it might as well live on stackoverflow Something along these lines seems to do the trick: if (!File.Exists(DB_FILENAME)) { var cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DB_FILENAME; // Use a late bound COM object to create a new catalog. This is so we avoid an interop assembly. var catType = Type.GetTypeFromProgID("ADOX.Catalog"); object

Exposing .net methods as Excel functions?

女生的网名这么多〃 提交于 2019-12-09 12:22:49
问题 I have a set of calculation methods sitting in a .Net DLL. I would like to make those methods available to Excel (2003+) users so they can use them in their spreadsheets. For example, my .net method: public double CalculateSomethingReallyComplex(double a, double b) {...} I would like enable them to call this method just by typing a formula in a random cell: =CalculateSomethingReallyComplex(A1, B1) What would be the best way to accomplish this? 回答1: There are two methods - you can used Visual

C++/CLI Inheriting from a native C++ class with abstract methods and exposing it to C#

谁都会走 提交于 2019-12-09 12:14:31
问题 I've been googling around in circles trying to find an fully fledged example to this but to no avail. I have a C++ API that presents a number of classes that contain pure virtual methods for the developer to extend from. What I'm attempting to do is provide this interface to C# via the C++/CLI. I've managed to get the API compiled into the C++/CLI library and I've reached a sticking point as I'm new to this. I'm aware that I need to create a wrapper to expose the C++/CLI unmanaged class to a

Access COM vtable from C#

和自甴很熟 提交于 2019-12-09 11:04:15
问题 Is there any way in C# to access a COM object's virtual method table in order to get a function's address? 回答1: After a lot of searching and piecing together different partial solutions, I figured out how to do it. First you need to define the COM coclass for the object you're trying to access: [ComImport, Guid("..."), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface ISomeCOMInterface { // Define interface methods here, using PInvoke conversion between types } Next you

COM Interop: What should I do to make a C# property usable as a VARIANT from VBA

我只是一个虾纸丫 提交于 2019-12-09 10:18:43
问题 Say I have a C# Nullable DateTime? property that needs to be consumed by VBA through COM. public DateTime? TestDate { get ; set; } Unfortunately, Nullables are not visible through COM, so I would like to have the property return a something that will be seen as a Variant from VBA. Unfortunately, I'm not sure how this should be written. I tried using an object and a dynamic instead of DateTime? : while I can get the property value, I can't set it (I get Run-Time error '424' Object required

How to distinguish different types of NaN float in Python

天大地大妈咪最大 提交于 2019-12-09 09:15:49
问题 I'm writing Python 2.6 code that interfaces with NI TestStand 4.2 via COM in Windows. I want to make a "NAN" value for a variable, but if I pass it float('nan') , TestStand displays it as IND . Apparently TestStand distinguishes between floating point "IND" and "NAN" values. According to TestStand help: IND corresponds to Signaling NaN in Visual C++, while NAN corresponds to QuietNaN That implies that Python's float('nan') is effectively a Signaling NaN when passed through COM. However, from

Running executable from memory

半城伤御伤魂 提交于 2019-12-09 06:25:27
问题 I'm trying to run an executable directly from a byte[] representation of this executable as a resource in C#. So basically i want to run a byte[] of an PE directly without touching the harddisk. The code I'm using for this used to work but it doesn't anymore. The code creates a process with a frozen main thread, changes the whole process data and finally resumes it so it runs the byte[] of the PE. But it seems like the process dies if the thread is resumed, i don't really know whats wrong. So