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 be great! Here
    are the details:

    I create a Windows based .NET application that made 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. 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 int
    _message "Object reference not set to an instance of an
    object." string
    _xcode -1073741819 int
    _xptrs 11989016 int
    HResult -2147467261 int
     
    Michael, Dec 18, 2003
    #1
    1. Advertising

  2. Michael

    BruceJohnson Guest

    I've run into similar problems in the past. It is usually caused by the
    fact that ASP.NET can't find the DLL in which the COM object is
    implemented. Even if the file is in the bin directory. In order to be
    found, the DLL file needs to be in the PATH for the ASP.NET user. To
    test this out, try moving the DLL to a directory like System32 and see
    if your problem goes away. The following link goes into more details.

    http://objectsharp.com/blogs/bruce/posts/191.aspx

    HTH

    Bruce Johnson
    http://www.ObjectSharp.com/Bruce

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    BruceJohnson, Dec 19, 2003
    #2
    1. Advertising

  3. Michael

    Michael Guest

    Thanks for responding Bruce,

    I tried your suggestion and it did not seem to make a difference. I
    also tried running the dcomcnfg utility and added every
    applicable/possible user to all security aspects of the com object,
    restarted the machine and still no luck. 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


    BruceJohnson <> wrote in message news:<#>...
    > I've run into similar problems in the past. It is usually caused by the
    > fact that ASP.NET can't find the DLL in which the COM object is
    > implemented. Even if the file is in the bin directory. In order to be
    > found, the DLL file needs to be in the PATH for the ASP.NET user. To
    > test this out, try moving the DLL to a directory like System32 and see
    > if your problem goes away. The following link goes into more details.
    >
    > http://objectsharp.com/blogs/bruce/posts/191.aspx
    >
    > HTH
    >
    > Bruce Johnson
    > http://www.ObjectSharp.com/Bruce
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    >
    > --
     
    Michael, Dec 19, 2003
    #3
  4. Okay, here's something else to try. Change the processModel element in your
    machine.config file so that IIS (aspnet_wp.exe) starts under a different
    user than ASPNET. You'll have to reboot for it to take effect. If this
    works, at least you know that it's an ASPNET user issue. It's probably some
    permission thing.

    FYI -- when you call COM from .NET, it runs in a different process in the
    security context of the same owner as that of aspnet_wp.exe.



    "Michael" <> wrote in message
    news:...
    > Thanks for responding Bruce,
    >
    > I tried your suggestion and it did not seem to make a difference. I
    > also tried running the dcomcnfg utility and added every
    > applicable/possible user to all security aspects of the com object,
    > restarted the machine and still no luck. 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
    >
    >
    > BruceJohnson <> wrote in message

    news:<#>...
    > > I've run into similar problems in the past. It is usually caused by the
    > > fact that ASP.NET can't find the DLL in which the COM object is
    > > implemented. Even if the file is in the bin directory. In order to be
    > > found, the DLL file needs to be in the PATH for the ASP.NET user. To
    > > test this out, try moving the DLL to a directory like System32 and see
    > > if your problem goes away. The following link goes into more details.
    > >
    > > http://objectsharp.com/blogs/bruce/posts/191.aspx
    > >
    > > HTH
    > >
    > > Bruce Johnson
    > > http://www.ObjectSharp.com/Bruce
    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***
    > > Don't just participate in USENET...get rewarded for it!
    > >
    > > --
     
    Dave Purrington, Dec 23, 2003
    #4
    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:
    940
    Laurent Bugnion
    Jan 26, 2006
  2. batista
    Replies:
    0
    Views:
    575
    batista
    Jan 26, 2006
  3. Paul Hadfield
    Replies:
    0
    Views:
    363
    Paul Hadfield
    Sep 17, 2007
  4. Michael
    Replies:
    2
    Views:
    192
    Michael
    Dec 19, 2003
  5. batista
    Replies:
    0
    Views:
    262
    batista
    Jan 26, 2006
Loading...

Share This Page