How to Use 32-bit COM DLL in a 64-bit WPF .NET Core 6 Application?

I have a Class Library project in .NET Core named “LIBTOOBA” with the following setup:

Project File (LIBTOOBA.csproj):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="Interop.TSMSLIB_TLB">
      <HintPath>DLLSInterop.TSMSLIB_TLB.dll</HintPath>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
  </ItemGroup>

</Project>

Details about the DLL:

  • Name: Interop.TSMSLIB_TLB
  • Works on Platform target: x86

Class Definitions:

namespace LIBTOOBA
{
    class Authentication
    {
        //...
    }

    class Proxy
    {
        //...
    }

    using TSMSLIB_TLB;

    class TSMS
    {
        private Authentication a = new Authentication();
        public Authentication A
        {
            set { this.a = value; }
            get { return this.a; }
        }

        private TSMS_Tooba t = new TSMS_Tooba();
        public TSMS_Tooba T
        {
            set { this.t = value; }
            get { return this.t; }
        }

        public void init()
        {
            t.UserName = this.a.UserName;
            t.Password = this.a.PassWord;
            t.LibKey = this.a.LibKey;
            t.ProxyServer = this.p.Server;
            t.ProxyPort = this.p.Port;
            t.ProxyUserName = this.p.UserName;
            t.ProxyPassword = this.p.PassWord;
        }
    }
}

Main Class:

namespace LIBTOOBA
{
    public class CL_TOOBASMS
    {
        private readonly TSMS CL_SMS;

        public CL_TOOBASMS(string userName, string password, string libKey)
        {
            // Validate inputs
            if (string.IsNullOrWhiteSpace(userName))
                throw new ArgumentException("Username cannot be null or empty", nameof(userName));
            if (string.IsNullOrWhiteSpace(password))
                throw new ArgumentException("Password cannot be null or empty", nameof(password));
            if (string.IsNullOrWhiteSpace(libKey))
                throw new ArgumentException("LibKey cannot be null or empty", nameof(libKey));

            CL_SMS = new TSMS();

            try
            {
                CL_SMS.A.UserName = userName;
                CL_SMS.A.PassWord = password;
                CL_SMS.A.LibKey = libKey;
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Failed to set SMS library credentials.", ex);
            }
        }

        public (string Number, int Credit, int UsedCredit, string LastDate) GetMyAccountInfo()
        {
            //...
            return (number, credit, usedCredit, lastDate);
        }

        public string GetDeliveryInfo(string sendToNumber, string sendEvent)
        {
            //...
            return delivery;
        }

        public string SendSMS(string sendToNumber, string sendMsg)
        {
            //...
            return sendEventTxt;
        }
    }
}

My Issue:
I have a WPF .NET Core 6 Application with Platform target set to AnyCPU (x64). When I add the “LIBTOOBA” library and try to run the application, I get the following error:

System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {83A108DD-D51F-43AF-9290-00541698F0F9} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).'

There is no x64 version of the Interop.TSMSLIB_TLB.dll.

If I change my WPF Platform target to x86, it runs successfully. However, I want to keep my WPF .NET Core 6 Application on Platform target AnyCPU (x64). How can I bypass this issue?

Potential Solutions I am Considering:

  • “Side-by-side” COM activation: Load the 32-bit COM component in a 64-bit process
  • PInvoke (Platform Invoke) to call functions directly from unmanaged DLLs
  • Separate 32-bit process for COM Interop
  • Use CorFlags to force x86 execution
  • Create a C++/CLI wrapper

Any suggestions or guidance on how to implement one of these solutions or another approach would be greatly appreciated.

I want to keep my WPF .NET Core 6 Application on Platform target AnyCPU (x64) , How can I bypass that ?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật