Pairing programming: Summary of interface modules

Source: Internet
Author: User

Our group is written in C + + with the underlying module, C # writing interface.

C + + generates a DLL and is then called in C #. Various functions were called out during the various problems.

1.c# attempts to read or write to protected memory, which usually indicates that other memory is corrupted.

This is caused by a mismatch between C # and some C + + data types. C + + uses the char**, tried a variety of methods including list,string[],vector,string and so on can not be resolved, generics can not be passed, so give up a transfer string, The intention of passing all strings of string after the string is cut open, and the same is string,c# and C + + but not the same, and finally found in C # in string,c++ with char*, so the call function can match. However, in C + + there is no split method, can only achieve one of their own, compared to other pits this is nothing ...

2.c# cannot find an entry point named "" in DLL ". dll"

This tried all sorts of ways to always find the reason. This includes checking parameters, checking for errors in calls, registering DLLs, checking DLLs for damage, and wondering if you want to set the function return value to static but not all. Finally know the expends tools and Exescope tools, learned that C + + compile time will add some inexplicable symbols, changed the function name, so the original function name can not be called. Then try to use the tool to see the changed function name, but did not find, and then continue to Baidu found that can load module definition files. Def this avoids the compiler changing the function name. In the data to see this is a general method, than to find the function name more effective, but do not know how to write Def, and Baidu a bit, fortunately not difficult. However, I did not know how to add into the project, tried several methods, and finally found to manually add. Finally solved.

3. Pointers and fixed-size buffers can only be used in unsafe contexts

This Baidu a bit need to set up to allow unsafe code and unsafe keywords can be resolved. But the last part of the code changed.

4. Contains non-ASCII characters and may not load DLLs on systems that have ANSI code pages other than 936

Originally did not know that there is a CPP file can be directly generated DLL, internet Baidu thought to manually write a variety of things and then output into a DLL, the study of a half-day written well so out of this error, can compile is the link error. Baidu is not the answer

Ask people everywhere can not solve, and finally the question did not know why. But then I knew I could build the DLL directly, so that's the problem.

Mainly on these issues, there are some minor problems. It took more than 24 hours to solve these problems, and last night's tune didn't work out. Fortunately, the final interface design is not too difficult, as long as the package is good, directly call on it.

Pairing programming: Summary of interface modules

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.