gpt4 book ai didi

c++ - 错误 LNK2022 元数据操作失败 (8013118D) : Inconsistent layout information in duplicated types (ChooseDeviceParam): (0x02000273)

转载 作者:太空宇宙 更新时间:2023-11-04 12:58:20 25 4
gpt4 key购买 nike

我最近得到了一个 .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

还是报错

Line Suppression State Error LNK2022 metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (ChooseDeviceParam): (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;
}

这里是VideoSourceList.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();
};

这里是 properties不工作的部分

谢谢你的帮助。

最佳答案

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

关于c++ - 错误 LNK2022 元数据操作失败 (8013118D) : Inconsistent layout information in duplicated types (ChooseDeviceParam): (0x02000273),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45506816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com