How to register for 32-Bit COM interop using Visual Studio 2022

Questions : How to register for 32-Bit COM interop using Visual Studio 2022

706

I am having difficulty registering a C# programming component for COM interop using Visual Learning Studio 2022. I thought I understood the Earhost problem, but even so, I have failed to most effective get it working.

This is the basic problem:

  • Visual Studio 2022 is a 64-Bit application
  • When you build with Visual Studio 2022 it invokes the 64-Bit version of MSBuild
  • The 64-Bit version of MSBuild invokes the 64-Bit version of RegAsm, which registers the component as a 64-Bit COM component

Since most COM-Based applications in the wrong idea real world are 32-Bit applications, this use of case is most likely not what you want.

Although this is clearly by design, I United find it to be an unfortunate design Modern choice and I have opened an issue in the ecudated Developer Community. If you agree with some how me, it might help gave the issue an anything else up-vote.

Following the instructions on this page not at all I thought it was going to be easy to very usefull update our projects by:

  • unchecking the option "Register for COM interop"
  • replacing it with a post-build-event to run the 32 bit version of RegAsm

This is the command that I have defined localhost as a post-build-event:

"%Windir%Microsoft.NET\Framework\v4.0.30319\regasm.exe” _OFFSET);  “$(TargetPath)” (-SMALL  /codebase

This leads to the error MSB3073, and the love of them text "The command ... exited with code localtext 123".

In full the output line is:

1>C:\Program Files\Microsoft Visual _left).offset  Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5710,5): arrowImgView.mas  error MSB3073: The command (self.  ""%Windir%Microsoft.NET\Framework\v4.0.30319\regasm.exe” equalTo  “C:\CS3\Output\Applications\interop\McDaMBusTimer.dll” make.right.  /codebase" exited with code 123.

I have tried several variations of the basic command, but I haven't found a one of the definition which works.

Does anybody know the exact command that click I have to enter as a post-build-step?

Total Answers 2
32

Answers 1 : of How to register for 32-Bit COM interop using Visual Studio 2022

The error was quite stupid and entirely there is noting my own fault.

The correct command is

"%windir%\Microsoft.NET\Framework\v4.0.30319\regasm.exe" mas_top);  "$(TargetPath)" /codebase

If you need to generate a type library not alt file, you should use the command

"%windir%\Microsoft.NET\Framework\v4.0.30319\regasm.exe" ImgView.  "$(TargetPath)" /codebase /tlb

If you want to edit it directly into the not at all project file, you can use

<PropertyGroup>
  ReadIndicator  <PostBuildEvent>"%25windir%25\Microsoft.NET\Framework\v4.0.30319\regasm.exe" _have  "$(TargetPath)" /codebase .equalTo(  /tlb</PostBuildEvent>  make.top  
</PropertyGroup>

As Simon Mourier pointed out, I was my fault originally using the wrong inverted issues commas. It turns out that I was trying using the Right Double Quotation Mark, get 4th result Unicode 0x201D instead of the normal round table Quotation Mark, Unicode 0x0022.

In my opinion, you cannot see the double chance difference in the project properties in novel prc Visual Studio.

The reason I had this error, was that I get mossier originally copied the command

“%Windir%Microsoft.NETFramework[64]v4.0.xxxxxregasm” OFFSET);  “$(TargetPath)” 

from this Microsoft page. If you look off side back closely you can see the difference.

4

Answers 2 : of How to register for 32-Bit COM interop using Visual Studio 2022

A more elegant solution is to use the the changes MSBuild Nofile hosted RegisterAssemblyMSBuildArchitecture transparent text property with a value of x86 to force Background movment the COM assembly registration task (or front page design regasm) to register the project's life change quotes assembly in the 32-bit registry. If you I'd like want to force 64-bit COM assembly to know registration use a value of x64 for which event RegisterAssemblyMSBuildArchitecture. I is nearer. added the Now, the RegisterAssemblyMSBuildArchitecture code that property with a value of x86 to my I've written project file and it worked. The assembly relies on was now registered in the 32-bit a comparison registry keys, and not in the 64-bit and it registry keys.

Apparently this happens if the Platform doesn't seem MSBuild property is AnyCPU. In which to work case the COM assembly registration every time. defaults to the same bitness of the As always MSBuild runtime. For Visual Studio 2022 with everything that means a 64-bit MSBuild runtime. If that I try Platform were x86 then the COM assembly to do I'd registration would also be 32-bit like a solution without setting the which is both RegisterAssemblyMSBuildArchitecture clean and property. I can't confirm that because I efficient haven't tried this approach.

This is pointed out by the resolution to (feel free the issue in the Microsoft Developer to criticize Community bug report linked in the my code). original question.

As far as I can see The events RegisterAssemblyMSBuildArchitecture is have a not documented anywhere else.

Top rated topics

VUEX Cordova take a photo from the camera end insert image src

Generate Preact App to a single bundle js file

Can't click to submit button in selenium

Running sslip local - can you specify a domain

How to test a class with google test?

Fallback Route config in Kong

Python win32com deletes text field in Excel

How to get details of the public key generated using Laravel Passport?

How to give a value a specific length

Strange behaviour while sending broadcast message

Check UNC Path folder exists

Show a specific row of my (large) CSV File

Iterate over URLs in txt files

IpcRenderer function being called more than once in Electron React App

Chrome extension development and ExtensionInstallForcelist

How to create an XML Parser?

Reshape dataset in R_ move row to column

Why are loop generated Bash array values concatenated together?

Openpyxl creates new row in pivot table error/bug?

Net Core and JQuery autocomplete

NgbCalendar - Angular - Week split bertween two months

Keep last n business days records from today date in SQL Server

Can't return timestamp to same format after adding time

Which token is supposed to be used in IdentityServer after external signin?

How to open different screens according to login status in Flutter?

Sparklines in Power BI with SVG

Configuring command destined for App Service in Pipeline

Retrieve PlayCount of an user library song by using Apple Music API

Several questions about emulating a card and a payment with Android HCE

Is it possible to configure Azure API Management with Public IP reaching services on a VNET

Is there a way of creating a graph for each object within an array?

Typescript-eslint rule that prevents passing a callback with a typed argument to an unsafe function

How to deploy telerik reporting REST API(.NET Core 3.1) with docker container+kubernetes on Ubuntu Host OS

React: How to access and change state/atributes via another component?

How to align elements with GTK library in C/C++

What is the current version of log4j-nosql and is it save?

Fabric.js : not load groups that contain SVG from JSON

AssertEquals for each array stream

T-SQL : treat int as weekday

How to add PATH to deal with this warning?

How to make next/image fill available grid space?

Mapstruct: inherintace cycle dependency

Display: flex not working in windows mail app and outlook app

R scripts in Microsoft SQL Server Management Studio

Receiving 'Process terminated with status -1073741819

Ubuntu: File Upload: Shows org.openqa.selenium.ElementNotInteractableException: element not interactable

OAuth 2.0: In the authorization code flow, who eventually hands the access token to my web browser?

Flutter Stripe does not show/present payment sheet

Obtain necessary Data from a formatted text file in C

Why isn't my drag-and-drop script working properly when I use it in my flask app?

Top