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 / Interop / August 2003

Tip: Looking for answers? Try searching our database.

Re: ASP 3.0 + ServicedComponent COM method parameter type mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bogdan CIRLIG - 21 Aug 2003 14:25 GMT
Hi all,

Interesting thing happening with ASP 3.0. We are in process of migrating our
old ASP 3.0 to ASPX and one of the stages is to replace the middle tier
components.

Now, I have created a simple COM from .Net by implementing the
ServicedComponent. I defined a class inside to be used a input parameters in
a function, let's say:

public class Login
{
   public String Username;
   public String Password;
}

Now, I have these public methods:

public Login getLogin();
public void setLogin(Login);

When registering the COM with Component Services everything is ok. When
attempting to use the object from ASP 3.0 the things get messy. The object
creation is successful. I create another object of type Login and assign the
properties to it and then I tried to pass it to setLogin method. I receive a
Type mismatch error from VBScript engine. If I call the getLogin() method,
ASP 3.0 is able to use the returned Login object w/o problems.

If I modify the setLogin() function to accept an Object instead of Login,
ASP 3.0 is able to send the variable but on the COM side I run into another
issue as my Object is System.__comObject type. I've tried to cast this
object to my Login class w/o success?

Question: Am I doing something wrong, is there another solution or it's a
known issue?

HTH,
Bogdan
Ying-Shen Yu[MSFT] - 22 Aug 2003 04:46 GMT
Hi Bogdan,
    I'm afraid you shouldn't return and pass the Login class type in VB
Script Engine, you may refer to the following link,
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/mts/mtxpg04_34yv.htm
I think marshal it to variant type first. may work around this problem.
let me know if  you still have problems on this issue, thanks!

Kind regards,

Ying-Shen Yu [MSFT]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2001 Microsoft Corporation. All rights
reserved.
--------------------
| From: "Bogdan CIRLIG" <bcirlig@travtech.com>
| Subject: Re: ASP 3.0 + ServicedComponent COM method parameter type
mismatch
| Date: Thu, 21 Aug 2003 09:25:48 -0400
| Lines: 40
[quoted text clipped - 47 lines]
| HTH,
| Bogdan
Bogdan CIRLIG - 22 Aug 2003 14:23 GMT
Thanks for your reply.

I found an interesting solution: I created a generic function called
createObject(String typeName) which uses Activator to create the type sent
through typeName.
 public Object createType(String typeName)
 {
  return Activator.CreateInstance(Type.GetType(typeName));
 }

I assign the return of the function to my VBScript variable, let's say set
myVar = createObject("Login")

If I pass this variable back to my ServicedComponent everything works fine.
I don't get the idea? After all, it seems a type mismatch but it looks more
like a bug?!
What I can see is that if my Login type gets exported through registering
the ServicedComponent when I create an instance of it from VBScript it is
NOT the same type as the method signature as seen by VBScript.

VERY interesting to find out why?

HTH,
Bogdan

> Hi Bogdan,
>      I'm afraid you shouldn't return and pass the Login class type in VB
[quoted text clipped - 71 lines]
> | HTH,
> | Bogdan

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.