interop

Multiple search paths for assemblies not in the GAC when using REGASM & COM

♀尐吖头ヾ 提交于 2019-12-25 01:08:57
问题 I am in the process of creating a .NET assembly that will be registered for COM so that it can be referenced by Microsoft Excel VBA. The assembly references a third-party .NET assembly (that contains some useful classes) that is not in the GAC, however, I have a problem with the deployment of my assembly since the path to the third-party assembly is not always in the same location (it depends on the locale of the user as well as how recently the third-party assembly was installed). This means

Passing a complex Struct (with inner array of struct) from C# to C++

会有一股神秘感。 提交于 2019-12-24 23:54:27
问题 I'm working on a driver for a scanner. Got dll and header files from provider, aside of a manual in PDF, written in native C++ (dont have source code). Need to use it within a C# project but I'm having problems with the structs (either trying to read or send them). I got the dll methods using the Command Prompt, demangling them in a website (since it has +100). Of course, I wont use all of them, just the ones I need. Didn't have problems with the ones using primitive data types, in fact, made

callback function from unmanaged dll in VB .NET

旧街凉风 提交于 2019-12-24 21:33:35
问题 I'm trying to use an unmanaged dll in VB.NET. The example source code provided with the dll is in VB6 and below is my attempt to convert it to .NET. When the dll tries to do a callback I get a "Attempted to read or write protected memory" exception. I really don't care about the callback function getting actually called. My code: <DllImport("AlertMan.dll")> _ Public Shared Function AlertManC( _ ByVal CallbackAddr As AlertManCallbackDel) As Long End Function Public Delegate Sub

: 'Unable to cast COM object of type 'System.__ComObject' to interface type

别来无恙 提交于 2019-12-24 20:05:36
问题 I am getting the following error: System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.MailItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063034-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).' The code from which the error arises: foreach

BadImageFormatException When Calling .dll Built from C++ Project In NET Core

∥☆過路亽.° 提交于 2019-12-24 19:14:41
问题 I have two preexisting projects (C++, C# NET 4.5.2) where the C# projects calls into the C++ project. This worked perfectly until I ported the NET 4.5.2 project to NET Core. Now I get a BadImageFormatException when trying to access the assembly built from the C++ project. Is it possible to call this assembly from a NET Core assembly? public static string CallCPlusPlusConvert(string inputFileName) { if (inputFileName == null) { throw new ArgumentNullException(nameof(inputFileName)); }; return

How do I get results from Matlab in Java?

烈酒焚心 提交于 2019-12-24 19:08:17
问题 I can call a .m file in Matlab from Java and that works fine, but I want to retrieve the results from Matlab and display them in Java. How can I do this? 回答1: matlabcontrol is a Java API which will allow you to do just that. It allows for invoking eval and feval in MATLAB and returning the results to MATLAB. The walkthrough explains with examples how to do this. The walkthrough uses built-in MATLAB functions and commands, but you can use it with your own .m files because using matlabcontrol

Unable to find an entry point named * in dll

限于喜欢 提交于 2019-12-24 17:47:58
问题 I have a C++ project with the following definition in the header file: typedef enum /* Set operation type */ { GPC_DIFF, /* Difference */ GPC_INT, /* Intersection */ GPC_XOR, /* Exclusive or */ GPC_UNION /* Union */ } gpc_op; typedef struct /* Polygon vertex structure */ { double x; /* Vertex x component */ double y; /* vertex y component */ } gpc_vertex; typedef struct /* Vertex list structure */ { int num_vertices; /* Number of vertices in list */ gpc_vertex *vertex; /* Vertex array pointer

“DLL caused an exception” when calling a method that references another DLL

我与影子孤独终老i 提交于 2019-12-24 14:07:50
问题 I developed a DLL, let's call it DomainLogic.dll , with some public methods through [DllExport] annotation. Some of those methods make calls to another DLL, let's call it Utils.dll . I developed a demo WinForm application with some buttons that call methods of DomainLogic.dll and everything works as expected. Currently we have a partner which wants to call our DomainLogic.dll from their existing Visual FoxPro application. They were able to successfully call dll methods that receive and return

C# Casting system.__comobject to class type

有些话、适合烂在心里 提交于 2019-12-24 13:25:38
问题 I have an Excel Add-In that I'm currently trying to set up a unit test framework for. For the unit tests I've followed this guide: http://blogs.msdn.com/b/varsha/archive/2010/08/17/writing-automated-test-cases-for-vsto-application.aspx It seems to work fine, until I want to return a class object from my interface. Specifying the class object as the return type throws a "return argument has an invalid type" exception when calling the method. Changing the return type from the class to an object

Using a .net4 based dll from .net2 based app not working for website

天涯浪子 提交于 2019-12-24 11:08:10
问题 Given this reference: https://code.msdn.microsoft.com/windowsdesktop/Using-a-NET-4-Based-DLL-bb141db3 Is it possible to add a .net2/3.5 website (not a web project) project to this solution and make it work with the adapter? I've tried but no luck. I keep getting error: Could not load file or assembly 'Net4Assembly' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. 来源: https://stackoverflow.com/questions/40666392/using