Problem calling a COM object within my webservice - please help....

Discussion in 'ASP .Net Web Services' started by Michael, Dec 18, 2003.

  1. Michael

    Michael Guest

    Hi,

    If anyone can help me identify the problem here I would appreciate it!
    Here
    are the details:

    I created a Windows based .NET application that has a reference to a
    COM object. The COM object was instainted successfully and all the
    calls to this COM object worked fine.

    I moved the classes that referenced the COM object into a WebService
    and made a reference to the COM object, esstially the exact same code.
    When the WebService instanitates the COM object within a try block it
    seems ok but as soon as I attempt to call a method on the COM object
    it raises an
    NullReferenceException. Here are some of the details in the exception:

    _COMPlusExceptionCode -532459699
    _HResult -2147467261
    _message "Object reference not set to an instance of an object."
    _xcode -1073741819
    _xptrs 11989016
    HResult -2147467261

    Here are things that I have tried:
    - using the tlbimp utility to create a .NET assembly and referencing
    the wrapper assembly
    - I gave administrator privelegdes to the aspnet_wp user
    - removed the IIS anynonyous flag and connect with web.config set to
    impersonate
    - added the following line before the COM is created:
    Thread.CurrentThread.ApartmentState = ApartmentState.STA;
    - moved and reregistered the COM's dll in the same bin directory as
    the webservice itself.

    Thanks in advance for your help.
    Mike
     
    Michael, Dec 18, 2003
    #1
    1. Advertising

  2. The error you have seems to indicate that you didn't instantiate your COM
    object yet.

    Do you have something like this for your object?

    oMyObject = new MyComObject.ClassName

    Can you post some code so we can see what's going on in that code?

    Michael

    "Michael" <> wrote in message
    news:...
    > Hi,
    >
    > If anyone can help me identify the problem here I would appreciate it!
    > Here
    > are the details:
    >
    > I created a Windows based .NET application that has a reference to a
    > COM object. The COM object was instainted successfully and all the
    > calls to this COM object worked fine.
    >
    > I moved the classes that referenced the COM object into a WebService
    > and made a reference to the COM object, esstially the exact same code.
    > When the WebService instanitates the COM object within a try block it
    > seems ok but as soon as I attempt to call a method on the COM object
    > it raises an
    > NullReferenceException. Here are some of the details in the exception:
    >
    > _COMPlusExceptionCode -532459699
    > _HResult -2147467261
    > _message "Object reference not set to an instance of an object."
    > _xcode -1073741819
    > _xptrs 11989016
    > HResult -2147467261
    >
    > Here are things that I have tried:
    > - using the tlbimp utility to create a .NET assembly and referencing
    > the wrapper assembly
    > - I gave administrator privelegdes to the aspnet_wp user
    > - removed the IIS anynonyous flag and connect with web.config set to
    > impersonate
    > - added the following line before the COM is created:
    > Thread.CurrentThread.ApartmentState = ApartmentState.STA;
    > - moved and reregistered the COM's dll in the same bin directory as
    > the webservice itself.
    >
    > Thanks in advance for your help.
    > Mike



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.552 / Virus Database: 344 - Release Date: 12/15/2003
     
    Michael Pearson, Dec 19, 2003
    #2
    1. Advertising

  3. Michael

    Michael Guest

    Thanks for responding Michael,

    Here is the code snippet that I am using to instaintate the com
    object:

    try
    {
    Thread.CurrentThread.ApartmentState = ApartmentState.STA;
    pbcodeinterfaceClass pbInterfaceCOM = new pbcodeinterfaceClass();
    String directoryData;
    String lib = "somevalue";
    directoryData = pbInterfaceCOM.of_exportlibrarydirectory(lib,(Int16)1);
    if (directoryData != String.Empty)
    {
    ...more code
    catch (Exception ex)
    {
    ex = ex;
    return null;
    }

    The code only blow's up when I call a method
    (of_ExportLibraryDirectory) of my COM object (pbInterfaceCOM). Again,
    this code works perfect when run within a windows application.

    Thanks!
    Mike




    "Michael Pearson" <> wrote in message news:<>...
    > The error you have seems to indicate that you didn't instantiate your COM
    > object yet.
    >
    > Do you have something like this for your object?
    >
    > oMyObject = new MyComObject.ClassName
    >
    > Can you post some code so we can see what's going on in that code?
    >
    > Michael
    >
    > "Michael" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > If anyone can help me identify the problem here I would appreciate it!
    > > Here
    > > are the details:
    > >
    > > I created a Windows based .NET application that has a reference to a
    > > COM object. The COM object was instainted successfully and all the
    > > calls to this COM object worked fine.
    > >
    > > I moved the classes that referenced the COM object into a WebService
    > > and made a reference to the COM object, esstially the exact same code.
    > > When the WebService instanitates the COM object within a try block it
    > > seems ok but as soon as I attempt to call a method on the COM object
    > > it raises an
    > > NullReferenceException. Here are some of the details in the exception:
    > >
    > > _COMPlusExceptionCode -532459699
    > > _HResult -2147467261
    > > _message "Object reference not set to an instance of an object."
    > > _xcode -1073741819
    > > _xptrs 11989016
    > > HResult -2147467261
    > >
    > > Here are things that I have tried:
    > > - using the tlbimp utility to create a .NET assembly and referencing
    > > the wrapper assembly
    > > - I gave administrator privelegdes to the aspnet_wp user
    > > - removed the IIS anynonyous flag and connect with web.config set to
    > > impersonate
    > > - added the following line before the COM is created:
    > > Thread.CurrentThread.ApartmentState = ApartmentState.STA;
    > > - moved and reregistered the COM's dll in the same bin directory as
    > > the webservice itself.
    > >
    > > Thanks in advance for your help.
    > > Mike

    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.552 / Virus Database: 344 - Release Date: 12/15/2003
     
    Michael, Dec 19, 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. batista
    Replies:
    1
    Views:
    926
    Laurent Bugnion
    Jan 26, 2006
  2. batista
    Replies:
    0
    Views:
    568
    batista
    Jan 26, 2006
  3. Paul Hadfield
    Replies:
    0
    Views:
    361
    Paul Hadfield
    Sep 17, 2007
  4. Michael
    Replies:
    3
    Views:
    167
    Dave Purrington
    Dec 23, 2003
  5. batista
    Replies:
    0
    Views:
    258
    batista
    Jan 26, 2006
Loading...

Share This Page