Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

USB superspeed peripherals Forum Discussions

YeVe_4753746
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

Hello All!

I am using Visual Studio 2019 to create a C ++ Windows Forms Application using the appropriate extension.

I made an application that displays an empty form.

Next I want to connect the CyAPI.lib library.

But as soon as I add #include <wtypes.h> at pointed place, I have gotten many errors.

I found that the reasons for the errors lie in the file "C:\Program Files(x86)\Windows Kits\10\Include\10.0.18362.0\um\ servprov.h"

pastedImage_29.png

I tried to solve this but couldn't find anything other than replacing * with ^ or other ways which didn't work or I couldn't understand ones.

Help me please!

CODE

#pragma once

#include <wtypes.h>

#include <dbt.h>

#include "CyAPI.h"

namespace CppCLRWinformsProjekt {

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

/// <summary>

/// Zusammenfassung fьr Form1

/// </summary>

public ref class Form1 : public System::Windows::Forms::Form

{

public:

Form1(void)

{

InitializeComponent();

//

//TODO: Konstruktorcode hier hinzufьgen.

//

}

protected:

/// <summary>

/// Verwendete Ressourcen bereinigen.

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

private:

/// <summary>

/// Erforderliche Designervariable.

/// </summary>

System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code

/// <summary>

/// Erforderliche Methode fьr die Designerunterstьtzung.

/// Der Inhalt der Methode darf nicht mit dem Code-Editor geдndert werden.

/// </summary>

void InitializeComponent(void)

{

this->components = gcnew System::ComponentModel::Container();

this->Size = System::Drawing::Size(300,300);

this->Text = L"Form1";

this->Padding = System::Windows::Forms::Padding(0);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

}

#pragma endregion

};

}

ERRORS:

1>------ Build started: Project: CppCLR_WinformsProjekt3, Configuration: Debug x64 ------

1>CppCLR_WinformsProjekt.cpp

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(91,81): error C3699: '*': cannot use this indirection on type 'IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(91,81): message : compiler replacing '*' with '^' to continue parsing

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(98,9): error C2371: 'IServiceProvider': redefinition; different basic types

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(44): message : see declaration of 'IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(115,41): error C2872: 'IServiceProvider': ambiguous symbol

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(98,9): message : could be 'IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(44,19): message : or       'System::IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(239,22): error C2872: 'IServiceProvider': ambiguous symbol

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(98,9): message : could be 'IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(44,19): message : or       'System::IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(249,32): error C2872: 'IServiceProvider': ambiguous symbol

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(98,9): message : could be 'IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(44,19): message : or       'System::IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\urlmon.h(6869,66): error C2872: 'IServiceProvider': ambiguous symbol

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(98,9): message : could be 'IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(44,19): message : or       'System::IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\urlmon.h(6871,62): error C2872: 'IServiceProvider': ambiguous symbol

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(98,9): message : could be 'IServiceProvider'

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\servprov.h(44,19): message : or       'System::IServiceProvider'

1>Done building project "CppCLR_WinformsProjekt3.vcxproj" -- FAILED.

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

0 Likes
1 Solution

Hi Yatish.

I solved this problem by moving the required code into a * .cpp file.

But I have installed the latest Windows 10 SDK.

Unfortunately this doesn't work in my case.

I have the same errors.

Thanks for your reply.

View solution in original post

0 Likes
2 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

I tried the code on my side and it built without any errors when the wtypes.h was included.

I use Windows 10 SDK version 10.0.19041.0

You can install the latest version from Visual Studios using the Tools-> Get Tools and Features-> Individual Components -> Windows 10 SDK (<latest version>)

pastedImage_1.png

Thanks,

Yatheesh

0 Likes

Hi Yatish.

I solved this problem by moving the required code into a * .cpp file.

But I have installed the latest Windows 10 SDK.

Unfortunately this doesn't work in my case.

I have the same errors.

Thanks for your reply.

0 Likes