1. vc9: Link: Warning lnk4068:/machine not specified; defaulting to x86
One of the reasons: the resource files contained in the project are not in the current project directory.
Solution: Check whether the resource file is valid. If the file is invalid, delete it. OK. The problem is solved.
2. A large number of errors have occurred. The "int" type is not recognized, and it does not end ";".
One of the reasons: Windows. h file not included
Solution: Include the windows. h file and OK file before the common header file. Solution
3. Command Line warning d9028: Minimal rebuild failure, reverting to normal build Cl (minimum re-generation failed, converting to standard generation)
One of the reasons: the project. IDB file is damaged.
Solution: delete and regenerate the. IDB file. Delete the. IDB file in the DEBUG directory. OK. Solution
4. badimageformatexception is not handled and an attempt is made to load a program with incorrect format. (Exception from hresult: 0x8007000b)
One of the reasons: this API is developed in a 32-bit system. When developing and compiling a 64-bit system, you need to set the generated target platform to x86.
Solution: In Solution Explorer on the right, right-click the project and choose Properties. In the Properties window, select "generate"> "Target Platform". Under Larry, select "x86. See:
5. c ++ DLL calls back the C # method. The dll must pass the byte array to the callback method. The result message processing function receives only one byte.
One of the reasons: the C ++ callback function has a parameter, which is the callback function pointer for processing received byte streams. The definition is basically as follows:
Typedef void (* fpdatareceived) (char * data, int Len );
Char * data is the byte stream returned from the DLL, and the space has been allocated in the DLL.
The following is the delegate defined in C #.
Public Delegate void ondatareceived (byte [] data, int Len );
The following is the implementation of the callback function in C #.
Public void getdata (byte [] data, int Len)
{
// The result shows that the data dimension is only 1, that is, only one byte is received.
}
Solution: 1. Using system. runtime. interopservices;
2. Define the delegation as follows:
Public Delegate void ondatareceived (intptr pdata, int Len); // pdata is a pointer address, corresponding to the preceding char * pointer data
3. The implementation of the callback function is as follows:
Public void getdata (intptr pdata, int Len)
{
Byte [] DATA = new byte [Len];
Marshal. Copy (pdata, Data, 0, Len );
// Process the content in Data
}