Question

i have the following header file(data.h):

#pragma once
#include <cliext\vector>
#include <msclr\marshal_cppstd.h>
using namespace msclr::interop;
using namespace MySql::Data::MySqlClient;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
ref class data
{
private:
    bool connect(MySqlConnection^ &conDatabase);
    MySqlCommand^ query(String^ qry,MySqlConnection^ conDatabase);
public:

    cliext::vector< String^ > viewCourses(int department,int sem);

};

and the following cpp file (data.cpp):

#include "StdAfx.h"
#include "data.h"

bool data::connect(MySqlConnection^ &conDatabase)
{
    String ^constring=L"datasource=localhost;port=3306;username=root;password=root";
    conDatabase=gcnew MySqlConnection(constring);
    return true;
}

MySqlCommand^ data::query(String^ qry,MySqlConnection^ conDatabase)
{
    MySqlCommand ^cmdDatabase=gcnew MySqlCommand(qry,conDatabase);
    return cmdDatabase;
}

cliext::vector< String^ >  data::viewCourses(int department,int sem) 
{
     cliext::vector< String^ > courses;
     return courses;


}

This is giving me the following linker error:

 error LNK2022: metadata operation failed (801311D7) : Differing number of fields in duplicated types (cliext.impl.vector_impl<System::String ^,0>):

This is only happening whenever i am trying to use cliext::vector as a return type. This error is vanishing when i am using std::vector< std::string > as return type but I want to return a vector of String^ . I am not able to figure out what is causing this error. This error happens only when using cliext::vector as return type , when i use it for general processing then also it is working fine.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top