Reputation: 11
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.
Upvotes: 1
Views: 1556
Reputation: 11
Well, I think it is because 2 diffferent cpp files had structure named ChooseDeviceParam so I renamed one of them (ofc renamed all occurrences of this structure in project as well) and now I am not getting this error anymore (new errors appeared but I think they have nothing to do with this problem)
Upvotes: 0