interop

Interoperating between Matlab and C#

半城伤御伤魂 提交于 2019-11-27 04:14:42
After peeking around the internet it looks like it is possible to interop between C# and Matlab. I am wondering if anyone has had success with it and what they did to do so. If possible somehow pulling it off without the use of COM. Thanks for your time. Yes, quite possible. Though I ended up using the C interface and calling into that using a mixed-mode DLL (and getting C# to call into that... but that was because I was also interfacing with some other C code). It's quite straightforward. On computers where you want to run your program, you'll need to install Matlab Runtime MCRInstaller.exe.

COM object that has been separated from its underlying RCW cannot be used

倖福魔咒の 提交于 2019-11-27 03:53:27
I have some COM component which I call from some c# dll. I also have a winforms app that uses that .dll. When I close the app I get this exception: COM object that has been separated from its underlying RCW cannot be used. The stack trace shows this exception comes from a destructor in the .dll. I implemented this destructor to call some cleanup method in the COM. Why does this happen? How is it best to solve it? Ran The issue is described here: Is it safe to call an RCW from a finalizer? and here: Release Excel Object In My Destructor The trouble is that not only is the timing as to when

Use Visual Studio Setup Project to automatically register and GAC a COM Interop DLL

痴心易碎 提交于 2019-11-27 03:43:48
I've created a .NET assembly for COM interop and it is working well on my development machine. I'm currently trying to figure out how to deploy the DLL to a target machine using Visual Studio's "Setup Project." How can I use the VIsual Studio setup project to do the following things: Register the assembly (currently using regasm ). The assembly needs to be registered successfully and the type library (.tlb) needs to be registered successfully . This answer suggests scrapping regasm in favor of custom code. I this is a good idea? If so, how does this code get included in the setup project? This

Calling FORTRAN dll from C# and assigning values to array of structures

人盡茶涼 提交于 2019-11-27 03:43:04
问题 I can pass a C# struct into FORTRAN just fine. I can even pass an array of a C# struct as an array of TYPE() in FORTRAN . Where I run into trouble is when I tried to return values back into C# . Here is an example: The fortran dll is: MODULE TESTING TYPE VALUEREF INTEGER*4 :: A ENDTYPE VALUEREF CONTAINS SUBROUTINE TEST_REF(T,N) !DEC$ ATTRIBUTES DLLEXPORT :: TEST_REF !DEC$ ATTRIBUTES ALIAS:'TEST_REF' :: TEST_REF !DEC$ ATTRIBUTES VALUE :: N IMPLICIT NONE INTEGER*4 :: A,I,N TYPE(VALUEREF) :: T(N

Hosting the .NET runtime in a Delphi Program

爱⌒轻易说出口 提交于 2019-11-27 03:42:17
I was looking into using some .NET code from within a Delphi program, I will need to make my program extensible using .net assemblies and predefined functions (I already support regular DLLs). After a lot of searching online, I found Managed-VCL , but I'm not ready to pay $250 for what I need, I also found some newsgroups with code that's incomplete and doesn't work. I'm using Delphi 2007 for win32. What can I use to dynamically execute a function from an assembly with predefined parameters? Something like: procedure ExecAssembly(AssemblyFileName:String; Parameters: Variant); I just want to

Get pages of word document

只愿长相守 提交于 2019-11-27 03:37:30
问题 I'm trying to get all pages of MSWord document via Microsoft.Office.Interop.Word (I'm using C# in VS2012). What I would like to get is List< String > Pages, where index is the number of page. I understand (at least I think so) that there is no direct way to do that. So I came up with something like that: List<String> Pages = new List<String>(); int NumberOfPreviousPage = -1; int NumberOfPage = -1; string InnerText = ""; for (int i = 0; i < Doc.Paragraphs.Count; i++) { Paragraph

C# Excel automation causes Excel memory leak

♀尐吖头ヾ 提交于 2019-11-27 03:20:05
问题 I'm trying to use C# with the COM Interop library to open a set of very heavy excel workbooks. I have to use C#, because I also need to start macros, move some cells around, and start a custom excel-add-in my company uses. My program then exits, leaving the workbooks open, each in a separate excel instance. I DO NOT want the workbooks to be closed when the program exits. The problem is that when my C# program exits, over time, the excel workbooks gradually consume more memory, until they're

Microsoft.Office.Interop.Excel really slow

喜夏-厌秋 提交于 2019-11-27 03:17:44
I am exporting a 1200 X 800 matrix (indexMatrix) to a excel file using the standard Microsoft.Office.Interop.Excel. The app works, just that it is really really really slow( even for the 100 x 100 matrix) . I also export in a text file through a TextWriter an it works almost instantly . Is there any way to export to the excel file faster? Here is my code : Excel.Application xlApp=new Excel.Application(); Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; //xlApp = new Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Add(misValue);

What is the correct `XlFileFormat` enumeration for Excel 97-2003

≯℡__Kan透↙ 提交于 2019-11-27 02:51:48
问题 In regards to Excel VBA Interop, what is the correct XlFileFormat enumeration for saving an Excel 97-2003 spreadsheet? The official MSDN documentation is here but I can't figure out from reading this what the correct selection is. Thanks 回答1: Excel 97 was version 8. Subsequent releases up to and including Excel 2003 had very minor changes. Until Excel 2007, version 12. Which is why you see xlExcel9 through 11 missing from the enumeration. So you'll want xlExcel8 here. 来源: https:/

64 bit C# with a 32 bit VB6 COM object

夙愿已清 提交于 2019-11-27 02:03:01
I have a 32 bit in-proc STA VB6 dll. I sadly cannot do anything about this. My C# component greatly benefits from being 64 bit. Is there anyway to call/interface with this 32-bit dll from my 64 bit process? Any sort of wrapper or anything? There's no direct way you can do this. Since you can't port the VB6 inproc dll I'd suggest you write a 32bit out of process server that implements the same interfaces and have it delegate down to the VB6 code. Then, your 64bit app can call the out of process server as COM will take care of marshaling the types between the processes. It ain't pretty, bit it