all groups > vj# > december 2003 >
You're in the

vj#

group:

Problem with byref parameter in COM object in J#


Problem with byref parameter in COM object in J# Vincent ROBERT
12/23/2003 1:58:15 AM
vj#:
First, excuse my english ...

So , i've a problem:

My company have developped a dll using J++. Before we use=20
the JVM with NT4. But we are moving to Windows 2003 and=20
there is not the JVM. So i've recompiled the dll with J#.=20
All is good, the dll is ok and fully fonctionnaly for 99%=20
of functions.

But we'have one function that wait for a byref parameter:
public int Scan (String Source, String Dep,String=20
Arrivee,Ctab result) =20

result -> type: Ctab (class in our project)

When we use it in ASP or vbscript, we have the error:=20
Erreur d'ex=E9cution Microsoft VBScript: Cet objet ne g=E8re=20
pas cette propri=E9t=E9 ou cette m=E9thode: 'Obj_CString.Scan'

But when we use it in VB6, if we cast the variable :
dim myvar as object, we don't have error.

I've seen on your site an help page:=20
http://support.microsoft.com/default.aspx?scid=3Dkb;en-
us;325742

But I don't understand what I must do ???

RE: Problem with byref parameter in COM object in J# mikegreonline NO[at]SPAM microsoft.com
12/23/2003 7:07:24 PM
Hello Vincent,

Let me just say your English is much better than my French!
Which parameter(s) in

public int Scan (String Source, String Dep,String Arrivee,Ctab result)

Are byref? In managed code Strings are immutable (they cannot change), have
you tried using StringBuilder instead of String? There is no byref keyword
in J#, but you can pass an array instead. For example if you needed to pass
an int as byref you could pass an int[] instead.

I hope this helps,

Mike Green
Microsoft Developer Support

RE: Problem with byref parameter in COM object in J# Vincent Robert
12/24/2003 6:59:02 AM
Hi Mike !

First, tanks a lot for your answer!

The parameter with byref is result. It's a structure like
this:
public class Ctab
{
protected String tabValeurs[];
protected int nb_elem;
private int MaxElem=50;
private int Ajout=550; // Nombre d'element ajouter si
le tableau est plein


public Ctab()
{
nb_elem=0;
tabValeurs=new String[MaxElem];
}
... ... ...
}


At the moment, i've always the problem. So i've tried to
migrate my j++ project to C# using jlca. All is good, my
project is migrated.

And I've always the same problem.

I've found a help page who talking of my problem:
http://support.microsoft.com/default.aspx?scid=kb;EN-
US;197957

When passing a parameter to a COM Component's method in
Active Server Pages (ASP) using VBScript, either the
following error occurs:


Microsoft VBScript runtime error '800a000d' Type mismatch

Or the value stored in the variable passed to the method
is not changed.

I don't what I must do.



[quoted text, click to view]
RE: Problem with byref parameter in COM object in J# mikegreonline NO[at]SPAM microsoft.com
12/29/2003 11:38:18 PM
Hi Vincent,

The article you mentioned is very confusing. I've read it over a few times
to make sure I understand what it is saying. Here is what I believe it's
trying to say:

When you call a COM object's method from VBScript all parameters not
defined as Variant * will be passed by value. In other words if you need to
pass a parameter by reference you need to define that parameter as a
Variant *.

What language is this method defined in? Is this method part of a COM
object?

Thanks,

Michael Green
Microsoft Developer Support



AddThis Social Bookmark Button