com

Passing a C# class instance back to managed code from JavaScript via COM

自古美人都是妖i 提交于 2019-12-22 04:54:12
问题 The basic outline of my problem is shown in the code below. I'm hosting a WebBrowser control in a form and providing an ObjectForScripting with two methods: GiveMeAGizmo and GiveMeAGizmoUser . Both methods return the respective class instances: [ComVisible] public class Gizmo { public string name { get; set; } } [ComVisible] public class GizmoUser { public void doSomethingWith(object oGizmo) { Gizmo g = (Gizmo) oGizmo; System.Diagnostics.Debug.WriteLine(g.name); } } In JavaScript, I create an

COM bug? Opening a workbook twice leads to broken reference

余生长醉 提交于 2019-12-22 04:48:13
问题 Credit to fuglede for bringing this to my attention: Is this a COM bug? I open Excel workbook A, then open workbook B (both of which have a bit of identifying text in cell A1). Then I attempt to open workbook A again and save that reference in a new variable a2 . But a2 now points to workbook B! This exact same behavior is reproduced in Python using win32com. So this isn't a VBA issue specifically, bur rather a COM issue more generally. (i.e. presumably also in C# etc., though not confirmed

.NET Client crasch when replacing COM registered .dll with new one in same .NET version as client

余生颓废 提交于 2019-12-22 04:34:07
问题 We have an old C/C++ .dll that is COM registered. Our customers have both native- and .NET clients that use this .dll. We have built a new .NET .dll to replace the old one, i.e. their COM interface is identical. We would like to replace the old .dll without our customer need to recompile or do anyting to their clients. For native clients it works fine to simply unregister the old .dll and register the new one (with regasm). It also works for some .NET clients. However, in those cases the both

Why is the C# CreateObject so much more verbose than VB.NET?

两盒软妹~` 提交于 2019-12-22 04:15:09
问题 I am looking to convert some VB6/COM+ code to C#/COM+ However where in VB6 or VB.NET I have: Dim objAdmin objAdmin = Server.CreateObject("AppAdmin.GUI") objAdmin.ShowPortal() In C# it seems like I have to do the following: object objAdmin = null; System.Type objAdminType = System.Type.GetTypeFromProgID("AppAdmin.GUI"); m_objAdmin = System.Activator.CreateInstance(objAdminType); objAdminType.InvokeMember("ShowPortal", System.Reflection.BindingFlags.InvokeMethod, null, objAdmin, null); Is there

How To Programmatically Enable/Disable 'Display PDF In Browser' For Acrobat / Reader XI or DC For Use With Adobe ActiveX Control

北战南征 提交于 2019-12-22 03:48:13
问题 We have a .NET C# application that makes use of the Adobe ActiveX Controls. For versions 7-10 of both Adobe Acrobat and Adobe Reader, to use this control you were required to turn on the "Display PDF In Browser" setting. You could do this manually from the GUI using Preferences > Internet > Display PDFs in browser or programmatically by setting the registry settings directly HKEY_CURRENT_USER\Software\Adobe\(Product Name)\(Version)\Originals "bBrowserIntegration"=dword:00000001 Which follows

Python: Access embedded OLE from Office/Excel document without clipboard

喜欢而已 提交于 2019-12-22 03:43:41
问题 I want to add and extract files from an Office/Excel document using Python. So far adding things is easy but for extracting I haven't found a clean solution. To make clear what I've got and what not I've written the small example test.py below and explain further. test.py import win32com.client as win32 import os from tkinter import messagebox import win32clipboard # (0) Setup dir_path = os.path.dirname(os.path.realpath(__file__)) print(dir_path) excel = win32.gencache.EnsureDispatch('Excel

COM+ object activation in a different partition

一世执手 提交于 2019-12-22 01:46:37
问题 I had created a COM+ domain partition then mapped it to a Windows 2008 server machine and imported a COM+ application into it. I tried using the following C# code to activate an object from that specific partition on the server remotely: //partition guid Guid guidMyPartition = new Guid("41E90F3E-56C1-4633-81C3-6E8BAC8BDD70"); //parition moniker string uri= "partition:{" + guidMyPartition + "}/new:MyObject"; Type t = Type.GetTypeFromProgID("MyObject", "MyServer"); MyObject obj = (MyObject

Is there a best practice for accessing C++ native COM functions to interop from C#?

怎甘沉沦 提交于 2019-12-22 00:36:21
问题 Is there a best practice for accessing C++ native COM functions to interop from C#? For example, if I have 100 C++ methods (basically a native library) that interacts with a core window component. I want to basically make a wrapper for these C++ methods in C#, so all my newly hired employees can use that instead of C++, etc. The C++ code is legacy and scares me, so I want to deal with it just once. Is the approach here for each method to have a corresponding C# method? In fact, is there

Successfully registered COM DLL, but can't use class methods

≡放荡痞女 提交于 2019-12-22 00:35:41
问题 I registered a COM DLL using regasm.exe , and now I'm trying to write a VBA script that uses a class from the DLL. The DLL is ExcelDataReaderLibrary.dll . In the C# source, the class is described as follows (includes code from this library): using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Data; using Excel; namespace ExcelDataReaderLibrary { public class ExcelDataReader { public void readSheet

From VB6 to .net via COM and Remoting…What a mess!

穿精又带淫゛_ 提交于 2019-12-22 00:26:43
问题 I have some legacy vb6 applications that need to talk to my .Net engine application. The engine provides an interface that can be connected to via .net Remoting. Now I have a stub class library that wraps all of the types that the interface exposes. The purpose of this stub is to translate my .net types into COM-friendly types. When I run this class library as a console application, it is able to connect to the engine, call various methods, and successfully return the wrapped types. The next