Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, February 19, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix .NET Extensions
Forum to discuss the use of .NET Extensions in SalesLogix version 7 and higher. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix .NET Extensions | New ThreadView:  Search:  
 Author  Thread: COM Visible SalesLogix .NET Extension with VB.NET
Colin Maitland
Posts: 5
 
COM Visible SalesLogix .NET Extension with VB.NETYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 08 1:44 PM
How do I make a SalesLogix aware .NET assembly that has public properties and methods that can be accessed directly from VB Script and that gets deployed on remotes as required. Essentially I have no problem with creating a .NET assembly containing SalesLogix aware classes that are created, run, and destoyed via the .Managed interface in SalesLogix. But I am wondering about having COM visible classes that are objects directly visible to VB Script so that there properties and methods may be accessed directly from VB Script. Can this be done and what is the end to end process. Note: Using VB.NEt not C++ etc.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: COM Visible SalesLogix .NET Extension with VB.NETYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 08 1:49 PM
You just add the ComVisible attribute to the class. That's it. See http://msdn.microsoft.com/en-us/library/ms182157(VS.80).aspx

Then you can just return an instance of the class (Me) in the extension's Run method and retrieve it in the calling script and use it as needed.

Make sense?
[Reply][Quote]
Colin Maitland
Posts: 5
 
Re: COM Visible SalesLogix .NET Extension with VB.NETYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 08 3:41 PM
Ryan

I used 'Return Me' in the Run method used 'objY = Application.Managed.Run(objX, arrArgs)' in the SalesLogix VB Script. When I test objY it is Empty.

I have set the COM Visible property on the assembly. My test class implements Sage.SalesLogix.NetExtensions.IRunnable. The .NET Extension itself is working fine using the .Managed interface. I just can't get a COM reference to it that I can then use directly to access the public properties and methods.

What could I be doing wrong here? Do I need to use Interop or something as well?

Thanks.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: COM Visible SalesLogix .NET Extension with VB.NETYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 08 3:47 PM
Don't forget in VBScript you must Set the reference. Try this:

Set objY = Application.Managed.Run(objX, arrArgs)


If that doesn't do it, then maybe post more of the code for us to look at?
[Reply][Quote]
Colin Maitland
Posts: 5
 
Re: COM Visible SalesLogix .NET Extension with VB.NETYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 08 4:02 PM
Ryan
I tried that too. i.e. 'Set objY = Application.Managed.Run(objX, arrArgs)'. Here is the VB Script. I will put the .NET stuff in a separate reply.
I got the following error from that line: Error calling method Main. Object required: 'Application.Managed.Run(...)' at line 19 char 13.
This is the VB Script. Note: Don't confuse the fact this is script is called Sub Main.
sub Main

Dim arrArgs(3)
Dim objX
Dim objY

If MsgBox("You are about to invoke the Adexio .NET COM Visible test?" & vbNewLine & vbNewLine & "Do you want to continue?", vbQuestion + vbYesNo, "Adexio .NET COM Visible Test") = vbYes Then

objX = Application.Managed.Create("Adexio COM Visible SalesLogix Extension", "Adexio.COMVisible.SalesLogixExtension.Test")
If Not IsBlank(objX) Then

arrArgs(0) = "ExampleArgument0"
arrArgs(1) = "ExampleArgument1"
arrArgs(2) = "ExampleArgument2"
arrArgs(3) = "ExampleArgument3"

Set objY = Application.Managed.Run(objX, arrArgs)
Stop
If Not IsEmpty(objY) Then
With objY
.ExampleFunction1()
.ExampleFunction1()
.ExampleFunction1()
MsgBox .ExampleProperty1 & vbNewLine & .ExampleProperty2 & vbNewLine & .ExampleProperty3, vbInformation + vbOKOnly, "Properties"
End With
Else
MsgBox "objY is empty!", vbExclamation + vbOKOnly, "Adexio .NET COM Visible Test"
End If

Application.Managed.Destroy(objX)
End If
End If

end sub
[Reply][Quote]
Colin Maitland
Posts: 5
 
Re: COM Visible SalesLogix .NET Extension with VB.NETYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 08 4:06 PM
Here is the VB.NET code, minus the Settings class module that it refers to.

Imports Sage.SalesLogix.NetExtensions
Imports Sage.SalesLogix.NetExtensions.Deployment

Public Class Test

Implements Sage.SalesLogix.NetExtensions.IRunnable

