interop

DisposableAction and Marshal.ReleaseComObject

北战南征 提交于 2019-12-10 19:09:57
问题 doing some office Interop and the code is of Type try { selection = getSelected(Return.Some.Office.InteropObject); for ( int i = 0 ; i < selection.count ; i++) yield return selection.item(i) } finally { Marshal.ReleaseComObject(selection); } Wondering if it's a good idea to replace it with a DisposableAction and change to using ( var a = new DisposableAction(getSelected(Return.Some.Office.InteropObject)) ) { foreach(var b in a.Items) yield return b; } 来源: https://stackoverflow.com/questions

Integrating Haskell with .Net?

笑着哭i 提交于 2019-12-10 19:02:03
问题 I was wondering if there is any good documentation out there for integrating Haskell with the outside world (specifically .NET). I would like to be able to call Haskell functions from within my .NET code. I saw that there was a previously posed question that showed how to pass strings back and forth, but I was wondering if there are more general references and the possibility of passing more complex type. 回答1: You should probably read the stuff in that other question more clearly, because it

GetActiveObject() vs. GetObject() — MK_E_UNAVAILABLE Error

大憨熊 提交于 2019-12-10 18:37:32
问题 All: I am having some problems translating some VBA code to C#. We have a 3rd party app which acts as a local COM server. In the VBA code we use GetObject() to get a reference to the existing object e.g. Set appHandle = GetObject("", ProgId) this works fine. I added a reference to the 3rd party app in our c# code, and used Marshal.GetActiveObject() to try and get a reference to a running instance. e.g. var appModel = (IAppCoModel)Marshal.GetActiveObject(ProgId); but I keep getting a MK_E

WPF - Does HwndSource have to be disposed?

大城市里の小女人 提交于 2019-12-10 18:28:58
问题 I'm using HwndSource in a WPF window, which is not the main window, in order to hook a window procedure (WndProc) to receive some messages: WinSource = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); WinSource.AddHook(new HwndSourceHook(WndProc)); HwndSource implements IDisposable . MSDN is not clear about when/should I dispose it. The docs of HwndSource.FromHwnd explains the technique above: You can use this method to return an HwndSource for a window that is not explicitly an

Enable ActiveX control to raise events without running in a System.Windows.Forms.Application

耗尽温柔 提交于 2019-12-10 18:09:23
问题 Our team is writing some code that requires us to interface with a networked device. The device uses a proprietary protocol, and the manufacturer has provided us with an interface library in the form of an OCX control (i.e., an ActiveX control). I had several false starts trying to use the ActiveX control, for example using native C++ (MFC) wrapped in C++/CLI, wrapped in see C#, I learned that I could drag and drop the control into winforms form, and some wrapper code would be auto-generated.

C# - mixed assembly (C++/CLI, DirectX native) interplay (32/64bit)

允我心安 提交于 2019-12-10 17:26:00
问题 I have a problem related to this question. Two players: C# application Mixed assembly used by 1) The application has to support anything from Windows XP (32bit) to Windows 7 (32 & 64bit). The assembly is complicated in different ways. It contains managed C++/CLI code and some native C++ classes dancing with native DirectX. It also is linked to a few 32bit native dll's w/o source access (containing C++ classes with import libraries). Things are working well in 32bit environments (XP and 7

Powerpoint Interop fails in a Windows Service but works fine in a Windows Form application

≡放荡痞女 提交于 2019-12-10 17:16:16
问题 I've written an application to watch a folder, and whenever a PowerPoint document is dropped into it, it goes through the slides within it and generates png images of each slide. This works fine in a windows forms application but I've put exactly the same code in a windows service, used the same test file and it fails to open it with the following error: Error: PowerPoint could not open the file. at Microsoft.Office.Interop.PowerPoint.Presentations.Open(String FileName, MsoTriState ReadOnly,

VB6 App using COM Interop works fine in IDE, but compiled EXE crashes

ⅰ亾dé卋堺 提交于 2019-12-10 16:54:18
问题 I am currently working on an app in VB6 that uses COM Interop libraries written in C# using the .NET 2.0 framework. I used regasm.exe to register the tlb files from the .NET dlls using the /codebase switch. I was then able to successfully build and run the application in the VB6 IDE with no issues. The .NET code uses a config file, so I added it to the VB6 directory and it read from the configurations fine. However, I then compiled an EXE file from the project an ran it on the same machine as

Passing strings/arrays within structures between C++/C#

走远了吗. 提交于 2019-12-10 16:39:09
问题 I am passing a struct from C# to C++. C# code: [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct Data { [MarshalAs(UnmanagedType.U4)] public int number; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public int[] array; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] public string buffer; } C++ code: struct Data { public: int number; int array[5]; char buffer[512]; //char *buffer; }; The above method works fine. But Instead if I use pointers to handle data in C++ I am

How to determine what “Ne” port the Adobe PDF printer is on?

夙愿已清 提交于 2019-12-10 16:38:23
问题 How can I detect what port (Ne01:, Ne02:, Ne99: etc) the printer is on? Computers (WinXP) here at BigCorp have Adobe Acrobat (version 7.0 Pro) installed which gives a virtual printer named "Adobe PDF". If you print an Excel (2003) workbook to pdf while recording a macro, the printer's full name is "Adobe PDF on Nexx:" where xx is a double digit.... and differs depending on what computer you try. I have written a C# console app using the Excel.Interop (I strongly discourage anyone else from