如何从工具箱中的 AxWMPLib::AxWindowsMediaPlayer 添加派生类?

问题描述

这是一个 CLR 项目(.NET Framework 4.5)。

Microsoft Visual Studio 社区 2019 版本 16.8.1

既然AxWMPLib::AxWindowsMediaPlayer继承自System::Windows::Forms::AxHostAxHost继承自System::Windows::Forms::Control,为什么ToolboxClassLibrary1.dll添加时不支持?相反,我收到了一个错误:ClassLibrary1.dll 中没有可以放置在工具箱上的组件。

这是我的ClassLibrary1.dll

#pragma once

using namespace System;

namespace ClassLibrary1 {
    public ref class Class1 : public AxWMPLib::AxWindowsMediaPlayer
    {
    public:
        Class1() {}
    };
}

解决方法

[ToolboxItem(true)] 应用到您的班级,例如:

[System::ComponentModel::ToolboxItem(true)]
public ref class MyMediaPlayer : public AxWMPLib::AxWindowsMediaPlayer
{
    ...
}

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...