In VB.Net:
Namespace CryptoToolkit
Public NotInheritable Class Ticket
Inherits System.Object
Public Shared Function getUserId(ByVal ticket As String) As String
In VBScript:
dim obj
obj=Server.CreateObject("CryptoToolkit.Ticket")
dim userid
userid=obj.getUserId("sometext")
-> error: Object doesn't support this property or method - Microsoft
VBScript runtime error
There are a couple of other issues in special cases, but this is probably
the cause of your problem.
I'll probably get there eventually - going to the school of hard knocks for
.Net COM Interop with a weakly named assembly deployed to the directory of
the app. I'm fairly sure I'm headed in the right direction, though - just
need all my project settings and ComVisible attributes set up right. If all
else fails, I'll try strongly naming the class. But that's all a .Net
issue, not VbScript-related in any particular way...
"Alex K. Angelopoulos [MVP]" <aka-at-mvps-dot-org> wrote in message
news:eLf1yJLa...@TK2MSFTNGP12.phx.gbl...
I gave up on the "visible" attributes since it's so blinking hard to do
right all the time. And function overloading in C# is just not worth it
either...
Eventual success. There seems to be a lot which can go wrong, and I spent
more time looking at OLE Viewer and Regedit than I care to. The route which
eventually worked was:
Make a wrapper which exposes the static method as an instance method. In
the wrapper project, use an explicit interface for the wrapper class. Use
explicit GUIDs for the interface and class. Specify a class interface type
of None. Specify comVisible(True)] for members. Compile class to a DLL and
deploy to target machine. Run "REGASM x.DLL /TLB /CODEBASE". Then access
the class from .asp vbscript using conventional
myObj=Server.CreateObject("namespace.classname") techniques.
I never backtracked to see which steps were unnecessary.
Lessons learned:
Before updating the DLL, unregister the old one with "REGASM x.DLL /TLB
/CODEBASE /U" - the tlb and codebase options help regasm to remove more
registry associations. To be sure, Run OLE/COM Object Viewer and check "All
Objects" and "Type Libraries" to make sure you don't acquire lots of
duplicate type libraries - regasm seems to make duplicate typelibs without
end. Ignore the strong names warnings from regasm /codebase - these are
significant if the component will be shared by other apps, but I could not
make .asp pages find the object without this - apparently the "application
folder" is not particularly well defined in IIS/VBScript, or at least it is
not the location of the .asp page (not sure if I tried a /bin subfolder).
using System;
using System.Runtime.InteropServices;
namespace clientticketssowrapper
{
[Guid("1664245D-758F-319B-8D43-CE855A558102")]
[ComVisible(true)]
public interface TicketWrapperInterface {
string getUserId(string ticket);
}
//[System.Runtime.InteropServices.ComVisible(true)]
[Guid("1664245D-758F-319B-8D43-CE855A558103")]
[ClassInterface(ClassInterfaceType.None)]
public class TicketWrapper : TicketWrapperInterface {
public TicketWrapper() {
}
[ComVisible(true)]
public string getUserId(string ticket) {
return CryptoToolkit.Ticket.getUserId(ticket);
}
}
}
"Alex K. Angelopoulos [MVP]" <aka-at-mvps-dot-org> wrote in message
news:uD3q7YN...@tk2msftngp13.phx.gbl...