Calling a Java function from C#.Net - c#

I just want to call a java function from ASP.Net... Please guide me !!!
I have seen JNBridge but its not free... :(
Thanks in anticipation

Possible options that i can think of :-
Expose the java function's functionality through a service (Recommended - Loosely Coupled)
Integrate through backend eg: database. Both programs can access a common database and pass data through here. (Not Highly Recommented - Very Tightly Coupled)
Use an open source bridge eg : jni4net
Note: I have not used this bridge ever but it seems to be something similar to what you are looking for. Refer their sample here

Not sure if it's exactly what you are looking for, but you could check out IKVM.NET.

and why you wanna do that?
1- It will slow your code also as Plateform Conversion came into picture
2- It will make your code hard to test.
3- It will make your code hard to understand.
There must be very solid reason because what ever you can do with Java , you can do in C#
if possible you can always COPY & PASTE same function in ASP.Net application

Related

How can we integrate our C# code in Drupal CMS

We have C# code, which is backend for us. Now we need it to be used in our website which is developed in Drupal.
As far as I know, there is no easy way to do it. You basically have 2 options:
Rewrite the code in php. It may be not possible to do it however, it depends on what the code does.
Expose c# code as an external webservice (e.g. with WCF) and then consume the webservice. Drupal is able to do it - more info.
A sloppy solution would also be to display your C# page in the Drupal page with an iframe. I do also agree with empi's answer to rewrite the code in php or a web service depending on your requirement.
You can build DLL project (class library) in C# and use the DLL as reference back in the drupal project.
Not sure about this, and never done before.
You better research more.
But, the best way to use the .NET code in another application is to build the required code into DLL project and use in whichever language you want to use.

Ruby libary to DLL file for use it with C# asp.net

i want to use this Ruby code https://github.com/weppos/freeagent
and convert it to Dll file or to any thing that allow my to use it in C#
any one can help me to convert it to Dll or EXE
Thanks in Advance
Not sure that this is a good idea - but if you really need to use this Ruby code from .NET then check these out:
http://www.codeproject.com/KB/cs/IronRuby_cSharp.aspx
Call Ruby or Python API in C# .NET
http://www.sapphiresteel.com/Blog/From-C-to-Ruby-and-back-again-The
http://www.igvita.com/2007/04/23/invoking-ruby-in-c-net/
these describe possible ways to achieve what you ask...
But since the API is REST-/XML-based I would recommend implementing it in C# - this way you have all options regarding updates/modifications etc. and I would definitely suspect even better performance...

Using a data access DLL with HTML forms

I've agreed to help out a friend with getting their website off the ground. Previously, someone else helped out by writing a data access layer dll in C#, which I luckily have access to the code. Not any means to change and recompile though, as C# has never been one of my primary languages.
Problem is, I have no idea how I'm supposed to call it. In HTML, I tried out
<form action='dll/MyLib.dll' method='GET'>'
But I've no understanding how to call a specific function out of the DLL nor how to pass parameters. I'm not even sure if I managed to load it. For example, if I have an HTML form to add a new user to a MySQL database, I want to call the DLL's connection and addUser functions.
I found a 2005 article on DLLs and HTML, but trying out their code doesn't seem to work in actual practice:
http://msdn.microsoft.com/en-us/library/3s0d4hwc%28v=vs.80%29.aspx
Anyone with any experience in this? I'm tempted to rewrite the DLL in a PHP script...
I think you're doing it wrong. While there "may" be a way to do what you're saying, there are much MUCH better/easier ways to go about this, one of which is using an IDE that understands .NET and can work with your C# code. I would recommend getting Visual Studio 2010 or WebMatrix if you can't afford VS2010 and learning how ASP.NET works.
It may take longer in the short run than whatever hacks people may or may not suggest here, but it will be a huge payoff in the long run, and who knows, maybe you'll really like programming in it :)
Do not call dll from html, please.
If you already have C#-related project, try ASP .NET.

Possible to work with Isolated Storage from Javascript?

I'm needing to delete a value in Isolated storage from javascript code.
If this is possible how is it done? I found some code from a post written in 2007 and Silverlight has changed a lot since then.
The best way would be to call a Silverlight method from JavaScript. This link provides examples on how to handle this:
http://weblogs.asp.net/mschwarz/archive/2007/06/01/call-scribtable-methods-from-javascript-with-silverlight.aspx
Expatiating Keith Adler's answer a bit...
IsolatedStorage can only be accessed by managed code, which is a term Microsoft uses to refer to code in one of the .NET languages. Fortunately, Javascript can be used to communicate with managed code, and vice-versa. As shown in the article you linked, this is done through a Silverlight object.
Microsoft has a set of very detailed walk-through articles on this very topic. But perhaps you and others would prefer (or perhaps more appropriately, would have preferred) an existing solution over rolling out your own.
If that's the case, check out BakedGoods. Its a Javascript library that establishes a uniform interface that can be used to conduct common storage operations in all native, and some non-native storage facilities, including IsolatedStorage.
With it, you can accomplish what you want by using something like the following code snippet:
bakedGoods.remove({
data: ["targetItemKey"],
storageTypes: ["silverlight"],
complete: function(byStorageTypeRemovedItemKeysObj, byStorageTypeErrorObj){/*code*/}
});
Oh, and for the sake of complete transparency, BakedGoods is maintained by none other than yours truly :) .

Is it possible to embeded js into c#

Currently I'm involved in a project using c# . I know some of the features of this project can be easily implemented using Javascript (I have been a js developer for some time, but totally new to c#). so I'm very eager to know if it is possible to reuse the available js code in the project, or put it another way, embeded js into c# .
thanks in advance.
I think you're asking if it is possible to run JavaScript on the CLR. Similar to Java 6's JVM script engine.
EcmaScript.net could be your best bet - http://code.google.com/p/ecmascript-net/ - see also this question - Are there any .NET CLR/DLR implementations of ECMAScript?
There is an extensive article written on how to embed Javascript within C# here. Is that what you are looking for?
Are you referring to ClientScriptManager RegisterClientScriptBlock Method
There is no reason you cant continue to use existing client side javascript code.
There is a still a clear distinction to whats required on the client and what can be called by the client.
Various possibilities include: calling web services, making ajax calls to WebMethods and injecting javascript code into pages.
The way you write it it sounds like a giant cop-out of learning C# properly. Unless you actually mean that you want to use JavaScript for client-side control of your project, this is a no-go (and it doesn’t sounds like you meant client-side scripting).
That said, .NET actually allows you to mix assemblies from different languages effortlessly, but this only applies to .NET languages which can be compiled to .NET IL (bytecode) and I’m not aware of a JS-to-IL-compiler.
Javascript runs in the browser, as long as it is a web project there is no problblem combining. C# code will run on the server, javascript code in the browser.
http://msdn.microsoft.com/en-us/library/aa479011.aspx

Categories