ASP.NET and COM interop/security issue.. ('NullReferenceException')

S

Subrata

hi All,
I'm trying to call a COM component written in PowerBuilder from an
ASP.NET application. The first method call into the COM component (developed
using PB) is failing with 'Object reference not set to an instnace of an
object' error.
Observations:
1. I can call the same PB COM component from a .NET Windows application
successfully.
2. I can call another COM component (developed using ATL COM, MSVC 6.0)
from the ASP.NET application.
3. I'm using exact same code in the .NET Windows app and in the ASP.NET
app.

Versions:
IIS 6.0, MS Visual Studio 2003 (with .NET Framework 1.1)

Here's the code snippet:
.................
// COClass_n_genappClass is a COM component developed using PowerBuilder
// This code works fine if called in a .NET Windows application
// but thorws an exception when called in a ASP.NET application.
private void Button1_Click(object sender, System.EventArgs e)
{
COClass_n_genappClass obj1 = new COClass_n_genappClass();
short n1 = short.Parse(TextBox1.Text);
short n2 = short.Parse(TextBox2.Text);
short n3 = obj1.add(n1,n2); // This line throws 'NullReferenceException'
in ASP.NET
TextBox3.Text = n3.ToString();
}

// CppCOMObj1Class is a COM component developed using C++/ATL/MSVC6.0
// This code works fine in both ASP.NET and in .NET Windows Application
private void Button2_Click(object sender, System.EventArgs e)
{
CppCOMObj1Class obj1 = new CppCOMObj1Class();
TextBox3.Text =
obj1.TestAdd(short.Parse(TextBox1.Text),short.Parse(TextBox2.Text)).ToString();
}

I tied the following:
1. Assuming this to be some error related to permission/file access, I
ran NTFileMonitor (sysinternals.com) to make sure that all the files/dlls
can be accessed and loaded.
2. Under the same assumption, I upgraded the Anonymous user a/c
(IUSR_<machine name>) and the ASPNET account to be a part of the
'Administrators' group in the development machine. This is just for
troubleshooting purpose, the accouts needs to me restricted once I figure
out the interop problem.
3. I changed the impersonate setting in machine.config from
<identity impersonate="false" userName="" password=""/>
to
<identity impersonate="true"/>
and,
from comImpersonationLevel="Impersonate" to
comImpersonationLevel="Anonymous"

Could you please help me troubleshooting this issue.
Thanks in advance for all your support.
 
P

Peter Huang [MSFT]

Hi Subrata,

I have replied to you in the COM Interop newsgroup.
You may go and take a look.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top