com-interop

Can't instantiate a COM object written in C# from VBA (VB6 ok)

你。 提交于 2019-11-27 02:25:35
问题 Using VS 2008, here is my COM object using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Windows.Forms; namespace TestCom { [Guid("9E5E5FB2-219D-4ee7-AB27-E4DBED8E123E")] [ClassInterface(ClassInterfaceType.AutoDual)] [ProgId("Test9.COMINT")] public class TestComClass { public void Init(string userid, string password) { MessageBox.Show(string.Format("{0}/{1}", userid, password)); } } } If I build this and register it on a

Excel interop loading XLLs and DLLs

醉酒当歌 提交于 2019-11-27 01:59:18
问题 I have excel with the Bloomberg API ( which uses simple calls like =BDP("MS equity","ask") ). I also have a C# application that opens an excel file (through interop) that uses the Bloomberg API. I have read here that addins are not loaded when you load excel through interop. I have even tried using the code suggested there. However, that only seems to work for XLL and XLAM files and it looks like Bloomberg also uses DLL files which doesn't get loaded. Is there any way to get all of these

Starting and stopping IIS Express programmatically

╄→гoц情女王★ 提交于 2019-11-26 23:40:28
I am trying to build a small application in C# which should start/stop an IIS Express worker process. For this purpose I want to use the official "IIS Express API" which is documented on MSDN: http://msdn.microsoft.com/en-us/library/gg418415.aspx As far as I understand, the API is based (only) on COM interfaces. To use this COM interfaces I've added a reference to the COM library in VS2010 via Add Reference -> COM -> "IIS Installed Versions Manager Interface": So far so good, but what's next? There is an IIISExprProcessUtility interface available which includes the the two "methods" to start

In Excel VBA how to persist key variables over a 'state loss' (without writing to a cell or a file)?

情到浓时终转凉″ 提交于 2019-11-26 23:17:26
问题 Excel VBA is a flexible development environment. It is pesudo-compiled. However, sometimes during development a "state loss" can occur. A "state loss" is when all variables are torn down. Indeed, VBA has an option "Notify before state loss" option for triage. It is unsurprising that one cannot Edit and Continue code in all cases. However, sometimes state losses happen whilst running in production because opening some other workbook may cause trauma to your application session (trust me, it

Calling regasm without administrative rights for COM interop in Excel VBA

梦想与她 提交于 2019-11-26 22:22:58
问题 A workaround for calling regasm without the admin rights was described here already: COM Interop without regasm I'm trying to create a COM library that my users can deploy and use from Excel VBA without the admin privileges. I liked the regasm workaround, since it seems that people don't have much success with using registration-free COM objects from Excel VBA. I also want early binding so my users can benefit from syntax completion. The accepted answer in the question mentioned above,

Using C# COM in unmanaged C++ project -> First-chance exception at 0x7697C41F (KernelBase.dll)

寵の児 提交于 2019-11-26 21:53:16
问题 I'm trying to call methods from a C# COM project in an unmanaged Visual C++ solution, but I keep getting the next error First-chance exception at 0x7697C41F (KernelBase.dll) in Program.exe: 0x04242420 (parameters: 0x31415927, 0x6F310000, 0x00BBDAE8). at the next piece of code SalesForceNew::IMyObjectClassPtr p; p.CreateInstance(__uuidof(SalesForceNew::TestObject)); // error SalesForceNew::MyObject mo = p->getObject(1, "a"); However the value of mo is as expected (5, "aa"). I import the tlb

unable to cast COM object of type 'microsoft.Office.Interop.Excel.ApplicationClass' to 'microsoft.Office.Interop.Excel.Application'\"

廉价感情. 提交于 2019-11-26 20:49:32
This is my first attempt to capture some data from excel from within one C# console application. I get the error "unable to cast COM object of type 'microsoft.Office.Interop.Excel.ApplicationClass' to 'microsoft.Office.Interop.Excel.Application'". This code used the 'Microsoft Excel 12.0 Object Library' , and I gave reference to Microsoft.Office.Interop.Excel. Still, I could not get over this error - which I believe has its own quick solution. I digged a little bit this site and came across with this solution: Interop type cannot be embedded However, I could not understand so could not

When is it necessary/appropriate to use InAttribute and OutAttribute for COM Interop

久未见 提交于 2019-11-26 20:37:59
问题 I am trying to go through the mess of COM interop definitions we have scattered across various projects and collect them into a single, known-good location from which the whole dev team can benefit. Part of this effort involves cleaning up the definitions that have been accumulated over the years. Some of these are borrowed from other source code, some were copied verbatim from pinvoke.net, and some look to be directly translated from the SDK headers. One thing I notice is that there is no

Register a C#/VB.NET COM dll programmatically

北战南征 提交于 2019-11-26 20:14:04
问题 Question: I have a .NET dll which I use from a C++ program. Now I have to register the dll programmatically on a deployment computer. How do I do that (programmatically! not using regasm)? I remember, when I once called a VB6 dll from a C++ dll, I had to use DllRegisterServer and DllUnregisterServer. Is that still so with a .NET dll? It seems I have to somehow add the dllregisterserver function to the .NET dll. 回答1: YUK, .NET dlls don't have DllRegisterServer, so you have to write a .NET

“Register for COM Interop” vs “Make assembly COM visible”

别说谁变了你拦得住时间么 提交于 2019-11-26 18:53:30
问题 What is the real difference between these two options? What I know is: Register for COM Interop This options executes regasm on the assembly and registers the assembly as an COM component(or maybe not) in the registry with all COM like registry entries. Does this step generates a TLB file? What else is done? Sometimes I see a tlb is generated when I compile the project but sometimes not, why is this? Make assembly COM visible What effect does this one has on an assembly? If I have the