interop

Replacing a C++ ActiveX component with a .NET implementation?

浪尽此生 提交于 2019-12-06 04:24:33
问题 I have existing managed and unmanaged software using an ActiveX component supplied by a third party to perform some communications, but it is now required that this communication be routed through my application. Ideally I'd be able to install a .NET component which will expose exactly the same interface, and will be usable as a drop-in replacement. However, I am running into the limits of my understanding of COM, which admittedly is quite minimal. How best to ensure that my implementation of

C# 2.0 Fastest way to parse Excel spreadsheet [duplicate]

浪尽此生 提交于 2019-12-06 04:12:02
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Reading Excel files from C# What is the fastest way to read large sets of data from excel from Csharp. Example code would be great . . 回答1: In our desktop environment, I have reached the best mix between performance, flexibility and stability by using Excel via COM. Access to Excel is always via the same thread. I use late-binding (in VB.Net) to make my app version independent. The rest of the application is

Runtime C# knowing if 32-bit or 64-bit version of COM Interface is being used

陌路散爱 提交于 2019-12-06 03:50:13
I want to build a DLL Class Library use COM Interop, with C#, target ANY CPU, and register it as 32-bit and 64-bit interfaces. I want to be able to, at runtime, display what interface was used - if I am using the 32-bit version, or 64-bit version. Any ideas? Daniel Earwicker In order for a process to load a 32-bit DLL, the process has to be 32-bit. And same for 64-bit. So to find out what has been loaded, assuming it has already worked, you just need to find out the bit-ness of the CLR: if (System.IntPtr.Size == 8) { // 64-bit } else { // 32-bit } PS. for discussion of whether you need to

Excel Interop Conditional Formatting

对着背影说爱祢 提交于 2019-12-06 03:49:46
问题 I've just spotted the following page: Setting Conditional Formatting in Excel 2007 which is very similar to something I'd like to do, but I can't seem to find appropriate functions to do something slightly different. I'm wondering if anyone knows a way to apply conditional formatting to a range, based upon a set of textual values. E.g. I want to say: If you see "InvalidValue1" OR "InvalidValue2" Highlight RED else if you see "WARNING" Highlight YELLOW I have a whole range of invalid values,

C# Programmatic Access to Excel macros

别来无恙 提交于 2019-12-06 03:31:18
问题 I am working with a directory of Excel files to get information about each file. I am trying to use C# Excel interop to gather information about VBA Macros associated with some of these files. The code for this is found below. The problem is that none of the excel files have programmatic access to macros enabled. I can switch this manually on local copies of the file, but I currently only have read access to the directory of files. Is there any way I can temporarily change the programmatic

COM interop side-by-side assemblies

假装没事ソ 提交于 2019-12-06 03:17:31
问题 I need to deploy multiple versions of the same C# .NET project. The project output is a COM interop assembly to be used in a native application. The problem I'm having is that I have to deploy several versions of this assembly side-by-side but whatever I do doesn't seem to create different versions. Instead the versions override eachother. I've tried changing the assembly GUID, tried changing the assembly version numbers, tried regenerating the assembly strong name key, tried changing the

Hide Excel 2013 while programmatic change a workbook

此生再无相见时 提交于 2019-12-06 03:06:33
A really good new feature of Excel 2013 is that it cannot forced to show more than one Excel workbook in one application. This seems the cause of my Problem: If I open an Excel workbook programmatically using c# and interop Excel 2013 starts with a new application window. I can working with the workbook in code without problems but I want to hide the application. Using Excel.Application excelApp = new Excel.Application(); ...... excelApp.Workbooks.Open(...); excelApp.Visible = false; hides the application window after showing it. Is there a way to stop showing the application as in Excel 2010

tlbexp.exe changes method names' case

天大地大妈咪最大 提交于 2019-12-06 02:52:16
问题 I have a rather strange problem. I am exporting an interface from a C# library to COM. I have enabled the 'register with COM' project setting, so it calls tlbexp.exe to make the type libs. We use camel case on our method names and I noticed that the exported type library changes these any method that happens to coincide with a class name to Pascal case... e.g interface IFoo { void randomClass() } class RandomClass { } The exported IFoo in the type lib defines IFoo->RandomClass() instead of

Errors when calling certain Excel VBA macros from C#

有些话、适合烂在心里 提交于 2019-12-06 02:08:16
I have been struggling and searching on this problem to no avail... I have a few test macros that work perfectly when run from Excel, but either fail or don't work when called from C#, using the interop... I am using MS Visual Studio 2012 (on 64 bit Windows 7) to create a console application that will call the VBA macro TestMacro() written in Excel 2007. Here is the C# code to call the macro: (I basically copied what was done here Run Office Macros by Using Automation from Visual C# .NET ) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System

How should I declare this C struct for interop?

对着背影说爱祢 提交于 2019-12-06 00:53:14
问题 I have to use a legacy C routine in the application I am developing. The code in here works, but I have to convert almost all the fields to char arrays in order to use it. There is a better way to do it? I have tried some version using strings, all to no avail. This is the code found in the original header file... typedef struct PXUCAMR { char xumrversaocomc01; char xumrretcomc02[2]; char xumrretusuc02[2]; char xumrcodfalhac05[5]; char xumrfiller1c01; char xumrtipoambclic01; char