By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

out object parameter

P: n/a
I have a COM server that's generally working ok. But one of its methods,
when the IDL gets read by the Intertop layer, has parameters of type "out
object".

The C# compiler tells me that it can't convert from object to out object, or
from int* to out object, or from object[] to out object. In fact, I can't
find anything at all that it will accept as a parameter on the call.

I don't think this is a COM issue, because if I wrote my own C# method with
an "out object" parameter I'd have the same problem.

So what does it want to have passed in?

Mike Carroll
Sigma Data Systems
Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Could you provide a snippet of code you use in the C# client?

José
"Mike Carroll" <mc******@gosigma.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a COM server that's generally working ok. But one of its methods,
when the IDL gets read by the Intertop layer, has parameters of type "out
object".

The C# compiler tells me that it can't convert from object to out object, or from int* to out object, or from object[] to out object. In fact, I can't
find anything at all that it will accept as a parameter on the call.

I don't think this is a COM issue, because if I wrote my own C# method with an "out object" parameter I'd have the same problem.

So what does it want to have passed in?

Mike Carroll
Sigma Data Systems

Nov 15 '05 #2

P: n/a
C# client code, attempting to call methods on DisplayableFieldsLister COM
object:

unsafe private void buttonListMasters_Click(object sender, System.EventArgs
e)
{
AmsDataModule.DisplayableFieldsLister lister = new
DisplayableFieldsLister();
lister.ShowMessage("Hi there!"); // testing COM client; this works

int* tableNames;
object actualFieldNames;
object[] siteFieldNames;
void* fieldDataTypes;
lister.GetDisplayableFields("ListMasters", true, true, true,
tableNames, actualFieldNames, siteFieldNames, fieldDataTypes);
}

Compiler messages:
[C# Error] JobPostingsEditorForm.cs(1032): Argument '5': cannot convert from
'int*' to 'out object'
[C# Error] JobPostingsEditorForm.cs(1032): Argument '6': cannot convert from
'object' to 'out object'
[C# Error] JobPostingsEditorForm.cs(1032): Argument '7': cannot convert from
'object[]' to 'out object'
[C# Error] JobPostingsEditorForm.cs(1032): Argument '8': cannot convert from
'void*' to 'out object'

Preceded by the message:
[C# Error] JobPostingsEditorForm.cs(1031): The best overloaded method match
for 'AmsDataModule.IDisplayableFieldsLister.GetDisplay ableFields(string,
bool, bool, bool, out object, out object, out object, out object)' has some
invalid arguments
Nov 15 '05 #3

P: n/a
Mike,
So what does it want to have passed in?


If you have a method such as

void Foo(out object o)

you call it with

object x;
Foo( out x );

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #4

P: n/a
Ok, so "out" is supposed to be sprinkled in among the parameters being
passed. Don't think I've seen that in any other language.

object tableNames;
object actualFieldNames;
object siteFieldNames;
object fieldDataTypes;
lister.GetDisplayableFields("ListMasters", true, true, true,
out tableNames, out actualFieldNames, out siteFieldNames, out
fieldDataTypes);
Nov 15 '05 #5

P: n/a
Mike Carroll <mc******@gosigma.com> wrote:
Ok, so "out" is supposed to be sprinkled in among the parameters being
passed. Don't think I've seen that in any other language.


That doesn't mean it's a bad thing - on the contrary, it's been added
to make the language clearer. In C#, it's always obvious if you're
passing something as a "ref" or "out" parameter, because it's in the
calling code as well as the method declaration. This is a very good
thing for readability, IMO.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.