interop

WinForms Interop, Drag & Drop from WinForms -> WPF

核能气质少年 提交于 2019-11-28 20:37:28
I'm trying to drag data from the Winforms portion of my application on a WPF controls that's contained inside an "ElementHost". And it crashes when I try doing so. Trying the same thing but from Winforms to Winforms works fine. (See example code below) I need help on making this work... have any clues what I'm doing wrong? Thanks! Example: In the sample code below, I'm just trying to drag a custom MyContainerClass object created when initating the drag on the label control on a 1) System.Windows.Forms.TextBox (Winforms) and 2) System.Windows.TextBox (WPF, added to an ElementHost). Case 1)

Clojure: working with a java.util.HashMap in an idiomatic Clojure fashion

淺唱寂寞╮ 提交于 2019-11-28 20:20:01
I have a java.util.HashMap object m (a return value from a call to Java code) and I'd like to get a new map with an additional key-value pair. If m were a Clojure map, I could use: (assoc m "key" "value") But trying that on a HashMap gives: java.lang.ClassCastException: java.util.HashMap cannot be cast to clojure.lang.Associative No luck with seq either: (assoc (seq m) "key" "value") java.lang.ClassCastException: clojure.lang.IteratorSeq cannot be cast to clojure.lang.Associative The only way I managed to do it was to use HashMap 's own put , but that returns void so I have to explicitly

Handling events exposed on a .NET class via COM in VB6

◇◆丶佛笑我妖孽 提交于 2019-11-28 19:59:04
Handling events exposed on a .NET class via COM in VB6 My test .NET (class libary registered for interop in compiler settings) code: Imports System.Runtime.InteropServices <InterfaceType(ComInterfaceType.InterfaceIsIDispatch), ComVisible(True)> _ Public Interface MyEventInterface <DispId(1)> Event Exploded(ByVal Text As String) <DispId(2)> Sub PushRedButton() End Interface <ClassInterface(ClassInterfaceType.None)> _ Public Class EventTest Implements MyEventInterface Public Event Exploded(ByVal Text As String) Implements MyEventInterface.Exploded Public Sub PushRedButton() Implements

Clojure Jython interop

半城伤御伤魂 提交于 2019-11-28 18:54:48
I was wondering if anyone has tried somehow calling Jython functions from within Clojure, and how you went about doing this if so. I have not used Jython, but I would imagine the Jython interpreter can be invoked in the same way as any other java code, and Python programs can be run within it. However I wonder if it would be possible to somehow call individual python functions from Clojure. Like I said, I have not tried this yet, so it might actually be straightforward and obvious. I'm just wondering if anyone has tried doing this. Thanks, Rob A note: I just realised that the question is

What is the interop dll?

空扰寡人 提交于 2019-11-28 17:44:50
I need some clarification. I have a Reportwriter dll that uses Crystal Reports. It is written in VB6. I have to add this dll to my asp.net project, where it creates an interop dll. To my understanding, the interop dll is there as an intermediary so that my .net code can speak to the Reportwriter dll. So do I register the interop dll or do I register the original dll? When you write code in VB6, the compiled result is a COM component. COM components provide interfaces, coclasses, structs and enums, which are normally described using a COM type library. However, to consume that COM component in

How to get type of COM object

99封情书 提交于 2019-11-28 17:31:50
I am referencing a COM library in Visual Studio, so it has automatically created the corresponding Interop assembly for me. I would like to do a GetType() on these com objects, but they always return System.__ComObject . Querying them for an interface works though: bool isOfType = someComeObject is ISomeComObject; //this works But what I really want is this to return the actual type of the com object: Type type = someComeObject.GetType(); //returns System.__ComObject :-( Does anyone know how to do what I want to do? Add reference to Microsoft.VisualBasic.dll and then: Microsoft.VisualBasic

Handling Null Values in F#

痴心易碎 提交于 2019-11-28 17:00:17
I need to interop with some C# code with F#. Null is a possible value that it is given so I need to check if the value was null. The docs suggest using pattern matching as such: match value with | null -> ... | _ -> ... The problem I'm having is the original code is structured in C# as: if ( value != null ) { ... } How do I do the equivalent in F#? Is there a no-op for pattern matching? Is there a way to check for null with an if statement? If you don't want to do anything in the null case, then you can use the unit value () : match value with | null -> () | _ -> // your code here Of course,

Java <-> Scala interop: transparent List and Map conversion

微笑、不失礼 提交于 2019-11-28 15:48:36
I am learning Scala and I have a Java project to migrate to Scala. I want to migrate it by rewriting classes one-by-one and checking that new class didn't break the project. This Java project uses lots of java.util.List and java.util.Map . In new Scala classes I would like to use Scala’s List and Map to have good-looking Scala code. The problem is that new classes (those are wtitten in Scala) do not integrate seamelessly with existing Java code: Java needs java.util.List , Scala needs its own scala.List . Here is a simplified example of the problem. There are classes Main , Logic , Dao . They

faster way to return data as an array interoping c++

爱⌒轻易说出口 提交于 2019-11-28 14:28:53
this is a very clean and nice solution to marsahall a struct array from unmanaged C++ code. it is allmost perfect solution when it comes to simplicity, it took me a while to get to that level of understanding the concept, so that in few lines of code, as you can see C# Main() , i have a populated array of struct ready to be 'harvested'.. typedef struct { int Id; BSTR StrVal; }Package; extern "C" __declspec(dllexport) void dodata(int requestedLength,int StringSize, Package **Packs){ int count; count=0; *Packs = (Package*)LocalAlloc(0, requestedLength * sizeof(Package)); Package *Cur = *Packs;

What is the size of a boolean In C#? Does it really take 4-bytes?

做~自己de王妃 提交于 2019-11-28 13:29:22
问题 I have two structs with arrays of bytes and booleans: using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential, Pack = 4)] struct struct1 { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] values; } [StructLayout(LayoutKind.Sequential, Pack = 4)] struct struct2 { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public bool[] values; } And the following code: class main { public static void Main() { Console.WriteLine("sizeof array of bytes: "+Marshal