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

M

Michael

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
 
B

BruceJohnson

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
 
M

Michael

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
 
D

Dave Purrington

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top