0

我实现了通过 jni4net 将 C# 与 Java 连接起来的实现。

我用 C# 生成了一个测试类(将 cs 文件转换为 dll)并从 Java 调用,工作正常。

我的问题是 dll;此 dll 由客户端提供。在执行proxygen生成文件并将文件放入工作区时,抛出此错误:

KeyNotFoudException

我不是 .net 开发人员,在我对异常的调查中,我找到了解决方案,但在 dll 的代码中找不到错误。

我使用 dotPeek 和 .Net Reflector 来反编译 dll。

此 dll 管理系统打印机和打印文件。

关于例外的任何建议或想法?

提前致谢。

这是dll代码:

    // Decompiled with JetBrains decompiler
// Type: SymetryBusModuloImpresora.cImpresora
// Assembly: SymetryBusModuloImpresora, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 86BC466E-075C-4F92-BB07-DEADD34550EF

using System;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Management;
using System.Runtime.InteropServices;

namespace SymetryBusModuloImpresora
{
  public class cImpresora
  {
    [DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);

    [DllImport("winspool.Drv", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern bool ClosePrinter(IntPtr hPrinter);

    [DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern bool StartDocPrinter(IntPtr hPrinter, int level, [MarshalAs(UnmanagedType.LPStruct), In] cImpresora.DOCINFOA di);

    [DllImport("winspool.Drv", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern bool EndDocPrinter(IntPtr hPrinter);

    [DllImport("winspool.Drv", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern bool StartPagePrinter(IntPtr hPrinter);

    [DllImport("winspool.Drv", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern bool EndPagePrinter(IntPtr hPrinter);

    [DllImport("winspool.Drv", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
    public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, int dwCount, out int dwWritten);

    public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, int dwCount)
    {
      int dwWritten = 0;
      IntPtr hPrinter = new IntPtr(0);
      cImpresora.DOCINFOA di = new cImpresora.DOCINFOA();
      bool flag = false;
      di.pDocName = "BanCoppel PDF Print";
      di.pDataType = "RAW";
      if (cImpresora.OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero))
      {
        if (cImpresora.StartDocPrinter(hPrinter, 1, di))
        {
          if (cImpresora.StartPagePrinter(hPrinter))
          {
            flag = cImpresora.WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
            cImpresora.EndPagePrinter(hPrinter);
          }
          cImpresora.EndDocPrinter(hPrinter);
        }
        cImpresora.ClosePrinter(hPrinter);
      }
      if (!flag)
        Marshal.GetLastWin32Error();
      return flag;
    }

    public static bool PrinterExists(string printerName)
    {
      if (string.IsNullOrEmpty(printerName))
        throw new ArgumentNullException("printerName");
      return PrinterSettings.InstalledPrinters.Cast<string>().Any<string>((Func<string, bool>) (name => printerName.ToUpper().Trim() == name.ToUpper().Trim()));
    }

    public static bool SendFileToPrinter(string szPrinterName, string szFileName)
    {
      FileStream fileStream = new FileStream(szFileName, FileMode.Open);
      BinaryReader binaryReader = new BinaryReader((Stream) fileStream);
      byte[] numArray = new byte[fileStream.Length];
      IntPtr num1 = new IntPtr(0);
      int int32 = Convert.ToInt32(fileStream.Length);
      byte[] source = binaryReader.ReadBytes(int32);
      IntPtr num2 = Marshal.AllocCoTaskMem(int32);
      int startIndex = 0;
      IntPtr destination = num2;
      int length = int32;
      Marshal.Copy(source, startIndex, destination, length);
      int num3 = cImpresora.SendBytesToPrinter(szPrinterName, num2, int32) ? 1 : 0;
      Marshal.FreeCoTaskMem(num2);
      return num3 != 0;
    }

    public static bool SendStringToPrinter(string szPrinterName, string szString)
    {
      int length = szString.Length;
      IntPtr coTaskMemAnsi = Marshal.StringToCoTaskMemAnsi(szString);
      cImpresora.SendBytesToPrinter(szPrinterName, coTaskMemAnsi, length);
      Marshal.FreeCoTaskMem(coTaskMemAnsi);
      return true;
    }

    public static int ImprimirPDF(string p_Ruta, string p_Archivo)
    {
      string path = p_Ruta + "\\" + p_Archivo;
      if (!File.Exists(path))
        return -7;
      try
      {
        byte[] source = File.ReadAllBytes(path);
        string printerName = new PrinterSettings().PrinterName;
        IntPtr num1 = new IntPtr(0);
        int length1 = source.Length;
        IntPtr num2 = Marshal.AllocCoTaskMem(length1);
        int startIndex = 0;
        IntPtr destination = num2;
        int length2 = length1;
        Marshal.Copy(source, startIndex, destination, length2);
        cImpresora.SendBytesToPrinter(printerName, num2, length1);
        Marshal.FreeCoTaskMem(num2);
        return 0;
      }
      catch (Exception ex)
      {
        Console.WriteLine(ex.Message);
        return -5;
      }
    }

    [STAThread]
    public static int ImpresoraEstatus(string p_Impresora)
    {
      int num = -2;
      new ManagementScope("\\root\\cimv2").Connect();
      foreach (ManagementObject managementObject in new ManagementObjectSearcher("SELECT * FROM Win32_Printer").Get())
      {
        if (managementObject["Name"].ToString().Trim().ToLower().Equals(p_Impresora.ToLower()))
        {
          Console.WriteLine("Printer = " + managementObject["Name"]);
          if (managementObject["WorkOffline"].ToString().ToLower().Equals("true"))
          {
            Console.WriteLine("Your Plug-N-Play printer is not connected.");
            num = -8;
            break;
          }
          Console.WriteLine("Your Plug-N-Play printer is connected.");
          num = 0;
          break;
        }
      }
      return num;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class DOCINFOA
    {
      [MarshalAs(UnmanagedType.LPStr)]
      public string pDocName;
      [MarshalAs(UnmanagedType.LPStr)]
      public string pOutputFile;
      [MarshalAs(UnmanagedType.LPStr)]
      public string pDataType;
    }
  }
}

另外:我尝试使用 JNI:我参考客户端提供的 dll 创建了一个 C++ 文件,我的实现是:

代码 C++

#include "stdafx.h"
#include "CppSymetryBusModuloImpresora.h"
#include "mx_com_solser_service_PrinterService.h"
#include <string>

using System::Text::Encoding;

String^ toString(const char * chars) {
    int len = (int)strlen(chars);
    array<unsigned char>^ a = gcnew array<unsigned char>(len);
    for (int i = 0; i < len; i++) {
        a[i] = chars[i];
    }

    return Encoding::UTF8->GetString(a);
}


int imprimirPDF(const char *ruta, const char *archivo) {
    return SymetryBusModuloImpresora::cImpresora::ImprimirPDF(toString(ruta), toString(archivo)); //Accesing to dll method
}

JNIEXPORT jint JNICALL Java_mx_com_solser_service_PrinterService_imprimirPDF
(JNIEnv *env, jclass c, jstring ruta, jstring archivo) {
    jint responseCode;
    jboolean isCopyRuta;
    jboolean isCopyArchivo;

    const char *p_ruta = env->GetStringUTFChars(ruta, &isCopyRuta);
    const char *p_archivo = env->GetStringUTFChars(archivo, &isCopyArchivo);
    responseCode = imprimirPDF(p_ruta, p_archivo);

    env->ReleaseStringUTFChars(ruta, p_ruta);
    env->ReleaseStringUTFChars(archivo, p_archivo);

    return responseCode;
}

Java代码:

package mx.com.solser.service;


import mx.com.solser.exception.PrinterException;
import mx.com.solser.util.CodigoError;

public class PrinterService  {

    private Integer codigoRespuesta = -1;
    private static PrinterService printerService = null;
    private static final String SPACE_FORMAT = "Codigo Respuesta: %d ::: %s";

    static native int imprimirPDF(String ruta, String archivo);

    static {
        System.loadLibrary("CppSymetryBusModuloImpresora");
    }

    private PrinterService () {}

    public static PrinterService getInstance() {
        return printerService != null ? printerService : new PrinterService();
    }

    public Integer printAndGetCode(final String ruta, final String archivo) throws PrinterException {
        if (isNullOrEmpty(ruta) || isNullOrEmpty(archivo))
            throw new PrinterException(getMessageCode(codigoRespuesta, CodigoError.getMessage(codigoRespuesta)));       

        if ((codigoRespuesta = imprimirPDF(ruta, archivo)) != 0)
            throw new PrinterException(getMessageCode(codigoRespuesta, CodigoError.getMessage(codigoRespuesta)));

        return codigoRespuesta;
    }   

    private boolean isNullOrEmpty(String param) {
        return (param == null || param.isEmpty());
    }

    private String getMessageCode(final Integer codigoRespuesta, final String message) {
        return String.format(SPACE_FORMAT, codigoRespuesta, message);
    }
}

错误:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (0xe0434352), pid=1472, tid=0x000000000000186c
#
# JRE version: Java(TM) SE Runtime Environment (8.0_112-b15) (build 1.8.0_112-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.112-b15 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [KERNELBASE.dll+0x2a1c8]
#
# Core dump written. Default location: E:\WSImpresion\PrintService\hs_err_pid1472.mdmp
#
# An error report file with more information is saved as:
# E:\WSImpresion\PrintService\hs_err_pid1472.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

日志:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (0xe0434352), pid=7776, tid=0x0000000000003128
#
# JRE version: Java(TM) SE Runtime Environment (8.0_112-b15) (build 1.8.0_112-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.112-b15 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [KERNELBASE.dll+0x2a1c8]
#
# Core dump written. Default location: E:\WSImpresion\PrintService\hs_err_pid7776.mdmp
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x0000000002ccd800):  JavaThread "main" [_thread_in_native, id=12584, stack(0x0000000002cd0000,0x0000000002dd0000)]

siginfo: ExceptionCode=0xe0434352, ExceptionInformation=0xffffffff80070002 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x00007fff4ee40000 

Registers:
RAX=0x0000000000f8aaf0, RBX=0x0000000002dcc230, RCX=0x0000000000000000, RDX=0x0000000000f768d0
RSP=0x0000000002dca2b0, RBP=0x0000000002dca960, RSI=0x0000000002dcc860, RDI=0x0000000002dcb0c0
R8 =0x0000000200000000, R9 =0x0000000100000002, R10=0x0000000000000002, R11=0x0000000100000002
R12=0x0000000002dca408, R13=0x0000000000000000, R14=0x0000000002dcb6d8, R15=0x0000000000000000
RIP=0x00007fff77b0a1c8, EFLAGS=0x0000000000000206

Top of Stack: (sp=0x0000000002dca2b0)
0x0000000002dca2b0:   00000001e06d7363 0000000002dcc230
0x0000000002dca2c0:   0000000002dcc860 0000000002dcb0c0
0x0000000002dca2d0:   00000001e0434352 0000000000000000
0x0000000002dca2e0:   00007fff77b0a1c8 0000000000000005
0x0000000002dca2f0:   ffffffff80070002 0000000000000000
0x0000000002dca300:   0000000000000000 0000000000000000
0x0000000002dca310:   00007fff4ee40000 0000000000000000
0x0000000002dca320:   0000000000000000 00007fff5e7c5908
0x0000000002dca330:   0000000002dcc230 0000000000000000
0x0000000002dca340:   0000000002dcb0c0 0000000002dca960
0x0000000002dca350:   0000000002dcb0c0 00007fff5e7c587b
0x0000000002dca360:   0000000002dcc230 0000000002dce7b0
0x0000000002dca370:   0000b44f6781abf0 0000000002dca568
0x0000000002dca380:   0000000002dcc230 00007fff5e801e89
0x0000000002dca390:   00007fff4f248594 0000000002dcb6d8
0x0000000002dca3a0:   0000000000000100 0000000000000000 

Instructions: (pc=0x00007fff77b0a1c8)
0x00007fff77b0a1a8:   49 8b d1 44 0f 47 c0 44 89 44 24 38 49 c1 e0 03
0x00007fff77b0a1b8:   e8 af eb 04 00 48 8d 4c 24 20 ff 15 18 05 0a 00
0x00007fff77b0a1c8:   48 8b 8c 24 c0 00 00 00 48 33 cc e8 88 b4 04 00
0x00007fff77b0a1d8:   48 81 c4 d8 00 00 00 c3 83 64 24 38 00 eb d6 cc 


Register to memory mapping:

RAX=0x0000000000f8aaf0 is an unknown value
RBX=0x0000000002dcc230 is pointing into the stack for thread: 0x0000000002ccd800
RCX=0x0000000000000000 is an unknown value
RDX=0x0000000000f768d0 is an unknown value
RSP=0x0000000002dca2b0 is pointing into the stack for thread: 0x0000000002ccd800
RBP=0x0000000002dca960 is pointing into the stack for thread: 0x0000000002ccd800
RSI=0x0000000002dcc860 is pointing into the stack for thread: 0x0000000002ccd800
RDI=0x0000000002dcb0c0 is pointing into the stack for thread: 0x0000000002ccd800
R8 =0x0000000200000000 is an unknown value
R9 =0x0000000100000002 is an unknown value
R10=0x0000000000000002 is an unknown value
R11=0x0000000100000002 is an unknown value
R12=0x0000000002dca408 is pointing into the stack for thread: 0x0000000002ccd800
R13=0x0000000000000000 is an unknown value
R14=0x0000000002dcb6d8 is pointing into the stack for thread: 0x0000000002ccd800
R15=0x0000000000000000 is an unknown value


Stack: [0x0000000002cd0000,0x0000000002dd0000],  sp=0x0000000002dca2b0,  free space=1000k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [KERNELBASE.dll+0x2a1c8]
C  [MSVCR120_CLR0400.dll+0x61e89]
C  [ntdll.dll+0x95c53]
C  [clr.dll+0x12dbd]
C  [clr.dll+0x12b5a]
C  [clr.dll+0x84c9]
C  [clr.dll+0x3055]
C  0x00007ffeef7d3525

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  mx.com.solser.service.PrinterService.imprimirPDF(Ljava/lang/String;Ljava/lang/String;)I+0
j  mx.com.solser.service.PrinterService.printAndGetCode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Integer;+42
j  mx.com.solser.principal.RunnerPrinter.main([Ljava/lang/String;)V+19
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x000000001e8d6000 JavaThread "Service Thread" daemon [_thread_blocked, id=12780, stack(0x000000001f400000,0x000000001f500000)]
  0x000000001e834800 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=11660, stack(0x000000001f300000,0x000000001f400000)]
  0x000000001e836800 JavaThread "C2 CompilerThread2" daemon [_thread_blocked, id=3868, stack(0x000000001f200000,0x000000001f300000)]
  0x000000001e82c000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=6892, stack(0x000000001f100000,0x000000001f200000)]
  0x000000001e828800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=8720, stack(0x000000001f000000,0x000000001f100000)]
  0x000000001e827000 JavaThread "Attach Listener" daemon [_thread_blocked, id=10052, stack(0x000000001ef00000,0x000000001f000000)]
  0x000000001e824000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=11764, stack(0x000000001ee00000,0x000000001ef00000)]
  0x0000000002ecd800 JavaThread "Finalizer" daemon [_thread_blocked, id=10644, stack(0x000000001ec00000,0x000000001ed00000)]
  0x0000000002ec4800 JavaThread "Reference Handler" daemon [_thread_blocked, id=14240, stack(0x000000001e700000,0x000000001e800000)]
=>0x0000000002ccd800 JavaThread "main" [_thread_in_native, id=12584, stack(0x0000000002cd0000,0x0000000002dd0000)]

Other Threads:
  0x000000001c909800 VMThread [stack: 0x000000001e600000,0x000000001e700000] [id=7548]
  0x000000001e8d9800 WatcherThread [stack: 0x000000001f500000,0x000000001f600000] [id=10956]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap:
 PSYoungGen      total 76288K, used 2621K [0x000000076b300000, 0x0000000770800000, 0x00000007c0000000)
  eden space 65536K, 4% used [0x000000076b300000,0x000000076b58f5e8,0x000000076f300000)
  from space 10752K, 0% used [0x000000076fd80000,0x000000076fd80000,0x0000000770800000)
  to   space 10752K, 0% used [0x000000076f300000,0x000000076f300000,0x000000076fd80000)
 ParOldGen       total 175104K, used 0K [0x00000006c1800000, 0x00000006cc300000, 0x000000076b300000)
  object space 175104K, 0% used [0x00000006c1800000,0x00000006c1800000,0x00000006cc300000)
 Metaspace       used 2607K, capacity 4490K, committed 4864K, reserved 1056768K
  class space    used 284K, capacity 386K, committed 512K, reserved 1048576K

Card table byte_map: [0x0000000012290000,0x0000000012a90000] byte_map_base: 0x000000000ec84000

Marking Bits: (ParMarkBitMap*) 0x0000000063f1a6d0
 Begin Bits: [0x00000000137e0000, 0x0000000017780000)
 End Bits:   [0x0000000017780000, 0x000000001b720000)

Polling page: 0x0000000000f30000

CodeCache: size=245760Kb used=1104Kb max_used=1111Kb free=244655Kb
 bounds [0x0000000002ed0000, 0x0000000003140000, 0x0000000011ed0000]
 total_blobs=257 nmethods=26 adapters=145
 compilation: enabled

Compilation events (10 events):
Event: 0.065 Thread 0x000000001e834800 nmethod 20 0x0000000002fe15d0 code [0x0000000002fe1780, 0x0000000002fe1eb8]
Event: 0.065 Thread 0x000000001e834800   22       3       java.lang.AbstractStringBuilder::append (50 bytes)
Event: 0.065 Thread 0x000000001e834800 nmethod 22 0x0000000002fe2290 code [0x0000000002fe2460, 0x0000000002fe2bb8]
Event: 0.065 Thread 0x000000001e834800   24       3       java.lang.String::indexOf (7 bytes)
Event: 0.065 Thread 0x000000001e82c000 nmethod 23 0x0000000002fe5b90 code [0x0000000002fe5ce0, 0x0000000002fe5db8]
Event: 0.065 Thread 0x000000001e834800 nmethod 24 0x0000000002fe5790 code [0x0000000002fe5900, 0x0000000002fe5b08]
Event: 0.068 Thread 0x000000001e834800   25       3       java.lang.StringBuilder::append (8 bytes)
Event: 0.068 Thread 0x000000001e834800 nmethod 25 0x0000000002fe4c10 code [0x0000000002fe4d80, 0x0000000002fe4f08]
Event: 0.069 Thread 0x000000001e834800   26       3       java.lang.System::getSecurityManager (4 bytes)
Event: 0.069 Thread 0x000000001e834800 nmethod 26 0x0000000002fe4910 code [0x0000000002fe4a60, 0x0000000002fe4bb0]

GC Heap History (0 events):
No events

Deoptimization events (0 events):
No events

Internal exceptions (2 events):
Event: 0.026 Thread 0x0000000002ccd800 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; name or signature does not match> (0x000000076b307c78) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\
Event: 0.026 Thread 0x0000000002ccd800 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.prefetchRead(Ljava/lang/Object;J)V name or signature does not match> (0x000000076b307f60) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\prims

Events (10 events):
Event: 0.068 loading class java/lang/Class$MethodArray
Event: 0.068 loading class java/lang/Class$MethodArray done
Event: 0.068 loading class mx/com/solser/exception/PrinterException
Event: 0.068 loading class mx/com/solser/exception/PrinterException done
Event: 0.068 loading class java/lang/Void
Event: 0.069 loading class java/lang/Void done
Event: 0.069 loading class mx/com/solser/service/PrinterService
Event: 0.069 loading class mx/com/solser/service/PrinterService done
Event: 0.069 loading class java/lang/ClassLoaderHelper
Event: 0.069 loading class java/lang/ClassLoaderHelper done


Dynamic libraries:
0x00007ff70acc0000 - 0x00007ff70acf7000     C:\Program Files\Java\jdk1.8.0_112\bin\javaw.exe
0x00007fff7ad90000 - 0x00007fff7af52000     C:\Windows\SYSTEM32\ntdll.dll
0x00007fff795b0000 - 0x00007fff7965d000     C:\Windows\system32\KERNEL32.DLL
0x00007fff77ae0000 - 0x00007fff77cbd000     C:\Windows\system32\KERNELBASE.dll
0x00007fff786d0000 - 0x00007fff78776000     C:\Windows\system32\ADVAPI32.dll
0x00007fff791f0000 - 0x00007fff7928d000     C:\Windows\system32\msvcrt.dll
0x00007fff78510000 - 0x00007fff7856b000     C:\Windows\system32\sechost.dll
0x00007fff789e0000 - 0x00007fff78b06000     C:\Windows\system32\RPCRT4.dll
0x00007fff78da0000 - 0x00007fff78eee000     C:\Windows\system32\USER32.dll
0x00007fff787e0000 - 0x00007fff78965000     C:\Windows\system32\GDI32.dll
0x00007fff72150000 - 0x00007fff723c4000     C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.10240.17184_none_f41d7a705752bce6\COMCTL32.dll
0x00007fff7ac00000 - 0x00007fff7ac36000     C:\Windows\system32\IMM32.DLL
0x00007fff78570000 - 0x00007fff786cc000     C:\Windows\system32\MSCTF.dll
0x0000000063fa0000 - 0x0000000064072000     C:\Program Files\Java\jdk1.8.0_112\jre\bin\msvcr100.dll
0x0000000063700000 - 0x0000000063f9a000     C:\Program Files\Java\jdk1.8.0_112\jre\bin\server\jvm.dll
0x00007fff79660000 - 0x00007fff79668000     C:\Windows\system32\PSAPI.DLL
0x00007fff6eb30000 - 0x00007fff6eb39000     C:\Windows\SYSTEM32\WSOCK32.dll
0x00007fff75c70000 - 0x00007fff75c93000     C:\Windows\SYSTEM32\WINMM.dll
0x00007fff73ed0000 - 0x00007fff73eda000     C:\Windows\SYSTEM32\VERSION.dll
0x00007fff78970000 - 0x00007fff789d9000     C:\Windows\system32\WS2_32.dll
0x00007fff78500000 - 0x00007fff78508000     C:\Windows\system32\NSI.dll
0x0000000001340000 - 0x000000000136c000     C:\Windows\SYSTEM32\WINMMBASE.dll
0x00007fff78400000 - 0x00007fff78444000     C:\Windows\system32\cfgmgr32.dll
0x00007fff76130000 - 0x00007fff76157000     C:\Windows\SYSTEM32\DEVOBJ.dll
0x00000000636f0000 - 0x00000000636ff000     C:\Program Files\Java\jdk1.8.0_112\jre\bin\verify.dll
0x00000000636c0000 - 0x00000000636e9000     C:\Program Files\Java\jdk1.8.0_112\jre\bin\java.dll
0x00000000636a0000 - 0x00000000636b6000     C:\Program Files\Java\jdk1.8.0_112\jre\bin\zip.dll
0x00007fff79670000 - 0x00007fff7ab93000     C:\Windows\system32\SHELL32.dll
0x00007fff77d20000 - 0x00007fff78349000     C:\Windows\system32\windows.storage.dll
0x00007fff78f70000 - 0x00007fff791ec000     C:\Windows\system32\combase.dll
0x00007fff78f10000 - 0x00007fff78f61000     C:\Windows\system32\shlwapi.dll
0x00007fff777b0000 - 0x00007fff777bf000     C:\Windows\system32\kernel.appcore.dll
0x00007fff77850000 - 0x00007fff77903000     C:\Windows\system32\shcore.dll
0x00007fff77800000 - 0x00007fff7784a000     C:\Windows\system32\powrprof.dll
0x00007fff777e0000 - 0x00007fff777f3000     C:\Windows\system32\profapi.dll
0x00007fff6afe0000 - 0x00007fff6b012000     E:\WSImpresion\PrintService\CppSymetryBusModuloImpresora.dll
0x00007fff6afb0000 - 0x00007fff6afd2000     C:\Windows\SYSTEM32\VCRUNTIME140D.dll
0x00007fff6ac20000 - 0x00007fff6addb000     C:\Windows\SYSTEM32\ucrtbased.dll
0x00007fff67960000 - 0x00007fff679c8000     C:\Windows\SYSTEM32\mscoree.dll
0x00007fff6aeb0000 - 0x00007fff6afa6000     C:\Windows\SYSTEM32\MSVCP140D.dll
0x00007fff62460000 - 0x00007fff624f8000     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
0x00007fff4ee40000 - 0x00007fff4f79c000     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
0x00007fff5e7a0000 - 0x00007fff5e897000     C:\Windows\SYSTEM32\MSVCR120_CLR0400.dll
0x00007fff4d9a0000 - 0x00007fff4ee38000     C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\fa8eef6f6cb67c660d71e15c5cad71b5\mscorlib.ni.dll
0x00007fff5e690000 - 0x00007fff5e795000     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll
0x00007fff7acb0000 - 0x00007fff7ad72000     C:\Windows\system32\OLEAUT32.dll
0x00007fff6ab00000 - 0x00007fff6ac17000     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\diasymreader.dll
0x00007fff79460000 - 0x00007fff795a1000     C:\Windows\system32\ole32.dll
0x00007fff4cdc0000 - 0x00007fff4d992000     C:\Windows\assembly\NativeImages_v4.0.30319_64\System\dd13bec6e0f1710a98d6c8745d5d4eb4\System.ni.dll
0x00007fff69fb0000 - 0x00007fff6a13a000     C:\Windows\system32\DBGHELP.DLL
0x00007fff6ae80000 - 0x00007fff6aea5000     C:\Windows\SYSTEM32\dbgcore.DLL

VM Arguments:
jvm_args: -XX:+CreateMinidumpOnCrash -Dfile.encoding=Cp1252 
java_command: mx.com.solser.principal.RunnerPrinter
java_class_path (initial): E:\WSImpresion\PrintService\bin
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_112
PATH=C:/Program Files/Java/jre1.8.0_121/bin/server;C:/Program Files/Java/jre1.8.0_121/bin;C:/Program Files/Java/jre1.8.0_121/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_112\bin;E:\Software\apache-maven-3.3.9\bin;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Skype\Phone\;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;E:\IDE\eclipse;
USERNAME=Green 4
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 10.0 , 64 bit Build 10240 (10.0.10240.17113)

CPU:total 8 (4 cores per cpu, 2 threads per core) family 6 model 42 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, aes, clmul, ht, tsc, tscinvbit

Memory: 4k page, physical 16675216k(9227236k free), swap 17723792k(10648200k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (25.112-b15) for windows-amd64 JRE (1.8.0_112-b15), built on Sep 22 2016 21:31:56 by "java_re" with MS VC++ 10.0 (VS2010)

time: Thu Mar 09 09:18:39 2017
elapsed time: 0 seconds (0d 0h 0m 0s)
4

1 回答 1

0

解决了。

我创建了另一个 C# 类并引用了客户端提供的 dll,仅此而已。

jni4net 插件工作正常。

代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SymetryBusModuloImpresora;

namespace PrinterService {
    public class PrinterService {
            public static int imprimriPDF(string ruta, string archivo) {
            return SymetryBusModuloImpresora.cImpresora.ImprimirPDF(ruta, archivo);
        }
    }
}

之后,就像 jni4net 插件文档一样。
1.- proxygen
2.- build.cmd 3.-
加载生成的 dll 3.-
将 jars 放入类路径

于 2017-03-11T00:31:28.480 回答