我必须将软件部署到n个客户端,这些客户端将安装证书并使用它.我不想只部署两个文件(.pfx和exe)(包含.pfx的.exe).
我现在正在做的是从一个位置导入证书.
X509Certificate2^ x509 = gcnew X509Certificate2;
x509->Import( "C:\\Tmp\\certficate.pfx" );
Run Code Online (Sandbox Code Playgroud)
可能吗 ?
在visual c ++ cli项目文件中,我创建了以下类(c ++类型).无法解析适合名称变量的字符串或char类型.
#include <vector>
#include <string.h>
using namespace std ;
class MyClass
{
public :
int x;
int y;
string * name;
void foo() { name = "S.O.S" ;}
};
Run Code Online (Sandbox Code Playgroud)
Ps.型铸造错误
我有一个textBox1Windows窗体.我想用它来获取用户的日期.我想显示MonthCalender1一旦用户将光标放入textbox1,然后textbox1自动设置日期,然后日历将消失.我如何使用C#或C++/CLI来做到这一点?
我有一段代码来读取构建日期和月份.这__DATE__是在预定义宏中定义的
const char* BUILD_DATE = __DATE__;
std::stringstream ss(BUILD_DATE);
std::string month;
size_t year;
ss >> month;
ss >> year;
ss >> year;
char buffer[1024];
sprintf(buffer, "Read year=[%d] month=[%s] date=[%s]", year,month.c_str(),BUILD_DATE);
Run Code Online (Sandbox Code Playgroud)
当它正常工作时,通常是缓冲区
读取年份= [2013]月= [3月]日期= [2013年3月9日]
但在某些运行中它是
读取年份= [0]月= [M]日期= [2013年3月9日]
要么
读取年份= [2013]月= [3月]日期= [2013年3月9日]
基本上年份是0或月份有额外的空间.
该项目是在Windows 7上使用Microsoft Visual Studio 2010 SP1的x64/CLR版本.
我很难过为什么偶尔会发生这种情况.我是否正确使用stringstream?
我有一个C++ DLL与以下方法:
//C++ dll method (external)
GetServerInterface(ServerInterface* ppIF /*[OUT]*/)
{
//The method will set ppIF
}
//ServerInterface is defined as:
typedef void * ServerInterface;
Run Code Online (Sandbox Code Playgroud)
为了从C#项目访问dll,我创建了一个C++/CLI项目并声明了一个托管类,如下所示:
public ref class ComWrapperManager
{
//
//
ServerInterface _serverInterface;
void Connect();
//
//
}
Run Code Online (Sandbox Code Playgroud)
我使用Connect()方法调用GetServerInterface,如下所示.第一次通话有效,第二次通话无效.有人可以解释原因吗?我需要将该指针持久化为托管类中的成员变量.有更好的方法吗?
void Connect()
{
ServerInterface localServerInterface;
GetServerInterface(&localServerInterface); //THIS WORKS
GetServerInterface(&_serverInterface); //THIS DOESNT
//Error 1 error C2664: 'ServerInterface ' :
//cannot convert parameter 1 from //'cli::interior_ptr<Type>'
//to 'ServerInterface *'
}
Run Code Online (Sandbox Code Playgroud) 我有一个使用以下组件构建的C/C++应用程序
我的问题是:C#assembly产生异步I/O线程以响应来自父应用程序的调用,并在后台使用一对System.Threading.Timer实例.
这些线程继续附加本机C/C++应用程序(1)并引起一些副作用,例如COM初始化问题.
这是C#组件运行时输出窗口的样子,我可以看到这些线程在运行时附加到C++/CLI DLL(3)入口点.

我的问题是:如何从C/C++应用程序中防火这些C#线程?我不希望这些线程能够继续调用加载它的本机代码的入口点.
到目前为止,我们能够提出的最好的解决方法是运行所有在他们自己的独立Win32线程(可以工作)中调用C++/CLI/C#dlls(3和4)的代码,但我会很感激任何其他建议!
我有一个System::String^C++代码变量.应将此变量转换std::string为稍后转换为const char*via的变量c_str.
// original string
System::String^ path = ...;
// convert to std::string
msclr::interop::marshal_context context;
std::string filename(context.marshal_as<std::string>(path));
// call API function that internally connects to sqlite3 using sqlite3_open as
// sqlite3_open(filename.c_str())
// https://www.sqlite.org/c3ref/open.html -
// const char *filename, /* Database filename (UTF-8) */
doCalculation(filename)
Run Code Online (Sandbox Code Playgroud)
它适用于ASCII路径,但如果路径包含非拉丁字符,则会失败.
所以我需要将marshalled std :: string从当前实现(ASCII?)转换为UTF8.
我试过了
std::wstring dbPath(context.marshal_as<std::wstring>(path));
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> convert;
std::string dbPathU8 = convert.to_bytes(dbPath);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
在C++/CLI项目中,我有方法void DoSomething(long x);.如果我想在用C#编写的任何单元测试中使用它,则方法参数x显示为类型int.
为什么我必须更改签名才能在单元测试(C#)中void DoSomething(long long x);使用类型参数long?
我有字符串类型值"e2ddfa02610e48e983824b23ac955632".我需要添加 - 在此代码中意味着转换为Guid.
EntityKey = "e2ddfa02610e48e983824b23ac955632";
Id = (Guid)paymentRecord.EntityKey;
Run Code Online (Sandbox Code Playgroud) c++-cli ×10
c# ×5
.net ×2
c++ ×2
certificate ×1
exe ×1
long-integer ×1
pointers ×1
stringstream ×1
types ×1
visual-c++ ×1
winapi ×1