#Region "Properties"
Private _ExampleProperty1 As String
Private _ExampleProperty2 As String
Private _ExampleProperty3 As String
Private _Settings As Settings
Private _SLX As SalesLogix.ISlxApplication

Public Property ExampleProperty1() As String
Get
Return _ExampleProperty1
End Get
Set(ByVal ExampleProperty1 As String)
_ExampleProperty1 = ExampleProperty1
End Set
End Property

Public Property ExampleProperty2() As String
Get
Return _ExampleProperty2
End Get
Set(ByVal ExampleProperty2 As String)
_ExampleProperty1 = ExampleProperty2
End Set
End Property

Public Property ExampleProperty3() As String
Get
Return _ExampleProperty3
End Get
Set(ByVal ExampleProperty3 As String)
_ExampleProperty3 = ExampleProperty3
End Set
End Property
#End Region

Public Sub Initialize(ByVal SLXApplication As SalesLogix.ISlxApplication, ByVal LicenceKeyManager As Licensing.ILicenseKeyManager) Implements IRunnable.Initialize
'Invoked By SalesLogix Script Application.Managed.Create()
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Initialize()")
_SLX = SLXApplication
_Settings = New Settings
End Sub

Protected Overrides Sub Finalize()
_Settings = Nothing
End Sub

Public Function Run(ByVal Args() As Object) As Object Implements IRunnable.Run
'Invoked By SalesLogix Script Application.Managed.Run() Function Call.

'Expected Total Number Of Argments To Be Passed Through Via The Args() Object From The SalesLogix Calling Function...
Const constExpectedArgsCount As Integer = 4

Dim CurrentArg As Object
Dim Index As Integer

MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Run()")

'Retrieve The Arguments Passed Through From The SalesLogix Calling Function...
_Settings.Clear() 'Custom Settings Object Used By This Class...
If Args.Length = constExpectedArgsCount Then
With _Settings
For Index = 0 To Args.Length - 1
CurrentArg = Args(Index).ToString
If Not CurrentArg Is Nothing Then
Select Case Index
Case 0
.Arg0 = CurrentArg.ToString
Case 1
.Arg1 = CurrentArg.ToString
Case 2
.Arg2 = CurrentArg.ToString
Case 3
.Arg3 = CurrentArg.ToString
End Select
End If
Next Index

