Click here to Skip to main content
15,888,803 members
Home / Discussions / C#
   

C#

 
AnswerRe: Async await error Pin
Gerry Schmitz3-May-20 18:34
mveGerry Schmitz3-May-20 18:34 
AnswerRe: Async await error Pin
Richard Deeming5-May-20 1:16
mveRichard Deeming5-May-20 1:16 
QuestionHow to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
boozeeh11-May-20 5:01
boozeeh11-May-20 5:01 
AnswerRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
Luc Pattyn1-May-20 7:43
sitebuilderLuc Pattyn1-May-20 7:43 
GeneralRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
boozeeh11-May-20 12:20
boozeeh11-May-20 12:20 
GeneralRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
Luc Pattyn1-May-20 13:43
sitebuilderLuc Pattyn1-May-20 13:43 
GeneralRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
boozeeh12-May-20 1:31
boozeeh12-May-20 1:31 
QuestionUse DLL in C# Pin
Member 1481764029-Apr-20 15:16
Member 1481764029-Apr-20 15:16 
Hello,

I have a dll created with delphi language (Borland Delphi 7) which thus contains functions in delphi which I would like to use in C# under Visual Studio 2017. It is a native dll.
I want to use for example the GENERATE_FILE function contained in test.dll.

Delphi code :
procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall; 


procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall;
var

begin
…
GENERATE_CALC(Path_And_File, CRC32, Total, err);
…
end;


In C#, I want to use the function GENERATE_FILE contained in test.dll but what is the type of the parameters Path and Input_File in C# ?

Below is an example of C# code I made to use test.dll in delphi in C#. I set string as a type for parameters of the function GENERATE_FILE.

namespace AppTest
{
    Public class Program
    {
        [DllImport("test.dll", CharSet = CharSet.Ansi)]
        public static extern bool CREATE_FILE(string pathDirectory, string filename);

        static void Main(string[] args)
        {
            GENERATE_FILE(@"C:\Users", "file.txt");
        }
    }
}

I added the test.dll in Visual Studio by right clicking on the project then add an existing element, then, in the properties of the test.dll, I put "Content" in Generation action and I put "Always copy "(output directory). When I run the solution, I have the test.dll in bin\Debug.

But when I test this program, I get the following error at the line that contains:
GENERATE_FILE(@"C:\Users", "file.txt");

System.DllNotFoundException: 'Unable to load DLL' test.dll ': The specified module could not be found. (Exception from HRESULT: 0x8007007E) '


How to solve this problem ?
I think the issue is about the type of parameters in the function GENERATE_FILE. What are the type equivalents between delphi and C# for the function GENERATE_FILE ?

Thank you for your help.

AnswerRe: Use DLL in C# Pin
Dave Kreskowiak29-Apr-20 16:56
mveDave Kreskowiak29-Apr-20 16:56 
AnswerRe: Use DLL in C# Pin
Luc Pattyn29-Apr-20 17:11
sitebuilderLuc Pattyn29-Apr-20 17:11 
AnswerRe: Use DLL in C# Pin
Eddy Vluggen30-Apr-20 9:34
professionalEddy Vluggen30-Apr-20 9:34 
AnswerRe: Use DLL in C# Pin
kalberts2-May-20 4:40
kalberts2-May-20 4:40 
QuestionCan not compare a file and same file stored in mysql - sha256 Pin
wilcodk29-Apr-20 7:40
wilcodk29-Apr-20 7:40 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Luc Pattyn29-Apr-20 8:07
sitebuilderLuc Pattyn29-Apr-20 8:07 
GeneralRe: Can not compare a file and same file stored in mysql - sha256 Pin
wilcodk30-Apr-20 1:32
wilcodk30-Apr-20 1:32 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Mycroft Holmes29-Apr-20 12:18
professionalMycroft Holmes29-Apr-20 12:18 
GeneralRe: Can not compare a file and same file stored in mysql - sha256 Pin
wilcodk30-Apr-20 1:28
wilcodk30-Apr-20 1:28 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Eddy Vluggen30-Apr-20 6:34
professionalEddy Vluggen30-Apr-20 6:34 
QuestionCompare string time to timer time (noobie) Pin
Member 1481029228-Apr-20 5:36
Member 1481029228-Apr-20 5:36 
AnswerRe: Compare string time to timer time (noobie) Pin
Gerry Schmitz28-Apr-20 6:48
mveGerry Schmitz28-Apr-20 6:48 
QuestionResize and move a drawn rectangle in win forms Pin
Member 1223285027-Apr-20 12:23
Member 1223285027-Apr-20 12:23 
AnswerRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn27-Apr-20 13:17
sitebuilderLuc Pattyn27-Apr-20 13:17 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Member 1223285027-Apr-20 19:38
Member 1223285027-Apr-20 19:38 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn28-Apr-20 4:50
sitebuilderLuc Pattyn28-Apr-20 4:50 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Member 1223285028-Apr-20 17:56
Member 1223285028-Apr-20 17:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.