Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to Call C#.net Dll in Java Script ???

Hi All Pals,
I m only 2 days older in javascript. Really frm 2 days i m seeking for :
How to Call C#.net Dll in Java Script ???
I need to call one method frm Class called Class1 and method call Fun() wich return one integer say 100.This val i need to catch in javascript variable just like

var val=Class1.Fun();
alert(val);

but i cud not do so.Pls help me

Help wud be appreciated

Regards
Chintan
«1

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hi All Pals,
    : I m only 2 days older in javascript. Really frm 2 days i m seeking for :
    : How to Call C#.net Dll in Java Script ???
    : I need to call one method frm Class called Class1 and method call Fun() wich return one integer say 100.This val i need to catch in javascript variable just like
    :
    : var val=Class1.Fun();
    : alert(val);
    :
    : but i cud not do so.Pls help me
    :
    : Help wud be appreciated
    :
    : Regards
    : Chintan
    :
    That's only possible if the dll is a registered COM server. For more info see this thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=18052 and msdn.microsoft.com
  • chintan.desaichintan.desai Posts: 17Member
    : : Hi All Pals,
    : : I m only 2 days older in javascript. Really frm 2 days i m seeking for :
    : : How to Call C#.net Dll in Java Script ???
    : : I need to call one method frm Class called Class1 and method call Fun() wich return one integer say 100.This val i need to catch in javascript variable just like
    : :
    : : var val=Class1.Fun();
    : : alert(val);
    : :
    : : but i cud not do so.Pls help me
    : :
    : : Help wud be appreciated
    : :
    : : Regards
    : : Chintan
    : :
    : That's only possible if the dll is a registered COM server. For more info see this thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=18052 and msdn.microsoft.com
    :
    -------------------------------------------------------------
    Reply :

    thank u friend.
    It is working.But Can i call .net dll in javascript or vbscript.My project been cease due to this problem.Is ther no other solution Pls reply soon.thx again.
  • zibadianzibadian Posts: 6,349Member
    : : : Hi All Pals,
    : : : I m only 2 days older in javascript. Really frm 2 days i m seeking for :
    : : : How to Call C#.net Dll in Java Script ???
    : : : I need to call one method frm Class called Class1 and method call Fun() wich return one integer say 100.This val i need to catch in javascript variable just like
    : : :
    : : : var val=Class1.Fun();
    : : : alert(val);
    : : :
    : : : but i cud not do so.Pls help me
    : : :
    : : : Help wud be appreciated
    : : :
    : : : Regards
    : : : Chintan
    : : :
    : : That's only possible if the dll is a registered COM server. For more info see this thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=18052 and msdn.microsoft.com
    : :
    : -------------------------------------------------------------
    : Reply :
    :
    : thank u friend.
    : It is working.But Can i call .net dll in javascript or vbscript.My project been cease due to this problem.Is ther no other solution Pls reply soon.thx again.
    :
    No, since as said it in the other forum, that would be a huge security hole. It would even be possible to run [b]any and all[/b] programs on someone else's computer [b]without[/b] his knowledge.
  • chintan.desaichintan.desai Posts: 17Member
    [b][red]This message was edited by chintan.desai at 2007-2-7 21:32:21[/red][/b][hr]
    [b][red]This message was edited by chintan.desai at 2007-2-7 21:27:9[/red][/b][hr]
    : : : : Hi All Pals,
    : : : : I m only 2 days older in javascript. Really frm 2 days i m seeking for :
    : : : : How to Call C#.net Dll in Java Script ???
    : : : : I need to call one method frm Class called Class1 and method call Fun() wich return one integer say 100.This val i need to catch in javascript variable just like
    : : : :
    : : : : var val=Class1.Fun();
    : : : : alert(val);
    : : : :
    : : : : but i cud not do so.Pls help me
    : : : :
    : : : : Help wud be appreciated
    : : : :
    : : : : Regards
    : : : : Chintan
    : : : :
    : : : That's only possible if the dll is a registered COM server. For more info see this thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=18052 and msdn.microsoft.com
    : : :
    : : -------------------------------------------------------------
    : : Reply :
    : :
    : : thank u friend.
    : : It is working.But Can i call .net dll in javascript or vbscript.My project been cease due to this problem.Is ther no other solution Pls reply soon.thx again.
    : :
    : No, since as said it in the other forum, that would be a huge security hole. It would even be possible to run [b]any and all[/b] programs on someone else's computer [b]without[/b] his knowledge.
    :
    ----------------------------------------------------
    Reply:
    Ok,thaxs for all replies.
    Ok then can u tell me How to make .net dll as COM assembly?
    I have done the following steps in .net visual studio 2005 IDE to register my .net dll as COM.
    1)Project->Project property>build>and checking "Register for com interop" box
    2)even use regasm and regsvr32 and tried to register.but cud not register

    my idea is to make this com register and by using javascript i can call this com assembly.Again i can call javascript file in my flash.

    pls reply if u know .net
    but thax again
  • zibadianzibadian Posts: 6,349Member
    : [b][red]This message was edited by chintan.desai at 2007-2-7 21:32:21[/red][/b][hr]
    : [b][red]This message was edited by chintan.desai at 2007-2-7 21:27:9[/red][/b][hr]
    : : : : : Hi All Pals,
    : : : : : I m only 2 days older in javascript. Really frm 2 days i m seeking for :
    : : : : : How to Call C#.net Dll in Java Script ???
    : : : : : I need to call one method frm Class called Class1 and method call Fun() wich return one integer say 100.This val i need to catch in javascript variable just like
    : : : : :
    : : : : : var val=Class1.Fun();
    : : : : : alert(val);
    : : : : :
    : : : : : but i cud not do so.Pls help me
    : : : : :
    : : : : : Help wud be appreciated
    : : : : :
    : : : : : Regards
    : : : : : Chintan
    : : : : :
    : : : : That's only possible if the dll is a registered COM server. For more info see this thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=18052 and msdn.microsoft.com
    : : : :
    : : : -------------------------------------------------------------
    : : : Reply :
    : : :
    : : : thank u friend.
    : : : It is working.But Can i call .net dll in javascript or vbscript.My project been cease due to this problem.Is ther no other solution Pls reply soon.thx again.
    : : :
    : : No, since as said it in the other forum, that would be a huge security hole. It would even be possible to run [b]any and all[/b] programs on someone else's computer [b]without[/b] his knowledge.
    : :
    : ----------------------------------------------------
    : Reply:
    : Ok,thaxs for all replies.
    : Ok then can u tell me How to make .net dll as COM assembly?
    : I have done the following steps in .net visual studio 2005 IDE to register my .net dll as COM.
    : 1)Project->Project property>build>and checking "Register for com interop" box
    : 2)even use regasm and regsvr32 and tried to register.but cud not register
    :
    : my idea is to make this com register and by using javascript i can call this com assembly.Again i can call javascript file in my flash.
    :
    : pls reply if u know .net
    : but thax again
    :
    Have you defined and implemented the interfaces correctly? I know very little about COM or .NET, but I do know that it often requires a rewrite of the type definitions to add the COM-interfaces instead of the exported functions. Perhaps people in the C#-board can help you better.
  • chintan.desaichintan.desai Posts: 17Member
    No probs.I got the solution.
  • hendyhanusinhendyhanusin Posts: 6Member
    Dear friend,

    i encounter same problem.
    so i have created a .NET DLL Class Library.
    But i don't know how to call and use this DLL method, event in JavaScript ?
    Could you help ?

    2.
    other solution is we have to re-build the DLL using VB 6.0 , but it's funny since we're already using VB .NET.

    Tks,
    hendy
    ---------my source code in windows application----------------

    .........
    Private _AddListHandler As ACR120DLL.ACR120DLL.AddListHandler
    Private WithEvents _ACR As ACR120DLL.ACR120DLL


    _ACR = New ACR120DLL.ACR120DLL
    _ACR.TotalBlocks = 44 'TOTAL BLOCK-1
    AddHandler _ACR.AddList, AddressOf AddList
    AddHandler _ACR.SelectList, AddressOf SelectList
    _ACR.Connect()

    Timer1 = New System.Timers.Timer
    AddHandler Timer1.Elapsed, AddressOf TriggerReadData
    Timer1.Interval = 1000
    Timer1.AutoReset = True
    Timer1.Start()

    ...........

    Private Sub AddList(ByVal Msg As String)
    If Msg.EndsWith("-3030") Then
    MessageBox.Show("Ada kesalahan ! Mohon diulangi proses pembacaan kartu !")
    Return
    End If
    List1.Items.Add(Msg)

    End Sub

    Private Sub SelectList()
    List1.SelectedIndex = List1.Items.Count - 1
    End Sub

    Private Sub TriggerReadData(ByVal o As Object, ByVal e As System.Timers.ElapsedEventArgs)

    End Sub





  • Luna7Luna7 Posts: 1Member
    : No probs.I got the solution.
    :
    Hi,

    I have exactly the same problem.

    I wrote a Com Assembly with C#, registered it with regasm and pushed it into the gac with gacutil successful.
    So far so good.

    Now I have to use it in Javascript
    I tried it like this:
    function lib ()
    {
    alert("here i am");
    try
    {
    var test = MyLib.Class1.info(); //Namespace.Class.Function
    alert ("Test: "+test);
    }
    catch (e)
    {
    alert("exc "+e.message);
    }

    }
    e. message is: MyLib is undefined
    What did I wrong?
    Can you help me please? Or show me your solution?
    thx!
  • danish_ssuetdanish_ssuet Posts: 2Member
    : Dear friend,
    :
    : i encounter same problem.
    : so i have created a .NET DLL Class Library.
    : But i don't know how to call and use this DLL method, event in
    : JavaScript ?
    : Could you help ?
    :
    : 2.
    : other solution is we have to re-build the DLL using VB 6.0 , but
    : it's funny since we're already using VB .NET.
    :
    : Tks,
    : hendy
    : ---------my source code in windows application----------------
    :
    : .........
    : Private _AddListHandler As ACR120DLL.ACR120DLL.AddListHandler
    : Private WithEvents _ACR As ACR120DLL.ACR120DLL
    :
    :
    : _ACR = New ACR120DLL.ACR120DLL
    : _ACR.TotalBlocks = 44 'TOTAL BLOCK-1
    : AddHandler _ACR.AddList, AddressOf AddList
    : AddHandler _ACR.SelectList, AddressOf SelectList
    : _ACR.Connect()
    :
    : Timer1 = New System.Timers.Timer
    : AddHandler Timer1.Elapsed, AddressOf TriggerReadData
    : Timer1.Interval = 1000
    : Timer1.AutoReset = True
    : Timer1.Start()
    :
    : ...........
    :
    : Private Sub AddList(ByVal Msg As String)
    : If Msg.EndsWith("-3030") Then
    : MessageBox.Show("Ada kesalahan ! Mohon diulangi proses
    : pembacaan kartu !")
    : Return
    : End If
    : List1.Items.Add(Msg)
    :
    : End Sub
    :
    : Private Sub SelectList()
    : List1.SelectedIndex = List1.Items.Count - 1
    : End Sub
    :
    : Private Sub TriggerReadData(ByVal o As Object, ByVal e As
    : System.Timers.ElapsedEventArgs)
    :
    : End Sub
    :
    :
    :
    :
    :
    : name : danish
    email : danish85_dj@hotmail.com
    Friend, i have a great solution of this problem, use AJAX.NET library, don't worry, this library is very simple to use, this library has the ability to use ServerSide functions (C#,VB.NET) function using JAVASCRIPT.
    download this library and enjoy it, i hope this will be very useful to u.




  • am_poam_po Posts: 14Member
    Hi.

    Does it work for you (using C# dll by javascript)?
    Still fighting with this...

    Thanks.
«1
Sign In or Register to comment.