Ruxo,
>I want to change the second argument to be int32 type without
>referencing.
Why? I wouldn't expect that to work.
> But just changing the type only causes the exception:
>
>"Could not load type msado27.CommandClass from assembly msado27, Version=
>2.7.0.0, Culture=neutral, PublicKeyToken=null."
If you catch that exception and look for an inner exception, it might
tell you more about why it fails.
You have to make sure you have matching declarations of the method in
both in the _Command interface and in the CommandClass class.
>Can I create an another overload method instead?
No
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Ruxo Zheng - 22 Sep 2003 03:20 GMT
Thanks Mattias for your clarification.
My original intention is to make the Execute method of ADO Command to
take no arguments. So I can migrate my VB6 code into .NET without
problems. (Or at least, I can really pass NULL value -- zero -- for the
second argument.)
But since .NET doesn't support [Optional] attribute. So I though about
two solutions. That's either changing the argument or overloading with a
new Execute method.
If both solutions can't work anyway, what to do if we find another legacy
COMs that use similar optional arguments? Is this a limit of .NET interop
for COM components?
Ruxo
> Ruxo,
>
>>I want to change the second argument to be int32 type without
>>referencing.
>
> Why? I wouldn't expect that to work.
<<-- old message is snipped -->>
> Mattias
Mattias Sj?gren - 22 Sep 2003 20:57 GMT
>But since .NET doesn't support [Optional] attribute.
VB.NET has full support for optional parameters.
In other languages such as C# you at least have the ability to make a
COM imported VARIANT parameter look unspecified to the callee, like
this
http://www.dotnetinterop.com/faq/?q=MissingOptional
>So I though about
>two solutions. That's either changing the argument or overloading with a
>new Execute method.
Neither will work, sorry.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Ruxo Zheng - 23 Sep 2003 02:50 GMT
Thanks Mattias, this's greatly help! :D
Rux
>>But since .NET doesn't support [Optional] attribute.
>
[quoted text clipped - 7 lines]
>
> Mattias