6/7/2025 12:22:38 PM
|
|
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!
Forum to discuss the use of .NET Extensions in SalesLogix version 7 and higher. View the code of conduct for posting guidelines.
|
|
|
|
Stumped On Sample .NET Integration via COM
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. |
|
|
|
Re: Stumped On Sample .NET Integration via COM
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 |
|
|
|
Re: Stumped On Sample .NET Integration via COM
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. |
|
|
|
Re: Stumped On Sample .NET Integration via COM
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 |
|
|
| |
|
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!
|
|
|
|
|
|
|
|