Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, June 7, 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: Stumped On Sample .NET Integration via COM
Carl Fenley
Posts: 4
 
Stumped On Sample .NET Integration via COMYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 May 07 4:25 PM
fiogf49gjkf0d
I'm trying to replicate the functionality demonstrated by Ryan Farley in this webcast:
http://www.slxdeveloper.com/screencasts/leveragingnetinsaleslogix/EmbeddingAControl/

My .NET UserControl has only one Label where I simply want to display the current ContactID. To make sure that I was understanding how Sales Logix works, I created two labels on the Form in Architect. One label is bound to the ContactID field while the other label displays the value of Form.CurrentID.

That much works.

I run into problems when I try to create my custom control on the Change event:

[code]Sub AXFormChange(Sender)

Dim loader

If Application.GlobalInfo.IndexOf("EmbedNETControl") = -1 Then
Set loader = CreateObject("SlxTest.EmbedNETControl")
loader.Init Form.HWND
loader.ContactID = Form.CurrentID
Application.GlobalInfo.Add "EmbedNETControl", loader
Else
Set loader = Application.GlobalInfo("EmbedNETControl")
loader.ContactID = Form.CurrentID
End If
End Sub[/code]

I basically get an error on the CreateObject line, but it is very generic. Here is the code for my Loader class:

[code]Imports System.Runtime.InteropServices

_
Public Class EmbedLoader

Private _ctrl As EmbedControl

Public Sub New()

End Sub

Public Sub Init(ByVal handle As Object)

Dim hwnd As IntPtr

If Not handle Is Nothing Then
hwnd = New IntPtr(CType(handle, Integer))
End If

If _ctrl Is Nothing Then
_ctrl = New EmbedControl
End If
SlxTest.Win32.SetParent(_ctrl.Handle, hwnd)
End Sub

Public Property ContactID() As String
Get
Return _ctrl.ContactID
End Get
Set(ByVal value As String)
If Not _ctrl Is Nothing Then
_ctrl.ContactID = value
End If
End Set
End Property
End Class[/code]

Any advice or suggestions would be greatly appreciated.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Stumped On Sample .NET Integration via COMYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 May 07 4:49 PM
fiogf49gjkf0d
The line for CreateObject needs to be specific for your .NET assembly. The "SlxTest.EmbedNETControl" isn't just some magic phrase, it needs to be the namespace.classname for your code. Also, your DLL needs to be registered for COM interop. I don't see what your namespace is, but your class name is "EmbedLoader", so that's enough to tell that the CreateObject call doesn't match your assembly.

I'd also suggest using the "ProgId" attribute for your class (as suggested in the screencast). That way, there's no room for things being wrong. However, just changing the call to CreateObject to match your namespace.classname in your code should do the trick.

Make sense?

-Ryan
[Reply][Quote]
Carl Fenley
Posts: 4
 
Re: Stumped On Sample .NET Integration via COMYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 May 07 4:57 PM
fiogf49gjkf0d
The forum must've stripped out my Attribute declarations because Visual Basic uses "<" and ">" to enclose them. What I have between those brackets is the following:

ComVisible(True), ProgId("SlxTest.EmbedLoader")

And I also changed the vbscript to reflect that change:
Set loader = CreateObject("SlxTest.EmbedLoader")

I have checked the Properties and confirmed my namespace and assemblyname are both "SlxTest". EmbedLoader is a member of SlxTest. The changes did not change the error in the SalesLogix Client.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Stumped On Sample .NET Integration via COMYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 May 07 5:05 PM
fiogf49gjkf0d
Ah, that makes sense. So, the only thing left that could be the problem is that the assembly is not registered for COM interop on the machine. Could that be the case?

Remember, marking the assembly ComVisible only takes care of making is accessible via COM. In order for you to be able to create/instanciate an object from it is to also register the assembly as well. You can do that in VS, to mark it so when you compile VS will do the COM registration for you, or you can do it manually.

To register the assembly manually for COM interop, execute the following in a command prompt:

"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe" "MySlxStuff.dll" /codebase


Of course, substitute your dll name for MySlxStuff.dll
[Reply][Quote]
Carl Fenley
Posts: 4
 
Re: Stumped On Sample .NET Integration via COMYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 May 07 6:16 PM
fiogf49gjkf0d
Thank you very much. That did the trick.
[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): 6/7/2025 12:45:04 PM