Monday, 26 August 2013

Create DLL file using C# to use in java

Create DLL file using C# to use in java

Hey guys I'm java developer however I need to work around c#. In my
company we are facing some issues in java so we decided to call dll
function through java. I wrote .cs file as follow
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Com
{
[ClassInterface(ClassInterfaceType.AutoDual),
Guid("F2F37A34-A440-4e82-A941-996056AADD88")]
public class Calculation
{
[DebuggerNonUserCode]
public Calculation()
{
}
public int sum(int x, int y)
{
return checked(x + y);
}
public int subtract(int x, int y)
{
return checked(x - y);
}
public int multi(int x, int y)
{
return checked(x * y);
}
public double Div(int x, int y)
{
if (y != 0)
{
return (double)x / (double)y;
}
return 0.0;
}
}
}
To create DLL File I'm using csc.exe /t:library /out:D:/test.dll
To Register DLL File I'm using RegAsm /verbose /nologo /codebase D:\test.dll
To Unregister DLL File I'm using RegAsm.exe /unregister D:\test.dll
I'm able to call this DLL in java program using jacob library. My problem
is when I'm trying to call same dll using Applet it throws exception.
So to call DLL over network/browser do I have to follow other things?
OR
Is there any other way to create DLL file or say parameter I've to set to
use it over network/browser...

No comments:

Post a Comment