Passing of managed code objects to COM

Last post 05-07-2009 8:00 AM by offseri. 2 replies.

Sort Posts:

  • Passing of managed code objects to COM

    05-06-2009, 6:19 PM
    • Member
      6 point Member
    • offseri
    • Member since 06-06-2007, 9:51 AM
    • Posts 20

    Hi all, 

     I am migrating an ASP application to Asp.net and have run into a problem with an object parameter. Interestingly enough the old ASP application passes the Response object to a custom VB 6.0 class and then calls the Response.Write method to output some dynamic content inside the COM dll. Is it possible to keep that methodology in the new ASP.NET application - I tried to pass the Response object (HttpContext.Current.Response) to the COM class as-is without any attributes for marshalling etc. and my website currently errors out when the COM class executes the Response.Write method.

    The error that I am getting is: Object Required, when i debugged the COM dll the variable that is assigned to the Response object is not showing as empty but the Watch window was displaying it as having no children.The variable in the COM dll that is assigned to the Response object parameter coming from VB.NET is of type Variant.

     To make it clearer here is some sample code: 

     ASP.NET

    Dim obj as Object = CreateObject("progIDofVB6.0class") ' Late Binding (tried early binding as well but got the same error)

    obj.Output = HttpContext.Response

    obj.PerformSomething

    .....

     

    VB 6.0 class 

    Public Property Set Output(ByVal obj As Variant)
        mvarClientScripter = obj
    End Property

    Sub PerformSometing

      ....

      Output.Write <string> ' Output here should be the Response object that was assigned above

      ....

    End Sub

     

    Any input is appreciated!

    Thanks

  • Re: Passing of managed code objects to COM

    05-07-2009, 12:42 AM
    • All-Star
      27,663 point All-Star
    • qwe123kids
    • Member since 03-27-2008, 9:49 AM
    • Mumbai
    • Posts 4,679

     Hi,

    There are ways To create com...In csharp
    //Check the Link below..
    http://comindotnet.blogspot.com/

    if U are using VB6.0 .. then Add The DLL In rfernce Then TRy..

    http://www.4guysfromrolla.com/webtech/112101-1.shtml

    Or..

    Ucan also Use Classic Asp Way Acess COM..

    Register YOUR DLL using Regsvr32
    Restart IIS
    In page Directives Use Aspcompant ="true"

    The Ucan Access tyhe COM Object as U Acess in Class Asp




    Hope it  helps

    Thanks
    Avinash Tiwari

    Remember to click “Mark as Answer” on the post, if it helps you.

    MY Blog

    Hacking Inside .net exe
  • Re: Passing of managed code objects to COM

    05-07-2009, 8:00 AM
    • Member
      6 point Member
    • offseri
    • Member since 06-06-2007, 9:51 AM
    • Posts 20

     Hi,

    Are you saying that if I register the COM dll in my ASP.NET application and use early binding instead of the CreateObject method then I should be able to pass the Response object as a parameter and call its Write method from the COM dll? I already went down that path and received the same error (Object required) but if it is possible maybe i need to add something else as well to tell the wrapper how to marshal the Response object. All in all I am trying to understand how is it possible for the COM dll to use an object such as the Response object which is native to the .NET runtime?

     Please let me know if I need to post more code but when I used the early binding I just replaced the CreateObject line in my original post with the actual COM type name which was available in the intellisense.

    Thanks!

Page 1 of 1 (3 items)