I have a project where I have to connect to a C-based library and I was not able to access functions from C # using DLLImport. I have to use a C ++ / CLI based project to use these functions. (more to this story, but not important).
I studied C ++ over 10 years ago, so sorry if that seems naive.
Last year, I acquired several books on the implementation of C ++ / CLI, and I have some idea of what is connected with this - I just delved into these books for this project. (I was a programmer for a long time).
I thought it was better to start a small example project to familiarize yourself with what will be involved in it, to make sure that I can compile, etc. I started a project using Visual Studio 2008 SP1; Visual C ++> CLR> Class Library. In the project - I want to use both managed and native from DLL. So the / clr switch is used.
I used other names in real code; but it is very, very close. (there are currently no other files or features)
Title:
#pragma once
using namespace System;
namespace myWrapper {
public ref class myWrappedService {
myWrappedService();
bool Connected(String ^user,String ^password,String ^domain);
}
};
And the implementation has it.
#include "stdafx.h"
#include "myWrapper.h"
using namespace System;
public ref class myWrappedService
{
public:
myWrappedService() {}
bool Connected(String ^user,String ^password,String ^domain)
{
bool result = false;
return result;
}
};
This is code that compiles but receives linker errors.
error LNK2020: unresolved token (06000002) myWrapper.myWrappedService :: Connected
fatal error LNK1120: 1 unresolved external.
- #. , - - , CLI. ( , , , , ).