Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
W

Willow2008

@Willow2008
About
Posts
4
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • function call from an c++ dll in c#
    W Willow2008

    Thank you very much !! I got it :))

    C# help csharp c++ debugging question

  • function call from an c++ dll in c#
    W Willow2008

    Sorry to bother you :(( I´m very glad about your help !! And I have to excuse me but I don´t have much experience in C# coding..:( I will give you more details what I want to do: I have a windows programm from and I have to make a communication to this programm. The supplier of the other programm provided me a dll with different functions inside. Now from my understanding the easiest way to setup the communication is to use this dll. So I only wanted to make a short trial if I can call this functions and if the communication can be established ! Fct1, Fct3 and Fct4 are returning a value that shows a good result. The problem is Fct2 where I have to deal with pointer :((( Thanks again !!

    C# help csharp c++ debugging question

  • function call from an c++ dll in c#
    W Willow2008

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Data;

    namespace ConsoleApplication1
    {
    class Program
    {
    [DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
    extern static int Fct1();

        \[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)\]
        extern static int Fct2();
    
        \[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)\]
        extern static int Fct3(IntPtr Size, byte\[\] data, int timeout);
    
        \[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)\]
        extern static int Fct4(int size, byte\[\] data);
    
        static void Main(string\[\] args)
        {
            byte\[\] data = new byte\[5\] {0x01,0x02,0x03,0x04,0x05};
    
    
            int result = Fct1();
            Console.WriteLine(result);
    
            result = Fct2((IntPtr)2, data, 3);
            Console.WriteLine(result);
    
            result = Fct3(3, data);
            Console.WriteLine(result);
    
            result = Fct4();
            Console.WriteLine(result);
    
    
        }
    }
    

    }

    ErrorMessage: AccessViolation at Fct2

    C# help csharp c++ debugging question

  • function call from an c++ dll in c#
    W Willow2008

    Hello, I hope somebody can help me and I hope I put my questions into the right forum !! If not pls let me know !! I received a c++ dll with a function inside: int FunctionCall(int* Size, unsigned char Data[], int time) I used the DLLImport:

    [DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
    extern static int FunctionCall(IntPtr Size, byte[] data, int timeout);

    But when I debug I always get an out of range error !! What did I wrong ?? Thank you very much for your help !!

    C# help csharp c++ debugging question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups