When I use the jna method, java calls c# with a constant error.

java.lang.Error: Invalid memory access

c# code is below (64 bit),

namespace EwpDeleteBlank
{

    public static class RemoveBlankPage
    {

    }
}

c++ code is below (pch.h and pch.cpp, 64 bit), pch.h is below,

#ifndef PCH_H
#define PCH_H


#include "framework.h"
#include <string>

using namespace std;

#define  MYLIBAPI  extern "C" __declspec(dllexport) 

MYLIBAPI  void deleteBlankPages();


#endif //PCH_H

pch.cpp is below,

#include "pch.h"
#include <string>



#using "C:\Users\zhang\Desktop\g\ewp-delete-blank\bin\x64\Debug\RemoveBlankPage.dll"

using namespace EwpDeleteBlank;
using namespace std;

void deleteBlankPages() {

    RemoveBlankPage ^obj = gcnew RemoveBlankPage();
}

java code is below,

public interface MyLibraryInterface extends Library {

    MyLibraryInterface instance = (MyLibraryInterface) Native.loadLibrary("Dll1.dll", MyLibraryInterface.class);

    void deleteBlankPages();
}

:
MyLibraryInterface.instance.deleteBlankPages();

but when run , it show error,

java.lang.Error: Invalid memory access
0

There are 0 best solutions below