Calling a COM component via C#(ASP .net)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Badrinath Mohan

    Calling a COM component via C#(ASP .net)

    Hi All
    I am accessing a COM component using C#. When i access it through the
    standalone c# application it works fine.But when i call it using ASP .net
    application its not working .
    For example

    This is my COM function..
    Myfunction(int *PNINPUT ,int nsize,int *PNOUTPUT) is the com function in
    the DLL.


    I add the reference in my c# application

    I call it in the C# application as follows
    int [] pninput=new int[32];
    //fill values in pninput

    int [] pnoutput=new int[32];
    Myfunction(ref pnInput,32,ref pnoutput);

    I step into the dll and look at the function.
    If its a standalone c# application it works fine .
    with PNINPUT having all the values.

    But when the c# client is a ASP .net the PNINPUT has only the first value
    rest of the values are all junk. That is the input variable is not passed
    onto the function at all,....

    Could anyone please help me to solve this.

    thanks and expecting ur reply
    kandukondein


  • Alvin Bruney

    #2
    Re: Calling a COM component via C#(ASP .net)

    you will need to add the directive "aspcompat=true " to the page directive to
    force the component to use the single threaded apartment model.

    regards

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Badrinath Mohan" <bmohan@NOSPAMu ncc.edu> wrote in message
    news:Op13yQKqDH A.708@TK2MSFTNG P10.phx.gbl...[color=blue]
    > Hi All
    > I am accessing a COM component using C#. When i access it through the
    > standalone c# application it works fine.But when i call it using ASP .net
    > application its not working .
    > For example
    >
    > This is my COM function..
    > Myfunction(int *PNINPUT ,int nsize,int *PNOUTPUT) is the com function in
    > the DLL.
    >
    >
    > I add the reference in my c# application
    >
    > I call it in the C# application as follows
    > int [] pninput=new int[32];
    > //fill values in pninput
    >
    > int [] pnoutput=new int[32];
    > Myfunction(ref pnInput,32,ref pnoutput);
    >
    > I step into the dll and look at the function.
    > If its a standalone c# application it works fine .
    > with PNINPUT having all the values.
    >
    > But when the c# client is a ASP .net the PNINPUT has only the first value
    > rest of the values are all junk. That is the input variable is not passed
    > onto the function at all,....
    >
    > Could anyone please help me to solve this.
    >
    > thanks and expecting ur reply
    > kandukondein
    >
    >[/color]


    Comment

    • Badrinath Mohan

      #3
      Re: Calling a COM component via C#(ASP .net)

      Unfortunately i was calling it from a web service and aspcompat was not
      recognized there..
      Fortunately
      But ur idea helped me to study more on that and I got this idea of approach


      Thread newThread =
      new Thread(new ThreadStart(Thr eadMethod));
      newThread.Apart mentState = ApartmentState. STA;
      newThread.Start ();
      and in my Thread method i did the functionality of calling the COM
      component.

      It works like a charm...


      thanks...
      Badri




      "Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
      message news:O6xF$nLqDH A.1408@TK2MSFTN GP11.phx.gbl...[color=blue]
      > you will need to add the directive "aspcompat=true " to the page directive[/color]
      to[color=blue]
      > force the component to use the single threaded apartment model.
      >
      > regards
      >
      > --
      >
      >
      > -----------
      > Got TidBits?
      > Get it here: www.networkip.net/tidbits
      > "Badrinath Mohan" <bmohan@NOSPAMu ncc.edu> wrote in message
      > news:Op13yQKqDH A.708@TK2MSFTNG P10.phx.gbl...[color=green]
      > > Hi All
      > > I am accessing a COM component using C#. When i access it through the
      > > standalone c# application it works fine.But when i call it using ASP[/color][/color]
      ..net[color=blue][color=green]
      > > application its not working .
      > > For example
      > >
      > > This is my COM function..
      > > Myfunction(int *PNINPUT ,int nsize,int *PNOUTPUT) is the com function[/color][/color]
      in[color=blue][color=green]
      > > the DLL.
      > >
      > >
      > > I add the reference in my c# application
      > >
      > > I call it in the C# application as follows
      > > int [] pninput=new int[32];
      > > //fill values in pninput
      > >
      > > int [] pnoutput=new int[32];
      > > Myfunction(ref pnInput,32,ref pnoutput);
      > >
      > > I step into the dll and look at the function.
      > > If its a standalone c# application it works fine .
      > > with PNINPUT having all the values.
      > >
      > > But when the c# client is a ASP .net the PNINPUT has only the first[/color][/color]
      value[color=blue][color=green]
      > > rest of the values are all junk. That is the input variable is not[/color][/color]
      passed[color=blue][color=green]
      > > onto the function at all,....
      > >
      > > Could anyone please help me to solve this.
      > >
      > > thanks and expecting ur reply
      > > kandukondein
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...