I recently got one .NET project to compile without further knowledge from previous developers and after fixing most errors (I am using visual studio 2017 and project's previous version was like this)
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
I am still getting error
Line Suppression State Error LNK2022 metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (ChooseDeviceParam): (0x02000273).
here is part of code where "ChooseDeviceParam" is declared (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, ¶m.ppDevices, ¶m.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;
}
and here is 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();
};
here are properties of not working part
Thank you for help.
答案 0 :(得分:0)
好吧,我认为这是因为2个不同的cpp文件有名为ChooseDeviceParam的结构,所以我重命名了其中一个(ofc在项目中也重命名了这个结构的所有实例),现在我不再收到这个错误了(出现了新的错误)但我认为他们与这个问题无关)