大佬教程收集整理的这篇文章主要介绍了c – MySQL NDB API AccessViolationException,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
private const String ndbapi = "ndb"; [DllImport(ndbapi)] public extern static intPtr init(IntPtr conn_String); [DllImport(ndbapi)] public extern static void read(IntPtr ndb_cluster_conn); [DllImport(ndbapi)] public extern static void release(IntPtr ndb_cluster_conn,IntPtr char_arr_ptr); private static intPtr handle; private static void InitNdb() { unsafe { fixed (byte* conn_buf = Encoding.UTF8.GetBytes("node1:1186")) { handle = ndb_api_init(new IntPtr(conn_buf)); } } } static void Main(String[] args) { Thread t = new Thread(InitNdb);// IF I CALL InitNDB IN THE SAME THREAD,EVERYTHING WORKS t.Start(); .. //waiTing for Thread t to complete... IntPtr bytes_read = read(handlE); ... }@H_673_2@C代码:(基于official documentation的例子):
#if Defined(WIN32) #define DLLEXPORT __declspec(dllexport) #define CALLCV __stdcall #else #define DLLEXPORT __attribute__((visibility("default"))) #define CALLCV __attribute__((cdecl)) #endif .. extern "C" DLLEXPORT Ndb_cluster_connection* CALLCV init(char* connection_String) { ndb_init(); // Object represenTing the cluster Ndb_cluster_connection* cluster_connection = new Ndb_cluster_connection(connection_String); if (cluster_connection->connect(3,2,1)) { std::cout << "Cluster management server not ready,error:" << cluster_connection->get_la@R_450_9214@error_msg() << "\n"; exit(-1); } if (cluster_connection->wait_until_ready(10,0) < 0) { std::cout << "Cluster not ready within 10 secs,error:" << cluster_connection->get_la@R_450_9214@error_msg() << std::endl; } return cluster_connection; } extern "C" DLLEXPORT char** CALLCV read(Ndb_cluster_connection* cluster_connection) { Ndb *ndb_obj = new Ndb(cluster_connection,db_name); if (ndb_obj->init()) { std::cout << "Error while initializing Ndb " << std::endl; } const NdbDictionary::Dictionary* Dict = ndb_obj->getDictionary(); const NdbDictionary::Table *table = Dict->getTable("table_name"); <-- THIS IS THE LINE THAT THROWS ACCESS VIOLATION EXCEPTION .. }
以上是大佬教程为你收集整理的c – MySQL NDB API AccessViolationException全部内容,希望文章能够帮你解决c – MySQL NDB API AccessViolationException所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。