Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / September 2003

Tip: Looking for answers? Try searching our database.

Customizing a Runtime Callable Wrapper

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ruxo Zheng - 19 Sep 2003 09:19 GMT
I've tried to customize the Execute method of ADO Command from its
generated DLL (by Tlbimp.exe).  The original code of the Execute method
is:

   .method public hidebysig newslot virtual
           instance class msado27.Recordset
           marshal( interface)
           Execute([out][opt] object&  marshal( struct) RecordsAffected,
                   [in][opt] object& Parameters,
                   [in][opt] int32 Options) runtime managed internalcall
   {
     .custom instance void [mscorlib]
System.Runtime.InteropServices.DispIdAttribute::.ctor(int32) = ( 01 00 05
00 00 00 00 00 )
     .param [3] = int32(0xFFFFFFFF)
     .override msado27._Command::Execute
   } // end of method CommandClass::Execute

I want to change the second argument to be int32 type without
referencing. 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."

What I have to do more to make it work?  Can I create an another overload
method instead?

Thanks ...
Ruxo
Mattias Sj?gren - 19 Sep 2003 10:08 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.