interop

C# & MATLAB interoperability for non-matrix datatypes

好久不见. 提交于 2019-12-05 12:29:05
I'm writing a C# program that needs to call MATLAB processing routines. I've been looking at MATLAB's COM interface. Unfortunately, the COM interface appears to be rather limited in terms of the types of data that can be exchanged. Matrices and character arrays are supported, but there doesn't seem to be support for exchanging struct data or cell arrays between C# and MATLAB using the COM interface. For example, in the following code (assuming that a DICOM image named IM000000 is present in the appropriate file folder), the MATLAB variables 'img' and 'header' are a 256x256 int16 matrix and a

Replace MergeFields in a Word 2003 document and keep style

眉间皱痕 提交于 2019-12-05 12:07:42
I've been trying to create a library to replace the MergeFields on a Word 2003 document, everything works fine, except that I lose the style applied to the field when I replace it, is there a way to keep it? This is the code I'm using to replace the fields: private void FillFields2003(string template, Dictionary<string, string> values) { object missing = Missing.Value; var application = new ApplicationClass(); var document = new Microsoft.Office.Interop.Word.Document(); try { // Open the file foreach (Field mergeField in document.Fields) { if (mergeField.Type == WdFieldType.wdFieldMergeField)

Keep session in subsequent Java calls to Play 2.0's fakeRequest

送分小仙女□ 提交于 2019-12-05 11:34:42
I'm looking for a way to preserve the session when using Play 2.0's fakeRequest in my Java tests, but my attempts fail while invoking methods in the Scala-based JARs. Based on a pull request mentioned in the Scala question Add values to Session during testing (FakeRequest, FakeApplication) , I figured the following might work in Java: public Session getSession(Result result) { play.api.mvc.Cookies scalaCookies = play.api.test.Helpers.cookies(result.getWrappedResult()); play.api.mvc.Cookie scalaSessionCookie = scalaCookies.get(play.api.mvc.Session.COOKIE_NAME()).get(); scala.Option<play.api.mvc

Does order matter when registering, gac-ing assemblies for COM interop?

こ雲淡風輕ζ 提交于 2019-12-05 11:29:58
When registering .NET assemblies for COM Interop, I do two things, currently in this order: regasm /tlb:MyDll.tlb Mydll.dll gacutil /i Mydll.dll I use regasm to register the type library for COM and gacutil to install the assembly into the GAC. Does it matter which order I do these two actions? Also, as I make updates to my dll, do I need to un-register and re-register it, uninstall it from the gac and re-install it, both or neither? Does order matter? No. Do you need to reinstall in GAC when the dll has changed? Yes. Do you need to re-register for COM when dll has changed? That depends. If

WCF Callback: Is it interoperable with Java?

随声附和 提交于 2019-12-05 11:26:27
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 really ask... is it interoperable with more than Java as well? Just in case... No. WSDualHttpBinding and

How to properly clean up interop objects in C#

偶尔善良 提交于 2019-12-05 10:26:54
This is a follow on question to How to properly clean up excel interop objects in c# . The gyst is that using a chaining calls together (eg. ExcelObject.Foo.Bar() ) within the Excel namespace prevents garbage collection for COM objects. Instead, one should explicitly create a reference to each COM object used, and explicitly release them using Marhsal.ReleaseComObject(). Is the behaviour of not releasing COM objects after a chained call specific to Excel COM objects only? Is it overkill to apply this kind of pattern whenever a COM object is in use? It's definitely more important to handle

Marshal a C char[][] array to C#

亡梦爱人 提交于 2019-12-05 10:26:12
I have looked and looked and tried everything I can think of or have found suggested. I'm still not having any luck getting the data I need. I'm using a third party DLL, which I believe is written in C. I need to access the functions from this DLL in C#. For the most part, I have this working, except for one function. The function I'm having problems with has the following header: uint queryNumOfServers(USHORT *NumOfServers, char ServerNames[8][16]); I have the following declared in my C# application [DllImport("client.dll", CharSet=CharSet.Ansi] public static extern uint queryNumOfServers(ref

C# Com Interop with Windows Media Player Visualisation (With Sample Code)

旧城冷巷雨未停 提交于 2019-12-05 10:12:44
I am attempting to create a Windows Media Player (WMP) Visualization plugin in C#. I am quite new to exposing C# to COM and may have missed something basic. I have persisted with this for 3 days (about 20 hours) and not got past the single issue I will describe below. For those who don't know, WMP visualizations are the pretty images that show in media player while listening to music. In a nutshell : WMP will call certain methods on my C# COM interface, but not others. I have WMP 11 installed I downloaded the Latest Windows SDK which contains a C++ plugin wizard to compile a working

Excel worksheet in Windows form application without opening Excel application

和自甴很熟 提交于 2019-12-05 09:47:23
问题 I am converting several VBA projects to Windows form applications. The only problem I have is that some of the functionality of Excel is essential to the application, such as R1C1 formulas. I do not want to instantiate the Excel application or access saved worksheets. All of the data is retrieved by querying Oracle databases. 2-Dimensional arrays are not an option because the columns contain differing datatypes, and DataGridViews are too slow to work with. I thought simply dimming a Microsoft

Preferred approach for conditional compilation for 32-bit versus 64-bit versions of types

ぃ、小莉子 提交于 2019-12-05 09:19:33
I'm required for a certain task to enumerate all handles in the system. The best approach I found so far is using the underdocumented NtQuerySystemInformation with the SystemHandleInformation flag for the class parameter. So far so good. However, running it in 32 bit mode on 64 bit Windows, the required structure is as follows: // 32-bit version [StructLayout(LayoutKind.Sequential, Pack=1)] public struct SYSTEM_HANDLE_INFORMATION { public uint ProcessID; public byte ObjectTypeNumber; public byte Flags; public ushort Handle; public uint Object_Pointer; public UInt32 GrantedAccess; } And for 64