Late Binding .....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hakan ÖRNEK

    #1

    Late Binding .....

    Hi,

    Can I Late binding to object in .NET ( not COM objects, Objects was created
    vb.net Dll ) !!!
    <<< CreateObject("M yDLLName.dll"," MyClassName") or
    CreateActiveX(" MyDLLName.dll", "MyClassNam e") >>>
    When I running this codes I have a error "ActiveX can not create" !

    Thanks for help...
    Hakan Örnek






  • Armin Zingler

    #2
    Re: Late Binding .....

    "Hakan ÖRNEK" <ornekh@gmail.c omschrieb
    Hi,
    >
    Can I Late binding to object in .NET ( not COM objects, Objects was
    created vb.net Dll ) !!!
    <<< CreateObject("M yDLLName.dll"," MyClassName") or
    CreateActiveX(" MyDLLName.dll", "MyClassNam e") >>>
    When I running this codes I have a error "ActiveX can not create" !

    http://msdn2.microsoft.com/en-us/library/k3a58006.aspx


    Armin

    Comment

    • Hakan ÖRNEK

      #3
      Re: Late Binding .....

      Armin,
      Thanks for your link, but for custom binding methods required add referance
      from dll.
      <Imports Simple_Type.Sim ple_Type>
      I dont want to add referance from created object dll.
      Can I use Createobject() method like a vbscript codes;

      dim o as object
      SET o=CreateObject( "MyDll.dll","My Class")
      call o.TestMethod()

      Thank for your helps...

      Hakan





      "Armin Zingler" <az.nospam@free net.dewrote in message
      news:OjK%23I76P HHA.3344@TK2MSF TNGP02.phx.gbl. ..
      "Hakan ÖRNEK" <ornekh@gmail.c omschrieb
      Hi,

      Can I Late binding to object in .NET ( not COM objects, Objects was
      created vb.net Dll ) !!!
      <<< CreateObject("M yDLLName.dll"," MyClassName") or
      CreateActiveX(" MyDLLName.dll", "MyClassNam e") >>>
      When I running this codes I have a error "ActiveX can not create" !
      >
      >
      http://msdn2.microsoft.com/en-us/library/k3a58006.aspx
      >
      >
      Armin
      >

      Comment

      • Armin Zingler

        #4
        Re: Late Binding .....

        "Hakan ÖRNEK" <ornekh@gmail.c omschrieb
        Armin,
        Thanks for your link, but for custom binding methods required add
        referance from dll.
        <Imports Simple_Type.Sim ple_Type>
        I dont want to add referance from created object dll.
        Can I use Createobject() method like a vbscript codes;
        >
        dim o as object
        SET o=CreateObject( "MyDll.dll","My Class")
        call o.TestMethod()
        >
        Thank for your helps...

        Maybe I didn't understand you correctly. You wrote a VB.Net dll. It is not a
        COM dll. In a client application, you want to create objects from classes in
        the dll, right? Using the methods described in the topics from the link, you
        are able to do it without using "Imports" or Createobject. Much can be said
        about it but I only mention System.Reflecti on.Assembly.Loa d and
        System.Type.Inv okeMember.


        Armin

        Comment

        • Branco Medeiros

          #5
          Re: Late Binding .....

          Hakan ÖRNEK wrote:
          Armin,
          Thanks for your link, but for custom binding methods required add referance
          from dll.
          <Imports Simple_Type.Sim ple_Type>
          I dont want to add referance from created object dll.
          Can I use Createobject() method like a vbscript codes;
          >
          dim o as object
          SET o=CreateObject( "MyDll.dll","My Class")
          call o.TestMethod()
          <snip>

          The CreateObject() function works only with COM libraries. Therefore,
          it seems you'd need to have your original .Net MyDll.dll registered in
          the COM framework, first.

          You need to mark the relevant class (in your case, "MyClass", although
          this is a reserved name, I suppose you only used it as an example), I
          was saying, you need to mark the relevant class as both "COM class" and
          "COM visible" -- select the class in the project/solution explorer and
          these options will become available.

          Then you need to enable the "Make Assembly COM visible flag": open the
          project properties and click the "Assembly Information..." button in
          the Applcation tab.

          Finaly, after the dll is compiled, you must register it in the COM
          framework. To this, use the regasm application (I guess you can
          download it with the .Net SDK):

          regasm /codebase "your dll path"

          Finally, inside your client application you'd use (notice that I don't
          have VB.Classic installed here, so I can't confirm the syntax):
          dim o as object
          Set o=CreateObject( "MyDll.dll.MyCl ass")
          call o.TestMethod()
          HTH.

          Regards,

          Branco.

          Comment

          • =?iso-8859-1?Q?Hakan_=D6RNEK?=

            #6
            Re: Late Binding .....

            Hi,
            Actualy I want to write vb script in my code, for example;
            '----------------------------------
            Public Class TestClass
            Public Sub HelloWorld()
            MsgBox("Hello World")
            End Sub
            End Class
            '----------------------------------
            Compile this code and create Test.Dll
            And then, create New Application Test.exe and not to add referance Test.Dll.
            '----------------------------------
            Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
            Dim oTest As Object
            oTest = CreateObject("T est.TestClass")
            oTest.HelloWorl d()
            End Sub
            '----------------------------------

            In VB6 Test.dll compiled automaticly register and Latebind in Dll name (Test.dll) and public class (TestClass), but I think so VB.NET dll not registered in registery so how can I do this case, I want to run my code like script.

            Thanks for helps again,

            Hakan




            "Armin Zingler" <az.nospam@free net.dewrote in message news:%23wurcTJQ HHA.4492@TK2MSF TNGP02.phx.gbl. ..
            "Hakan ÖRNEK" <ornekh@gmail.c omschrieb
            Armin,
            Thanks for your link, but for custom binding methods required add
            referance from dll.
            <Imports Simple_Type.Sim ple_Type>
            I dont want to add referance from created object dll.
            Can I use Createobject() method like a vbscript codes;

            dim o as object
            SET o=CreateObject( "MyDll.dll","My Class")
            call o.TestMethod()

            Thank for your helps...

            Maybe I didn't understand you correctly. You wrote a VB.Net dll. It is not a
            COM dll. In a client application, you want to create objects from classes in
            the dll, right? Using the methods described in the topics from the link, you
            are able to do it without using "Imports" or Createobject. Much can be said
            about it but I only mention System.Reflecti on.Assembly.Loa d and
            System.Type.Inv okeMember.


            Armin
            >

            Comment

            • Hakan ÖRNEK

              #7
              Re: Late Binding .....

              Hi Branco,
              Thanks for advices, It worked... :)))
              Only "assembly a strong name" and cliend dll was same directory required.
              Thanks for all helps.....
              Best regards,

              Hakan




              "Branco Medeiros" <branco.medeiro s@gmail.comwrot e in message
              news:1169740519 .486543.144130@ k78g2000cwa.goo glegroups.com.. .
              Hakan ÖRNEK wrote:
              Armin,
              Thanks for your link, but for custom binding methods required add
              referance
              from dll.
              <Imports Simple_Type.Sim ple_Type>
              I dont want to add referance from created object dll.
              Can I use Createobject() method like a vbscript codes;
              >
              dim o as object
              SET o=CreateObject( "MyDll.dll","My Class")
              call o.TestMethod()
              <snip>

              The CreateObject() function works only with COM libraries. Therefore,
              it seems you'd need to have your original .Net MyDll.dll registered in
              the COM framework, first.

              You need to mark the relevant class (in your case, "MyClass", although
              this is a reserved name, I suppose you only used it as an example), I
              was saying, you need to mark the relevant class as both "COM class" and
              "COM visible" -- select the class in the project/solution explorer and
              these options will become available.

              Then you need to enable the "Make Assembly COM visible flag": open the
              project properties and click the "Assembly Information..." button in
              the Applcation tab.

              Finaly, after the dll is compiled, you must register it in the COM
              framework. To this, use the regasm application (I guess you can
              download it with the .Net SDK):

              regasm /codebase "your dll path"

              Finally, inside your client application you'd use (notice that I don't
              have VB.Classic installed here, so I can't confirm the syntax):
              dim o as object
              Set o=CreateObject( "MyDll.dll.MyCl ass")
              call o.TestMethod()
              HTH.

              Regards,

              Branco.


              Comment

              • Armin Zingler

                #8
                Re: Late Binding .....

                "Hakan ÖRNEK" <ornekh@gmail.c omschrieb
                Hi,
                Actualy I want to write vb script in my code, for example;
                '----------------------------------
                Public Class TestClass
                Public Sub HelloWorld()
                MsgBox("Hello World")
                End Sub
                End Class
                '----------------------------------
                Compile this code and create Test.Dll
                And then, create New Application Test.exe and not to add referance
                Test.Dll.
                '----------------------------------
                Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                System.EventArg s) Handles Button1.Click
                Dim oTest As Object
                oTest = CreateObject("T est.TestClass")
                oTest.HelloWorl d()
                End Sub
                '----------------------------------
                >
                In VB6 Test.dll compiled automaticly register and Latebind in Dll
                name (Test.dll) and public class (TestClass), but I think so VB.NET
                dll not registered in registery so how can I do this case, I want
                to run my code like script.
                >
                Thanks for helps again,
                >
                Hakan
                There is nothing more I can add to what I've already said, sorry. The topics
                in the documentation desribe in detail how to do it.


                Armin

                Comment

                Working...