用于TFS API的C++包装器
C++ Wrapper for TFS API
我在VS 2012中有两个项目试图为Team Foundation Server API构建C++包装器。
#pragma once
using namespace System;
using namespace System::Reflection;
using namespace System::Collections::ObjectModel;
using namespace Microsoft::TeamFoundation::Client;
using namespace Microsoft::TeamFoundation::Framework::Common;
using namespace Microsoft::TeamFoundation::Framework::Client;
namespace ManagedDll {
public ref class TFSAUth
{
public:
TFSAUth();
~ TFSAUth();
void AuthUser()
{
System::String ^x = gcnew String( "http://myhost:8080/tfs");
System::String ^u = gcnew String( "user");
System::String ^p = gcnew String( "Pass");
System::Net::NetworkCredential ^c = gcnew System::Net::NetworkCredential(u, p);
TeamFoundationServer ^something = gcnew TeamFoundationServer(x, c);
something->Authenticate();
System::String ^col = gcnew String (something->TfsTeamProjectCollection->Name);
Console::WriteLine(col);
}
private:
};
TFSAUth:: TFSAUth()
{
}
TFSAUth::~ TFSAUth()
{
}
}
__declspec(dllexport) void Auth()
{
ManagedDll::TFSAUth work;
work.AuthUser();
}
这是库项目,我有一个使用此库的测试应用程序。
#include "stdafx.h"
#include "conio.h"
#include <iostream>
#include <windows.h>
#include "ManagedDll.h"
_declspec(dllexport) void Auth();
int _tmain()
{
Auth();
system("pause");
return 0;
}
我工作了一段时间,打开这个项目,看看我是否能做得更远。今天它编译失败,给了我链接器错误。
TestApp.obj:错误LNK2019:未解析的外部符号"void __cdeclAuth(void)"(?Auth@@YAXXZ)在函数_wmain 中引用
我不知道为什么,因为一切都没有改变。但除此之外,我想知道在为TFS API创建C++包装器时,我是否做了正确的事情。
任何帮助/示例/建议都将不胜感激,因为这是我第一次尝试使用包装器。
在本机C++项目(测试应用程序)中,必须包含托管C++项目(ManagedDll)的lib文件。
管理C++DLL中导出的DLL函数与本机C++DLL中的函数相同,您可以按照以下步骤操作:将Lib文件作为链接器输入以使其工作。
此外,您应该删除
_declspec(dllexport) void Auth();
在测试应用程序中。
相关文章:
- 如何在c++17中制作一个模板包装器/装饰器
- std::vector的包装器,使数组的结构看起来像结构的数组
- 如何在c++迭代器类型中包装std::chrono
- 是否可以用"iostream"包装现有的TCP/OOpenSSL会话
- 用pybind11包装C++抽象类时出错
- 为左值和右值的包装器实现C++范围
- C结构,其指针将被包装在unique_ptr中
- 如何包装第三方DLL在R中使用
- 在类型和包装器之间reinterpret_cast是否安全<Type>?
- 将 N-arg 函数包装到另一个函数中
- 元组由 Swig 生成的 Python 包装器返回,用于C++向量
- 包装一个对象并假装它是一个 int
- 使用 Python Extension API 包装复杂C++类
- 外壳包装器句柄/执行交互式命令管道C++ UNIX
- 包装C++类时不完整的类型 GLFWwindow
- 将函数包装器转换为 std::function
- C++函数包装器来捕获某些信号
- 创建包装升压适配器的自定义范围类
- 如何包装(撰写)增强 hana 地图并访问括号运算符(运算符 [])?
- 使用运算符*重载包装矩阵乘法