Answer the question
In order to leave comments, you need to log in
How to connect dll with c++ code to C# project?
You need to use C++ code in a C# project. The only option that I know of is to pack the code into a dll and include it in a C# project. Created a DLL following this instruction: https://docs.microsoft.com/ru-ru/cpp/build/walkthr... . When connecting a dll in C # through links, it throws an error (screen is attached). Tried using the following option:
[DllImport("Dll2.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern double Add(double a, double b);
Answer the question
In order to leave comments, you need to log in
Something you read in the
wrong place https://docs.microsoft.com/ru-ru/dotnet/standard/n...
using System;
using System.Runtime.InteropServices;
public class Program
{
// Import user32.dll (containing the function we need) and define
// the method corresponding to the native function.
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern int MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType);
public static void Main(string[] args)
{
// Invoke the function as a regular managed method.
MessageBox(IntPtr.Zero, "Command-line message box", "Attention!", 0);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question