如何从c#调用dll文件 [英] How to call a dll file from c#

查看:294
本文介绍了如何从c#调用dll文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从c#调用一个dll文件



dll文件是由使用ikvm的java应用程序构成的,现在所有的代码都是打印你好世界



我如何在我的c#代码中调用dll文件,可以在java中创建一个将返回一个布尔值给我的c#代码的应用程序吗? p>

感谢您的时间。

解决方案

我不知道我明白你想做什么,如果我误读了,那么道歉。 IKVM应将您的java代码转换为.NET DLL或可执行文件。在翻译之后,您应该能够以与native.NET代码相同的方式或多或少地使用.dll。



如果您的java应用程序有一个在控制台上打印hello world的主要方法,您应该将其转换为.NET可执行文件(.exe),而不是转换为dll。
将其转换为.exe(并假设您在Windows系统上的Microsoft .NET上运行),您应该执行它。



As对于您的问题的第二部分,您还可以创建一个返回布尔值并从C#应用程序使用的dll(从java转换)。



请参阅本教程的两个例子(几乎完全相同)你正在做什么。


I am trying to call a dll file from c#

The dll file is made from a java application using ikvm and for now all the code does is print hello world.

How do i call the dll file in my c# code and is it possible to create an application in java that will return a boolean value to my c# code?

Thanks for your time.

解决方案

I'm not sure I understand what you're trying to do, so apologies if I'm misreading. IKVM should translate your java code to a .NET dll or executable. After the "translation" you should be able to use the .dll more or less in the same way as you would with a "native" .NET code.

If your java application has a main method that prints "hello world" on the console, you should have converted it to a .NET executable (.exe) and not to a dll. After converting it to a .exe (and assuming you're running it on Microsoft .NET on a windows system) you should just execute it.

As for the second part of your question, you can also create a dll (converted from java) that returns a boolean and consume it from a C# application.

See this tutorial for two examples of (pretty much exactly) what you're doing.

这篇关于如何从c#调用dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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