没有功能在C#DLL与RGiesecke.DllExport [英] No functions in C# DLL with RGiesecke.DllExport

查看:1880
本文介绍了没有功能在C#DLL与RGiesecke.DllExport的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在C#中使用一些其他语言的DLL。我发现了RGiesecke的DllExport,但似乎没有起作用。它建立得很好,并且建立一个dll,但是当我在Dependency Walker中打开它时,它不显示任何功能,我的调用代码也找不到它们。

I am trying to make a DLL in C# for use in a couple other languages. I found RGiesecke's DllExport but it doesn't seem to work. It builds just fine and makes a dll, but when I open it in Dependency Walker it doesn't show any functions, and my calling code can't find them either.

我创建了一个新的类库项目(VS 2013),然后从NuGet安装了Unmanaged Exports(DllExport for .Net)。是否有任何需要的项目设置?

I created a new "Class Library" project (VS 2013) and then installed "Unmanaged Exports (DllExport for .Net)" from NuGet. Are there any project settings I need?

这是我的代码。

using System;
using System.Collections.Generic;
using System.Text;
using RGiesecke.DllExport;

namespace ToolServiceDLL
{
    public class Class1
    {
      [DllExport("addUp", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
      public static double addUp(double num1, double num2)
      {
        return num1 + num2;
      }

      [DllExport("get5", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
      public static int get5()
      {
        return 5;
      }
    }
}


推荐答案

我发现问题。它在RGiesecke文档中有,但我错过了。在项目设置 - >构建 - >平台目标:您不能将其设置为任何CPU。您必须将其设置为x64或x86,具体取决于是否要在64位或32位应用程序中使用它。

I found the problem. It has it in the RGiesecke Documentation, but I missed it. In the project settings->Build->Platform target: you can not have it set to "Any CPU". You must have it set to x64 or x86 depending on if you want to use it in a a 64 or 32 bit application.

这篇关于没有功能在C#DLL与RGiesecke.DllExport的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