2

I have my c# class library.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Keyence.IV.Sdk;
using System.Reflection;
namespace JavaKameraSchnittstelle
{

public class KeyenceKameraSchnittstellen
{   
    private IVisionSensor[] sensor;
    private VisionSensorStore store;
    private List<byte[]> images;
    private DateTime lastUpdate;
    private bool[] areConnected;


    public KeyenceKameraSchnittstellen()
    {
    ...
    }

    //Listner
    public void ImageAcquired(object sender, ImageAcquiredEventArgs e)
    {
    ...
    }

    public void startTickTack()
    {
    ...
    }

    private void setImageAquiredListener()
    {
        ...
    }

    private void readIniDatei()
    {
       ...
    }

    private void init()
    {
        ...
    }

    private System.Net.IPAddress getLocalIp()
    {
        ...
    }

    public IVisionSensor[] getVisionSensoren()
    {
        ...
    }

    public List<byte[]> getImages()
    {
        ...
    }

    public bool[] getAreConnected()
    {
       ...
    }
}
}

Its based on a Keyence.IV.Sdk.dll. I added this .dll as Assembly via Visual Studio. The compiler is friendly and shows no erros. (In a Windows-Applikation the code works fine.)

Now i want to make a Bridge with

JNI4Net (proxygen.exe -...\dll ....) enter image description here

Now i want to execute the build.cmd, but I'm getting this error:

Z:\bwulf\GeneratedSchnittstelle>build.cmd
compile classes
JavaKameraSchnittstelle.j4n.jar
JavaKameraSchnittstelle.j4n.dll clr\javakameraschnittstelle\KeyenceKameraSchnittstellen.generated.cs(58,165): error CS0400: Der Typ- oder Namespacename
        'Keyence' konnte im globalen Namespace nicht gefunden werden. (Fehlt ein Assemblyverweis?) clr\javakameraschnittstelle\KeyenceKameraSchnittstellen.generated.cs(79,85): error CS0400: Der Typ- oder Namespacename
        'Keyence' konnte im globalen Namespace nicht gefunden werden. (Fehlt ein Assemblyverweis?) clr\javakameraschnittstelle\KeyenceKameraSchnittstellen.generated.cs(79,125): error CS0400: Der Typ- oder Namespacename
        'Keyence' konnte im globalen Namespace nicht gefunden werden. (Fehlt ein Assemblyverweis?) clr\javakameraschnittstelle\KeyenceKameraSchnittstellen.generated.cs(79,13): error CS0012: Der Typ
        'Keyence.IV.Sdk.IVisionSensor' ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf        die Assembly 'Keyence.IV.Sdk, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' hinzu. z:\bwulf\KameraSchnittstelle\JavaKameraSchnittstelle.dll: (Position des Symbols für den vorherigen Fehler)

I'm not familiar with c#. I found something with Assembly.LoadFile()... but could not really do anything with it.

Where is the mistake and why i'm getting this error :

'Keyence' namespace not found.

Thank you for reading it.

4

1 回答 1

3

您应该添加 build.cmd 文件的内容。

假设你build.cmd相当于这个

Csc.exe /nologo /warn:0 /reference:....\lib\jni4net.n-0.8.9.0.dll /out:work/helloWorldFromCLR.exe /target:exe Program.cs

它看起来像是一种编译 C# 程序的方法。

错误 CS0400

在全局命名空间中找不到类型或命名空间名称“标识符”(您是否缺少程序集引用?)

本质上,您build.cmd没有找到其他程序集-Keyence.IV.Sdk.dll

您可以通过/reference:选项添加它,以便编译器Csc.exe可以找到程序集。编辑您的build.cmd文件并/reference:为您在 Visual Studio 项目参考中添加的其他程序集添加其他部分。

您可以在此处查看完整的编译器选项

于 2018-09-15T19:10:38.027 回答