interop

Best method of calling managed code(c#) from unmanaged C++

佐手、 提交于 2019-12-04 11:01:21
We have developed a s/w architecture consisting of set of objects developed in C#. They make extensive use of events to notify the client of changes in status, etc. The intention originally was to allow legacy code to use these managed objects through COM interop services. That was easy to write in the design specification but, I'm seeing that actually implementing it is more problematic. I've searched for many hours looking for a good sample of event handling using this method. Before we march down that path, I want to make sure that COM interop is the best way to allow legacy code to call

Conversion of Scala map containing Boolean to Java map containing java.lang.Boolean

左心房为你撑大大i 提交于 2019-12-04 10:43:20
问题 I'd like to convert a scala map with a Boolean value to a java map with a java.lang.Boolean value (for interoperability). import scala.collection.JavaConversions._ val a = Map[Int, Boolean]( (1, true), (2, false) ) val b : java.util.Map[Int, java.lang.Boolean] = a fails with: error: type mismatch; found : scala.collection.immutable.Map[Int,scala.Boolean] required: java.util.Map[Int,java.lang.Boolean] val b : java.util.Map[Int, java.lang.Boolean] = a The JavaConversions implicit conversions

How to use Office from Visual Studio C#?

时间秒杀一切 提交于 2019-12-04 10:39:20
问题 The technique for adding a reference to the COM interop of Office in Visual Studio is to go to: References Add Reference Select the COM tab Select Microsoft Office 11.0 Object Library And magically named reference appears: Microsoft.Office.Core The Project.csproj file shows the details of the reference: <COMReference Include="Microsoft.Office.Core"> <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid> <VersionMajor>2</VersionMajor> <VersionMinor>3</VersionMinor> <Lcid>0</Lcid> <WrapperTool

Calling C code from managed code

六月ゝ 毕业季﹏ 提交于 2019-12-04 10:22:38
I currently have a C function that I'd like to use in .NET (C#). I can see two ways of achieving this: Compiling it (I think this is possible) with /clr on VC++.NET, having implemented "façade" managed methods that call the C code. Compiling the C code as a DLL and then making API calls. What do you find best? How to do the first of them? Update As requested, here is the (only) function I need to call from my managed code: int new_game(double* params1, double* params2); Just one more question (though harder) I have one function of the form int my_hard_to_interop_function(double** input, double

C# console app that does Excel Interop - failing when running as scheduled Task -System.UnauthorizedAccessException

安稳与你 提交于 2019-12-04 10:14:21
As the title states, I have a C# console app which uses interop to open Excel and create a new workbook. The code works fine when running the console app via command line. However this exception is thrown when running the console app via a scheduled task: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 It is thrown from the following call: _xlApp = new Excel.Application() The scheduled task is setup to use my credentials (I am an administrator). Based on other forums

Why does an 8-bit field have endianness?

微笑、不失礼 提交于 2019-12-04 10:13:08
问题 See the definition of TCP header in /netinet/tcp.h: struct tcphdr { u_int16_t th_sport; /* source port */ u_int16_t th_dport; /* destination port */ tcp_seq th_seq; /* sequence number */ tcp_seq th_ack; /* acknowledgement number */ # if __BYTE_ORDER == __LITTLE_ENDIAN u_int8_t th_x2:4; /* (unused) */ u_int8_t th_off:4; /* data offset */ # endif # if __BYTE_ORDER == __BIG_ENDIAN u_int8_t th_off:4; /* data offset */ u_int8_t th_x2:4; /* (unused) */ # endif u_int8_t th_flags; # define TH_FIN

How to bind to and use a higher-order component in ReasonReact

廉价感情. 提交于 2019-12-04 09:44:00
Let's say I have a higher-order component, something like the following trivial definition, exported from the JavaScript module ./hoc.js : export const withStrong = Component => props => <strong> <Component ...props/> </strong> Assuming I have some component called HelloMessage , what is the equivalent of this piece of JavaScript: import { withStrong } from './hoc.js'; const HelloMessage = ... const StrongMessage = withStrong(HelloMessage); ReactDOM.render( <StrongMessage name="Joe" />, document.getElementById('react-app') ); TL;DR: This should be the exact equivalent of the requested

Building an OCX with VS.NET?

你离开我真会死。 提交于 2019-12-04 09:34:19
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 Developer Tab. What would you do? Yes, you can still create them. But you can't create an OCX with a .NET language. Need to be unmanaged C++ (or VB). The DLLs with COM interop you can create in C# or VB.NET are just .NET objects that are invoked via CCW. You can

Array from C++ to C#

送分小仙女□ 提交于 2019-12-04 08:25:46
I am trying to pass a double array (its actually a std::vector, but converted at transfer) from a c++ dll into a c# script (unity). Using the approach outlined here https://stackoverflow.com/a/31418775 . I can successfully get the size of the array printing on my console in unity however I am not able to use "CoTaskMemAlloc" to allocate memory for the array since I am using Xcode and it doesnt seem to have COM. For a little more background this array is part of a control for a GUI, c++ creates it and the user edits with the c# GUI - so the plan is to be able to pass the array back to c++ when

DLLImport Int** - How to do this if it can be done

安稳与你 提交于 2019-12-04 08:20:55
I am trying to use a third party DLL that wants an int** as one of the parameters to the method. It describes the parameter as the address of the pointer that will point to the memory allocation. Sorry for any confusion. The parameter is two-way I think. The DLL is for talking to an FPGA board and the method is setting up DMA transfer between the host PC and the PCI board. Use a by-ref System.IntPtr . [DllImport("thirdparty.dll")] static extern long ThirdPartyFunction(ref IntPtr arg); long f(int[] array) { long retval = 0; int size = Marshal.SizeOf(typeof(int)); var ptr = IntPtr.Zero; try {