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

Discussion in 'ASP .Net Security' started by Badrinath Mohan, Nov 11, 2003.

  1. 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
     
    Badrinath Mohan, Nov 11, 2003
    #1
    1. Advertising

  2. Badrinath Mohan

    Alvin Bruney Guest

    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" <> wrote in message
    news:...
    > 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, Nov 12, 2003
    #2
    1. Advertising

  3. 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(ThreadMethod));
    newThread.ApartmentState = 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$...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >

    >
    >
     
    Badrinath Mohan, Nov 12, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Soni
    Replies:
    0
    Views:
    1,103
  2. Badrinath Mohan

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

    Badrinath Mohan, Nov 11, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,477
    Badrinath Mohan
    Nov 12, 2003
  3. Jim Hammond
    Replies:
    1
    Views:
    763
    Jim Hammond
    Nov 12, 2003
  4. Badrinath Mohan

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

    Badrinath Mohan, Nov 11, 2003, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    150
    Badrinath Mohan
    Nov 12, 2003
  5. Replies:
    1
    Views:
    188
Loading...

Share This Page