quick question on overloading methods

  • Thread starter Thread starter barb
  • Start date Start date
B

barb

I'm developing an assembly that will be used from ASP (not ASP.NET). Can I
overload methods? My initial tests suggest that I can't.

Thanks,
Barb
 
Hello Barb,

Thanks for your post. I am not quite sure what exactly you want to do.
According to my understanding, do you want to know how to access .NET
component from ASP? If so, you will need COM Interop to access .NET
component from unmanaged client. I believe the following MSDN articles are
helpful:

Exposing .NET Framework Components to COM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconexposingnetframeworkcomponentstocom.asp?frame=true

COM Interop Part 2: C# Server Tutorial
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/
vcwlkcominteroppart2cservertutorial.asp

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 
Thanks. Here's a little more information:

I am writing a .NET component that is to be used from ASP. It seems to be
working fine in general, using the regasm utility to create a type library
and putting the assemby in the GAC. The only problems I'm having is when I
call a public method that has an overload -- then, when tested from ASP, I
get the error "Invalid Procedure Call or Argument". If I remove the
overload, it works fine from ASP. I wasn't certain whether ASP can deal
with overloaded methods or not, but my first test indicates that maybe it
can't?

Thanks,
Barb
 
Hello Barb,

Thanks for your update. I now share the following information with you:

Based on my experience and research, the TlbExp.exe may desingate a unique
name for each overloaded method. For example, I declare the following
interface in C#:

public interface IMyInterface
{
int Method(string strVal);
int Method(int iVal);
}

If I use OLE View to view the .TLB file generated by TlbExp.exe, the
Method(int) will be changed to Method_2.
interface IMyInterface: IDispatch {
[id(0x60020000)]
HRESULT Method(
[in] BSTR strVal,
[out, retval] long* pRetVal);
[id(0x60020001),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, Method)]
HRESULT Method_2(
[in] long iVal,
[out, retval] long* pRetVal);
};

So I recommend you use OLE View to check the new name for the overloaded
methods and the call them from ASP page.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 
Back
Top