COM Interop is causing a horrible CLR crash

A

andrew lowe

Hi there,

We have to use a com interop library generated by tlbimp, where the orginal
com object is written in uniface (a compuware language). The method we use
and have the problem with has the following signature:

[PreserveSig, DispId(1002)]
int exec(
[In, MarshalAs(UnmanagedType.BStr)] string servicetorun,
[In, MarshalAs(UnmanagedType.BStr)] string inparameters,
[MarshalAs(UnmanagedType.BStr)] out string outparameters);

As you can see we have an output parameter that returns a string. Everything
works great when the output string is <= 700k. However once it becomes
around 800k & greater, we get a horrible error that cannot be caught. Here's
the code that produces the error:

using System;
namespace MarshallingTest {
public class Class1 {
[STAThread]
public static void Main(string[] args) {
ePathway.Request.Broker.esyv0005Class service = null;
try {
Console.WriteLine("Before create esyv0005");
service = new ePathway.Request.Broker.esyv0005Class();
Console.WriteLine("esyv0005 created");
string xml;
service.exec("esyv0095", "", out xml);
Console.WriteLine(xml);
} catch (Exception e) {
Console.WriteLine(e.ToString());
} finally {
if (service != null)

System.Runtime.InteropServices.Marshal.ReleaseComObject(service);
Console.WriteLine("Press a key to continue");
Console.ReadLine();
}
}
}
}

The error is:
MarshallingTest.exe - Common Language Runtime Debuggin services
Application has generated an error that can't be handled
Process Id=0x6f8(1784), Thread Id=0xc24(3108)


Any ideas on what might be going on here ?

tia
andrew
 
S

Simon Smith

Hi there,

We have to use a com interop library generated by tlbimp, where the orginal
com object is written in uniface (a compuware language). The method we use
and have the problem with has the following signature:

[PreserveSig, DispId(1002)]
int exec(
[In, MarshalAs(UnmanagedType.BStr)] string servicetorun,
[In, MarshalAs(UnmanagedType.BStr)] string inparameters,
[MarshalAs(UnmanagedType.BStr)] out string outparameters);

As you can see we have an output parameter that returns a string. Everything
works great when the output string is <= 700k. However once it becomes
around 800k & greater, we get a horrible error that cannot be caught. Here's
the code that produces the error:
<snip>

Have you tried using a StringBuilder as the out param rather than a string?
I recall seeing some stuff about doing that somewhere.....
 
S

Scott Allen

Hi there,

We have to use a com interop library generated by tlbimp, where the orginal
com object is written in uniface (a compuware language). The method we use
and have the problem with has the following signature:

[PreserveSig, DispId(1002)]
int exec(
[In, MarshalAs(UnmanagedType.BStr)] string servicetorun,
[In, MarshalAs(UnmanagedType.BStr)] string inparameters,
[MarshalAs(UnmanagedType.BStr)] out string outparameters);

As you can see we have an output parameter that returns a string. Everything
works great when the output string is <= 700k. However once it becomes
around 800k & greater, we get a horrible error that cannot be caught. Here's
the code that produces the error:

Hi andrew:

You might try this tool to see if it gives you any useful information:
CLRSPY -
http://www.gotdotnet.com/Community/...mpleGuid=c7b955c7-231a-406c-9fa5-ad09ef3bb37f

HTH,
 

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

Similar Threads


Top