COM Interop of WPF Custom Control - Access denied about the registry key HKEY_CLASSES_ROOT\...

Modi 1 Reputation point
2022-11-18T06:23:58.273+00:00

Hi, I have a problem building a project.
My purpose is to build a WPF Custom Control in order to use it in MFC.
But the build cannot be done.
The following informations are what I am through right now:

Project Type: WPF Custom Control Library
Framework Version: 4.7.2
Language: C#

Setup:

  • Project Property->Application->Assembly Information->Set Assembly Visible in COM
  • Project Property->Build->Output->Regist COM Interop
  • Build -> Error

Error Message:
unable to register the assembly "D:{MyWorkSpaceFolder}{MyProjectName}\bin\x64\Release{MyProjectName}.dll".
Access denied.
Check if the application is executed in administrator's authority.
Access denied about the registry key 'HKEY_CLASSES_ROOT{MyProjectName.MyControl}.

I have tried to solve this issue in many ways such as:

  • Changing the framework versions
  • Changing the HKEY_CLASSES_ROOT's authority in Registry Editor (Which made my computer not working)
  • Using different project types

None of them worked. Please help me.

Thank you

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,703 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,554 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,607 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 114K Reputation points
    2022-11-18T06:33:07.1+00:00

    Did you also try running Visual Studio as an administrator?

    2 people found this answer helpful.