1,882 questions
1
vote
0
answers
82
views
How to replace a COM Interop with the ComWrapper Source Generator?
I am currently using a COM Interop DLL, generated with tlbimp, to access a proprietary COM library from C# (net8), so no source code available (TLB embedded in DLL). It works, but stops me from using ...
2
votes
1
answer
103
views
System.IO.FileNotFoundException using another assembly in ComInterop project
I am getting the following exception when using another assembly from a ComInterop assembly:
System.IO.FileNotFoundException: Could not load file or assembly 'Wpf.Tools.CSharp (...)'. The system ...
0
votes
0
answers
26
views
"Object required" error with.NET 8 ComVisible object created with CreateObject() [duplicate]
I've created a simple counter class using .NET 8 and C#:
SimpleCounter.cs
using System.Runtime.InteropServices;
namespace Counters
{
[ComVisible(true)]
[Guid("01FB5599-3CD1-462E-98AA-...
1
vote
1
answer
119
views
How to pass a string as a pointer to byte array from a managed code to an unmanaged function
I need to use a Windows API function in my VB.NET application.
I need to pass an ASCII string of text to that function. This string is stored as a zero-terminated byte array.
What I currently do is I ...
1
vote
1
answer
55
views
ASP.NET web application : Dcom configuration interop exception
I have an ASP.NET web application to export an Excel file with multiple sheets. Each sheet contains multiple tables on it created using Microsoft.Excel.Interop.Services package. The export ...
0
votes
1
answer
67
views
CreateObject on .NET-Framework-based COM object fails if (a) the COM object is registered in HKCU instead of HKLM and (b) UAC is off [sic]
Yes, you read the title correctly - this is an issue that only occurs when UAC is off (for example, with the built-in Administrator account on Windows Server systems).
Repro steps:
Create a COM-...
5
votes
1
answer
179
views
RegFree COM in VBA - ClassFactory cannot supply requested class
Working on creating a .NET 8 library which will be called from Excel VBA via COM interop. I've had some success setting this up using regsvr32, but having gone down that path on earlier projects, I'm ...
2
votes
1
answer
95
views
One COM object works but the other does not
Having a very strange problem here. I'm attempting to make a .NET 8 library which will be called from Excel VBA via COM interop.
I've been following these two pieces of guidance:
Expose .NET Core ...
1
vote
1
answer
86
views
What makes Notepad (and others) open behind my program when invoked through an IExplorerCommand?
I've written a Windows Explorer clone, and while it's been an adventure, most of the stuff is now working fine.
But, I have this problem: when I right-click an item and the Windows 11-style Explorer ...
3
votes
1
answer
106
views
Changing the name of assembly as exposed to COM
I'm starting on a project which will involve calling .NET 8 code from Excel VBA. I've been following these two pieces of guidance:
Expose .NET Core components to COM
How to correctly create COM ...
1
vote
1
answer
181
views
Implement IDispatch-only interface easily in C++
I defined the following IDispatch-only interface in my C# project:
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[Guid("3532C4E8-D320-487C-8BD4-...
2
votes
1
answer
249
views
How to create and register an object via ComWrappers in native AOT
There is a test project that shows the contents of a notepad, in perspective the contents of other window elements:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
&...
0
votes
0
answers
54
views
My WPF application crashes intermittently when working with multiple windows
I have an application built with WPF using .Net framework 4.8 and windows APIs which runs as a windows application and opens an excel app (separate excel process) and from the excel app opens up a ...
2
votes
1
answer
153
views
Are there significant differences between using COM directly or using an interop in PowerShell?
I am automating the creation of Excel workbook with PowerShell scripts.
I can create an Excel instance with either
add-type -assembly Microsoft.Office.Interop.Excel
$xls = new-object Microsoft.Office....
0
votes
1
answer
256
views
How to not use builtin com interop to make trimming work in .NET
In C# .NET 8 given a pointer (IntPtr) to a native object implementing a COM-compatible interface and a C# interface definition, how do I convert the pointer to an object implementing such interface ...
0
votes
0
answers
52
views
How do I make it so a search folder can be saved?
I'm creating a Windows Explorer-like application and I've also implemented search folders and everything works fine, except I can not save the search from the right-click IContextMenu. It gives me (...
1
vote
1
answer
127
views
C# DLL with [ComSourceInterfaces] Attribute Not Working in VBA WithEvents
I am trying to use a C# DLL in VBA with events using the [ComSourceInterfaces] attribute, but I am encountering issues. Here's what I have so far:
C# Code
ITaskRunnerEvents.cs
using System;
using ...
1
vote
1
answer
99
views
COM Interop: Interface Not Found in VBA Despite Correct Class Registration
Problem Description: I'm working on using COM interop to call a C# asynchronous method from VBA. The class (NewAsyncTaskRunner) is recognized and works fine, but the interface (INewCallback) is not ...
1
vote
1
answer
104
views
C# COM INTEROP and VB6 - Resources not being released
I have a C# .netFramework4.8 COM INTEROP library that takes data and puts it into a .pdf file to be saved somewhere. This involves PDFSharp, as I need to take pages out of existing .pdf files and ...
2
votes
0
answers
98
views
What makes it so that all OneDrive context menu items appear twice in my IContextMenu?
In my application, I'm showing an IContextMenu when a user right-clicks an item. Just like Windows Explorer. The problem is that all OneDrive items are added twice, some with slightly different names. ...
0
votes
0
answers
55
views
How do I know when my COM object is released?
I'm implementing drag and drop and clipboard copy/paste with CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS with IStream. So I implemented my own IStream where basically I map the stream to a .NET ...
0
votes
0
answers
103
views
VirtualAllocEx - Memory reservation does not return an base address
I am currently working on a small C# project to save the names of the desktop icons in a text file.
I have used these two articles to help me get started:
Desktop Icon manipulation - how to get a ...
1
vote
1
answer
113
views
Excel RTD server in a WPF .NET 8 application
Excel RTD is a COM based technology and all examples I found have the following characteristics:
They are based on .NET Framework (not .NET core or modern .NET)
They are 32 bits
They are in process ...
1
vote
0
answers
69
views
Export COM Interface for class from another assembly
I have two projects, Server and ServerCOMInterop. I have defined some classes in the Server project and I have imported them in ServerCOMInterop. Now I want to create a COMInterface for the ...
1
vote
1
answer
208
views
Passing an array of objects from C# to VBA Excel
I have a C# console application and Dll. I registered the dll as COM via interop. I used the
COM Visible property, GUID etc
Set Assembly Information, Build information to register it to COM
I ...
0
votes
0
answers
523
views
Created COM object with .Net 8. It just works (TM) but I am struggling with deps.json and consuming with Native code
I have a .Net 4.72 DLL, exposed to COM using ComVisible(true) and the rest. I'll put example in a sec. I have been modernizing this DLL to .Net 8. This DLL consumes some registered ocx files via ...
1
vote
2
answers
159
views
registering for COM fails because referenced assembly is not registered
I have an assembly containing the following classes that should be exposed to COM:
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
namespace Interop
{
[ComVisible(true)]
[...
0
votes
0
answers
234
views
Issues with COM between a .NET 8+ project and a .NET Framework one
I tried making a .NET 8+ COM Host whose interface has an IEnumerable that under the hood is an iterator method utilizing yield statements, to be used from a .NET Framework v4.8 project.
My interface ...
2
votes
0
answers
255
views
error: Automation error. The system cannot find the file specified in vb6
I have an application in VB6 and need to create an object of a class that is part of another .dll (written in VB.NET). Now I am using the CreateObject() method (I am following the same logic used in ...
4
votes
1
answer
937
views
.NET 8 COM class using GeneratedComInterfaceAttribute not visible to VB6/VBA or OLEViewer
Following the Source generation for ComWrappers article from Microsoft, I've created a simple .NET 8 Class Library project in Visual Studio 2022 using the GeneratedComInterfaceAttribute attribute, ...
0
votes
1
answer
628
views
Registering a COM Interop DLL > Class not registered
I am familiar with the process of how to register a COM Interop. Eg:
As long as I am running Visual Studio using Administrator elevation this C# COM DLL will compile and register for interop. The TLB ...
3
votes
4
answers
6k
views
How to correctly create COM classes with .NET8?
I need to create a COM class in .NET8 that needs to be accessible to Excel.
After watching this video, I implemented the following test bed class:
namespace COMTestBedCS
{
[Guid("26a0aa6d-...
0
votes
0
answers
95
views
How to subscribe to the Workbook.SheetActivate event?
I want to subscribe to the Workbook.SheetActivate event of my excel Application which I use as a dynamic object so that I am not dependent on the specific version.
Instantiation and EventHandler:
...
1
vote
0
answers
114
views
Visual Studio write to Office 365 word
I created an app (in visual studio 2015 and .net) that writes to Word 2013 (it creates the word document, fills in paragraphs of text, tables, numbers, etc... through bookmarks) it's been working ...
0
votes
0
answers
78
views
How to obtain a COM object type of an array?
Aim: Using reflection and generics pass in a VBA array of custom objects and return the same custom VBA COM object back after processing. Eg in the example removing duplicates from a VBA of any type ...
-1
votes
1
answer
157
views
Is this programming pattern the solution to Excel COM interop memory leaks?
I don’t wish to contribute to the mysticism of this subject further than it already seems to be on internet. I’ve many articles talking about this subject, some say never Marshal.ReleaseComObject ...
0
votes
0
answers
71
views
Connect to Running Program via COM - Marshal.GetIUnknownForObject
I am using a software package that offers an "extension" package, largely undocumented, that allows for creation of extensions that allow automation within the program. It's a COM interface ...
0
votes
1
answer
1k
views
.NET 6.0 comhost registration fails with error 0x80008083
I am migrating a managed 32-bit COM component from .NET Framework 4.8 to .NET 6. Regsvr32 will register its xxx.comhost.dll on the development machine, but not on a non-development machine: it fails ...
0
votes
1
answer
107
views
Cannot Scaffold Access Database after Office365 Upgrade - EFCore + Visual Studio 2019
I've spent the last three hours trying to resolve this issue to no avail, so I'm coming here for some assistance. I have previously scaffolded a subset of this database, but prior that was prior to ...
0
votes
1
answer
93
views
How can I expose c# classes and methods as <globals> in the COM interface?
When I'm using the Microsoft Office VB Editor, looking in the Object Browser I can see a section that lists a set of classes and methods that can be invoked without qualifying with a class name or ...
2
votes
1
answer
666
views
How to use FindAll() with the nuget package Interop.UIAutomationClient
I want to use Microsoft UIAutomation, from C#.
I collected some finds I made on the internet and ended up with the following code (using the Nuget package "Interop.UIAutomationClient" ...
1
vote
1
answer
87
views
Interop function call from Excel to PowerPoint much slower in C# compared to VB.net (when run for the first time)
I have a VSTO Excel addin as well as a VSTO PowerPoint addin. I am calling one of the PowerPoint addin functions from my Excel addin with the below code:
Application pptApp = null;
try
{
...
0
votes
1
answer
126
views
CS1545 error with specific COM object properties
I am doing COM automation with a 3rd party library. When trying to access certain properties I need to use obj.get_Property() instead of obj.Property.
This seems to be happening only for properties of ...
0
votes
1
answer
92
views
Problem retrieving email sender in Outlook Interop
We are developing an Outlook 365 plugin that retrieves various parts of the email to create a file.
When the mail in the inbox is sent with exchange we are not able to retrieve the sender. We copied a ...
1
vote
2
answers
594
views
Get value from System.__Object in C#
I have a vendor specific COM interface. Intellisense shows properties while writing; thus I write something like
App.Element.Car.seats
which is somehow known to Visual Studio. In the autocomplete ...
0
votes
0
answers
137
views
WPF Window failing to display and throwing the exception
I have the below code in a COM interop project(interacts with the parent window) that first creates a WPF dialog in a STA thread. The dialog is displayed properly from the parent window and is ...
0
votes
0
answers
78
views
COM interop returns ERROR_FILE_NOT_FOUND
I have a C++ non-managed program calling into a C# DLL using COM interop to access a sharepoint server using SharePoint CSOM.
Calling from C++ returns hr == ERROR_FILE_NOT_FOUND.
Calling the same DLL ...
1
vote
1
answer
470
views
How to late bind an event sink for a COM object of unknown type at runtime in C# .NET 7
I am working in C# .NET 7 where I can create a COM object of a type that is unknown at compile time.
var comTypeName = "Word.Application";//Assume this is passed in by the user and is ...
1
vote
0
answers
77
views
Cannot specify page name when creating a new page using OneNote interop in C#
I am creating a OneNote add-in using OneNote interop in C#. I want to create a page with a specific name, but I'm not able to do so. I used Application.GetHierarchy to get the XML for my notebooks, ...
2
votes
1
answer
137
views
Can you programmatically determine if modern comments are enabled in Word?
Can you programmatically determine if modern comments are enabled in Word?
If it is not possible to check this directly [I don't think it is], is there any property of a comment that you can check ...