'Call To Example Main Function Which Contains The Main Functionality...
If Main() = True Then
Return Me
Else
Return Me
End If
End With
Else
Beep()
MsgBox("An invalid number of arguments was passed to the SalesLogix NET Extension Class!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "SalesLogix Net Extension Class Run()")
Return Me
End If

End Function

Public Function Main() As Boolean
'Main Functionality Goes Here And Into Related Custom Subs And Functions...

ExampleProperty1 = "ExampleProperty1 = 'A'"
ExampleProperty2 = "ExampleProperty2 = 'B'"
ExampleProperty3 = "ExampleProperty3 = 'C'"

Return True
End Function

Public Function ExampleFunction1() As Boolean
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ExampleFunction1()")
Return True
End Function

Public Function ExampleFunction2() As Boolean
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ExampleFunction2()")
Return True
End Function

Public Function ExampleFunction3() As Boolean
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ExampleFunction3()")
Return True
End Function

End Class
[Reply][Quote]
Colin Maitland
Posts: 5
 
Re: COM Visible SalesLogix .NET Extension with VB.NET - THIS WORKSYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 08 7:43 PM
OK I found out I can get it to work when using BaseRunnable rather than IRunnable. Here is the example working VB SCRIPT and VB.NET code...

*** VB SCRIPT CODE ***
sub Main

Dim arrArgs(3)
Dim objX
Dim objY

If MsgBox("You are about to invoke the Adexio .NET COM Visible test?" & vbNewLine & vbNewLine & "Do you want to continue?", vbQuestion + vbYesNo, "Adexio .NET COM Visible Test") = vbYes Then

objX = Application.Managed.Create("Adexio COM Visible SalesLogix Extension", "Adexio.COMVisible.SalesLogixExtension.Test")
If Not IsBlank(objX) Then

arrArgs(0) = "ExampleArgument0"
arrArgs(1) = "ExampleArgument1"
arrArgs(2) = "ExampleArgument2"
arrArgs(3) = "ExampleArgument3"

Set objY = Application.Managed.Run(objX, arrArgs)
If Not IsEmpty(objY) Then
With objY
.ExampleFunction1()
.ExampleFunction2()
.ExampleFunction3()
MsgBox .ExampleProperty1 & vbNewLine & .ExampleProperty2 & vbNewLine & .ExampleProperty3, vbInformation + vbOKOnly, "Properties"
End With
Else
MsgBox "objY is empty!", vbExclamation + vbOKOnly, "Adexio .NET COM Visible Test"
End If
Set objY = Nothing

Application.Managed.Destroy(objX)
End If
End If
End Sub

*** VB.NET CODE ***
Imports Sage.SalesLogix.NetExtensions

Public Class Test

Inherits Sage.SalesLogix.NetExtensions.BaseRunnable

#Region "Private Properties"
Private _ExampleProperty1 As String
Private _ExampleProperty2 As String
Private _ExampleProperty3 As String

Private _Settings As Settings
Private _SLX As SalesLogix.ISlxApplication
#End Region

#Region "Public Properties"
Public Property ExampleProperty1() As String
Get
Return _ExampleProperty1
End Get
Set(ByVal ExampleProperty1 As String)
_ExampleProperty1 = ExampleProperty1
End Set
End Property

Public Property ExampleProperty2() As String
Get
Return _ExampleProperty2
End Get
Set(ByVal ExampleProperty2 As String)
_ExampleProperty2 = ExampleProperty2
End Set
End Property

Public Property ExampleProperty3() As String
Get
Return _ExampleProperty3
End Get
Set(ByVal ExampleProperty3 As String)
_ExampleProperty3 = ExampleProperty3
End Set
End Property
#End Region

Public Overrides Sub Initialize(ByVal SLXApplication As SalesLogix.ISlxApplication, ByVal LicenceKeyManager As Licensing.ILicenseKeyManager)
'Invoked By SalesLogix Script Application.Managed.Create()
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Initialize()")
_SLX = SLXApplication
_Settings = New Settings
End Sub

Protected Overrides Sub Finalize()
_Settings = Nothing
End Sub

Public Overrides Function Run(ByVal Args() As Object) As Object
'Invoked By SalesLogix Script Application.Managed.Run() Function Call.

'Expected Total Number Of Argments To Be Passed Through Via The Args() Array From The SalesLogix Calling Function...
Const constExpectedArgsCount As Integer = 4

Dim CurrentArg As Object
Dim Index As Integer

MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Run()")

'Retrieve The Arguments Passed Through From The SalesLogix Calling Function...
_Settings.Clear() 'Custom Settings Object Used By This Class...
If Args.Length = constExpectedArgsCount Then
With _Settings
For Index = 0 To Args.Length - 1
CurrentArg = Args(Index).ToString
If Not CurrentArg Is Nothing Then
Select Case Index
Case 0
.Arg0 = CurrentArg.ToString
Case 1
.Arg1 = CurrentArg.ToString
Case 2
.Arg2 = CurrentArg.ToString
Case 3
.Arg3 = CurrentArg.ToString
End Select
End If
Next Index

'Call To Example Main Function Which Contains The Main Functionality...
Main()
End With
Else
Beep()
MsgBox("An invalid number of arguments was passed to the SalesLogix NET Extension Class!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "SalesLogix Net Extension Class Run()")
End If

Return Me

End Function

Public Function Main() As Boolean
'Main Functionality Goes Here And Into Related Custom Subs And Functions...
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Main()")

ExampleProperty1 = "ExampleProperty1 = 'A'"
ExampleProperty2 = "ExampleProperty2 = 'B'"
ExampleProperty3 = "ExampleProperty3 = 'C'"

Return True
End Function

#Region "Example Functions"
Public Function ExampleFunction1() As Boolean
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ExampleFunction1()")
Return True
End Function

Public Function ExampleFunction2() As Boolean
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ExampleFunction2()")
Return True
End Function

Public Function ExampleFunction3() As Boolean
MsgBox("Hello World!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ExampleFunction3()")
Return True
End Function
#End Region

End Class
[Reply][Quote]
Andrew Wilson
Posts: 1
 
Re: COM Visible SalesLogix .NET Extension with VB.NET - THIS WORKSYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Jul 09 11:26 PM
When you implement IRunnable, you also need to mark the class with the ComVisible(true) attribute, as well as inherit from MarshalByRefObject. The BaseRunnable class does both of these things, which is why it worked for you.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 2/19/2025 4:34:13 PM