Accessing a c#.net created COM object in vbscript...  
Author Message
NewSunRising





PostPosted: Tue Dec 09 10:21:06 CST 2003 Top

VB Scripts >> Accessing a c#.net created COM object in vbscript... Hey guys.

How do I access a COM object in vbscript?

I created the object using c#, but am unsure :
- which guid to use
- which object id
- whether i should use the <OBJECT> tag at all
- how to handle create object...

my structure for the COM object is as follows ( created following the
tutorial found at http://www.csharphelp.com/archives/archive281.html )

//----------------------------------------- start c# code

namespace BIF_COM_API
{
//
// Interface Declaration
//
[Guid("49B9D855-182A-4064-A362-95D7D10C4E15")]
public interface BIF_Interface
{
//
// DispId declarations
//
}

//
// Events Interface
//
[Guid("09603A1F-E672-4460-9F66-D012CE9F9842"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface BIF_Events
{
}

//
// COM object instantiation
//
[Guid("1995FED2-2C21-4659-A5E4-B832C0BD4434"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof( BIF_Events ))]
public class BIF_Instantiation : BIF_Interface
{
//
// class implementation
//
}
}
//----------------------------------------- end code

and my current vbscript code is

//----------------------------------------- vbscript code

<!-- header stuff -->

<SCRIPT LANGUAGE="VBScript">
<!--
option explicit

sub VB_Click

Dim bifapi

bifapi = CreateObject ( "BIF_Instantiation" )
' error here, can't create
object

bifapi.SetDestinationQueueName "Local_In"

bifapi.Send

end sub
-->
</SCRIPT>

</HEAD>
<OBJECT
classid="clsid:49B9D855-182A-4064-A362-95D7D10C4E15"
id=BIF_COM_API.BIF_Interface
VIEWASTEXT>
</OBJECT>

<BODY>
<!-- body stuff.... -->
//----------------------------------------- end code


thanks for your help in anticipation.
Daniel.

Visual Studio346  
 
 
Daniel





PostPosted: Tue Dec 09 10:21:06 CST 2003 Top

VB Scripts >> Accessing a c#.net created COM object in vbscript... after playing around, i got it to work...
- <OBJECT> is for active x, this is only COM, not active x.
- the correct solution follows:


<SCRIPT LANGUAGE="VBScript">

<!--
option explicit

sub VB_Click

Dim bifapi

set bifapi = CreateObject ( "BIF_COM_API.BIF_Instantiation" )

bifapi.SetDestinationQueueName "Local_In"

bifapi.Send

end sub
-->
</SCRIPT>