interop

Marshalling array of structs vs classes

荒凉一梦 提交于 2020-01-02 06:55:22
问题 I want to read a native struct into a C# type using Marshalling. My method to Marshal structs is like so: T ReadObject<T>(BinaryReader br) { var bytes = br.ReadBytes(Marshal.SizeOf(typeof(T))); var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); } finally { handle.Free(); } } Now this works fine in general, the problem arises with the following type: [StructLayout(LayoutKind.Sequential, Pack=1)] class SubData

WCF Callback: Is it interoperable with Java?

夙愿已清 提交于 2020-01-02 04:57:05
问题 Currently I implement all my webservices in the "normal" fashion... that is, I create a WSDL file in Eclipse and then use WSCF.blue (A visual studio extension) to auto-generate the necessary code and it is reply/request. However I was hoping to use callbacks instead, so I can have my services become "push" services. Before I jump into reworking my application, I was wondering about its interoperability. If I use callbacks (WCF), can my Java client still use this? Oh, and I guess I should

Sandwiching Clojure between Java with Leiningen

二次信任 提交于 2020-01-02 04:12:08
问题 For a class, I need to write some JVM code, and I'm hoping to use Clojure. I got it to work with the bottom part of the software stack, but I can't manage to make it work in between the GUI layer sitting on top and the bottom part. My main problem is getting the Java GUI to recognize my Clojure files. I want to use Leiningen for this, but the Java compiling solution doesn't seem to account for this interoperation. The answer here seems to be exactly what I need. I don't understand where to

calling .NET COM object from VBScript

别等时光非礼了梦想. 提交于 2020-01-02 03:27:27
问题 I use VS 2008 and Windows 7. Got a .NET C# class which is exposed as COM object. [Guid("E5014B85-FCB2-4F0D-95EC-F741395A7923")] [InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface DSystem { [DispId(1610809354)] void setProperties(IDictionary propertymap); } COM object is called from a VBScript dim dSystem set dSystem = CreateObject("MYCOMOBJECT") Dim objDictionary Set objDictionary = CreateObject("System.Collections.Hashtable") objDictionary.Add "PROP1", "abc" objDictionary.Add

Problem with hanging interop COM objects

﹥>﹥吖頭↗ 提交于 2020-01-02 03:13:45
问题 I have an application that uses COM interop to create a spreadsheet which is opened in Excel on the client's machine. It appears, however, that the EXCEL.exe process isn't always ended when Excel is closed by the user if I look at Task Manager. If I was saving the workbook and programmatically closing Excel, I would just use Marshal.ReleaseComObject() to clean up, but since I'm depending on a manual close of the program, I'm not sure what to do. Any suggestions? 回答1: Excel cannot terminate

Given the choice, what are the pros/cons of mixed-mode assemblies vs. separate interop DLLs?

安稳与你 提交于 2020-01-02 00:27:14
问题 When a 3rd-party component is offered in both "mixed-mode assembly" and "separate interop dll" versions, what are the pros and cons of each? A good example is System.Data.SQLite. The above link has this to say: [Mixed-mode assembly] packages should only be used in cases where the assembly binary must be deployed to the Global Assembly Cache for some reason. But WHY? The mixed-mode assembly seems to work just fine in my projects, with no GAC installation (just xcopy to the application's exe

How can I open an Excel file without locking it?

萝らか妹 提交于 2020-01-01 17:07:07
问题 I have a process that builds an Excel report, then opens it for the user. The problem is if someone leaves the file open, it stays locked and nobody else can build the report until the first person exits the excel file. Is there a way to open an Excel file without locking it, using either Process.Start or Microsoft's Interop.Excel library? I use the Interop library to build the file each time the report is run, and save it as a static file name in a shared network folder where this

.NET2.0 C# Interop: How to call COM code from C#?

∥☆過路亽.° 提交于 2020-01-01 14:23:12
问题 In my last development environment, I was able to easily interact with COM, calling methods on COM objects. Here is the original code, translated into C# style code (to mask the original language): public static void SpawnIEWithSource(String szSourceHTML) { OleVariant ie; //IWebBrowser2 OleVariant ie = new InternetExplorer(); ie.Navigate2("about:blank"); OleVariant webDocument = ie.Document; webDocument.Write(szSourceHTML); webDocument.close; ie.Visible = True; } Now begins the tedious,

P/Invoke, Pinning, and KeepAlive Best Practices

一世执手 提交于 2020-01-01 13:31:50
问题 At work we have a native C code responsible for reading and writing to a proprietary flat file database. I have a wrapper written in C# that encapsulates the P/Invoke calls into an OO model. The managed wrappers for the P/Invoke calls have grown in complexity considerably since the project was started. Anecdotally the current wrapper is doing fine, however, I'm thinking that I actually need to do more to ensure correct operation. A couple of notes brought up by the answers: Probably don't

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

与世无争的帅哥 提交于 2020-01-01 12:17:32
问题 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" />,