元数据操作失败LNK2022错误 (8013118D):重复类型中的布局信息不一致 (选择设备参数):(0x020002

Error LNK2022 metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (ChooseDeviceParam): (0x02000273)

本文关键字:不一致 信息 布局 选择 参数 0x020002 LNK2022 失败 操作 错误 8013118D      更新时间:2023-10-16

我最近有一个.NET项目要编译,而无需以前的开发人员进一步了解,并且在修复了大多数错误之后(我使用的是Visual Studio 2017,项目的先前版本是这样的(

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1

我仍然收到错误

行抑制状态错误 LNK2022元数据操作失败 (8013118D(:重复类型中的布局信息不一致 (选择设备参数(:(0x02000273(。

这是声明"ChooseDeviceParam"的代码的一部分(VideoSourceList.cpp(

struct ChooseDeviceParam
{
IMFActivate **ppDevices = nullptr;    // Array of IMFActivate pointers.
UINT32      count = 0;          // Number of elements in the array.
~ChooseDeviceParam()
{
if (ppDevices != nullptr)
{
for (UINT32 i = 0; i < count; i++)
{
SafeRelease(&ppDevices[i]);
}
CoTaskMemFree(ppDevices);
}
}
};
HRESULT VideoSourceList::InitVideoDevices()
{
m_videoDevices.clear();
HRESULT hr = S_OK;
ChooseDeviceParam param;
CComPtr<IMFAttributes> pAttributes;
// Initialize an attribute store to specify enumeration parameters.
hr = MFCreateAttributes(&pAttributes, 1);
if (!SUCCEEDED(hr))
{
return hr;
}
// Ask for source type = video capture devices.
hr = pAttributes->SetGUID(
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
);
if (!SUCCEEDED(hr))
{
return hr;
}
// Enumerate devices.
hr = MFEnumDeviceSources(pAttributes, &param.ppDevices, &param.count);
if (!SUCCEEDED(hr))
{
return hr;
}
for (UINT32 n = 0; n < param.count; ++n)
{
WCHAR name[1024];
hr=param.ppDevices[n]->GetString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, name, 1024, NULL);
if (!SUCCEEDED(hr))
{
return hr;
}
VideoDeviceData data;
data.name = name;
m_videoDevices.push_back(data);
}
return S_OK;
}

这是视频来源列表.h

#pragma once
#include "atlbase.h"
#include <memory>
#include <vector>
class VideoSourceList
{
public:
VideoSourceList();
virtual ~VideoSourceList();
HRESULT GetVideoSourceCount(int& count);
HRESULT GetVideoSourceName(int index, CComBSTR& name);
private:
struct VideoDeviceData
{
CComBSTR name;
CComPtr<IMoniker> moniker;
};
std::vector<VideoDeviceData> m_videoDevices;
HRESULT InitVideoDevices();
};

这是不工作部分的属性

谢谢你的帮助。

好吧,我认为这是因为 2 个不同的 cpp 文件具有名为 ChooseDeviceParam 的结构,所以我重命名了其中一个(ofc 重命名了项目中此结构的所有出现(,现在我不再收到此错误(出现了新错误,但我认为它们与此问题无关(