This question already has answers here:
Is there any way to compile Java code into a DLL?
(3 answers)
Closed 9 years ago.
I need to use Java code in .NET (C#) and am looking for a way to convert a Java class to a DLL file (which I can then reference in my .NET app). Is this a valid scenario? If yes, How can I do it?
You can use IKVM.NET to use Java classes and libraries from .NET.
Basically that is not a good idea. Since java emphasizes on platform independence, but dll is platform dependent. So, think about pack into a jar file, execute and consume it somehow
May be this link will be useful for you:
http://www.codeproject.com/Articles/13549/Using-Java-Classes-in-your-NET-Application
For this you can use IKVM.NET.
Related
This question already has answers here:
CLR and CLI - What is the difference?
(7 answers)
Closed 5 years ago.
What exactly is Common Language Runtime in Dot Net. Is it an exe or dll. Can I see common language runtime in task manager. Where is it located.
You should first look up in google before posting here.. But here it goes:
What is it?
The .NET Framework provides a run-time environment called the common language runtime, which runs the code and provides services that make the development process easier.
Where is it located?.
C:\Windows\Microsoft.NET\Framework\v2.0.50727
Of course the last part depends on your version.
This question already has answers here:
C# library to native C++ application
(3 answers)
Closed 3 years ago.
What is the best solution to access c# code via native code (C++)?
I have C# code which I want to call from native project, so I'm considering writing a COM wrapper but I wonder whether there is a better option (framework/design pattern/architecture etc.) available in .NET?
COM interop is without a doubt the best bet. It's a known, supported framework for achieving exactly what you want to achieve.
There is another alternative however - it is possible to edit the IL code inside a compiled .NET assembly to flag methods within the assembly as native exports. A detailed breakdown of the changes can be found in this CodeProject article.
Robert Giesecke has created Unmanaged Exports to simplify this process using simple method attributes. A NuGet package can be found here.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Interoperating between Matlab and C#
I need to use some functionality from a Dot Net C# managed-dll How can I call this Dot Net C# dll in matlab ?
One way to make this work is to use COM. You can implement a COM object using .NET, and MatLab can work with COM objects (e.g. see http://www.mathworks.co.uk/help/matlab/matlab_external/exploring-your-object.html).
If your managed C# DLL is not yet exposed to COM, you may have to write a little wrapper (depending on whether or not you have access to the source code).
You could use Matlab's system command and this approach:
Need to run a c# dll from the command line
This question already has answers here:
Is is possible to export functions from a C# DLL like in VS C++?
(4 answers)
Closed 6 years ago.
I have a .net assembly written in C#, and I'm looking to export a native C function from the assembly.
I have an application which will perform a 'LoadLibrary()' on any DLL's found in a 'plugin' folder. After loading the DLL, the application performs a 'GetProcAddress' looking for a function named 'Register'. The application expects this function to follow the C calling convention.
How can I export a function named 'Register' from my .net assembly, so I can successfully hookup with the plugin system for this application?
Thanks,
Andrew
Have a look at Unmanaged Exports.
Write a .Net library in Managed C++ and there you can export a "Native" method/function.
Sadly Microsoft does not support this feature, and you have to change the msil after the build to expose those methods.
It is possible as one guy has shown a reasonable solution
on codeproject or here,
but it requires a post build step and you are on your own after that.
I don't know if this hack will work on .net 4.0 or later though.
Hopefully Microsoft will listen to us and support this simple feature in C# since the CLR support is already there.
What you want is a Reverse P/Invoke. You can't actually embed a C function in a C# dll, if by that you mean a function actually implemented in C, but by following the tutorials given on the linked page you can create a DLL export that's callable by unmanaged C/C++ code.
This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
Tool to convert java to c# code
I have done a project in java and I want to convert it to C#.Net. I'm using Visual Studio 2008. How can I convert the code from Java to C#? Are there any tools available?
There are tools that can help do this. For example this one from the team who created db4o:
Smart java to c# conversion for the masses with sharpen
Note that these are not perfect and some constructs and API's cannot be easily translated.
IKVM.NET Bytecode Compiler
Here is an Msdn Article about converting from Java to Visual C#.
I think your best shot would be, unless you really really need all the code in C#, to use Visual J# and integrate your Java code with C#.
Microsoft used to support their own .net implementation of the Java language, called Java#, but unfortunetelly they discontinued the project.
But at least you could try it to see if it could help you to convert your code to .net