question about creating COM component Add In using Visual Basic .N

Aug 31, 2005 5 Replies

Hello,



I am trying to create a very basic add-in to POS just to get familiar with how it's done. I have followed the directions in the "Creating a



COM Component Add-in" help section. First I created a Class Library called RMSTest; I left the default name of Class1 for the class. Here



is all the code:


---------------------- Module TestModule


Public Session As Object



Public Class Class1



End Class



Public Function Process(ByVal Session As Object) As Boolean Dim custID As Integer custID = Session.Transaction.Customer.ID If custID 0 Then Process = True MsgBox("cust id is " + custID) Else MsgBox("no cust id") Process = False End If



End Function End Module



----------------------



Basically, I just want to display a message box with the customer's id when a customer value is changed. After I built my solution and



strong named the assembly, rebuilt the solution (steps 1-10), I browsed out to the bin folder of my project and registered the dll. I was a



bit confused because the steps said to browse out to the bin folder from the command prompt, but then it said to ccopy the dll to the addins



directory for Store Operations. So I wasn't sure where the file should be registered, so I tried it from both places.



Both times I typed in regasm /tlb:RMSTest.tlb RMSTest.dll, I got the following at the command prompt:



RegAsm Warning: No Types were registered.. Assembly exported to 'C:\Program Files\Microsoft Retail Management System\Store Operations\rmstest.tlb', and the type library was registered



successfully


I am not sure why I got the No Types Were registered.



But then I continued on and changed my registry settings; I changed the Hook Count to 1, and in the 000 hook, I put in Hooktype of 11,



ObjectName of RMSTest.Class1 and Parameter of 5. This seemed to be the right settings for calling the add in on customer save.



So, then I went into Store Operations and tried to change some customer values; when I clicked the OK button, I got the error message:



Attempt to execute COM object 'RMSTest.Class1' failed. Could not create object.



Like I said, this is a very basic thing I am trying to do - there could be an error in the VB .Net code, the way I tried to register it, the



registry settings, etc - I just am not sure.



Any ideas?



Thanks!


Some changes I have tried are moving the Process Function code inside the class. the code is now:

Module TestModule

Public Session As Object

Public Class Class1

Public Function Process(ByVal Session As Object) As Boolean Dim custID As Integer

custID = Session.Transaction.Customer.ID If custID 0 Then MsgBox("cust id is " + custID) Else MsgBox("no cust id") End If

Process = True

End Function End Class

End Module

I also added the line to the AssemblyInfo.vb file and that did not do anything.

"aozm" wrote:

I checked the Register for COM inteeop checkbox in the project options. I deleted my existing class and added a COM class. The only code in there is:

---------------------------- Public Class Component1 Inherits System.ComponentModel.Component

Public Function Process(ByVal Session As Object) As Boolean

Try MsgBox("this is a test") Process = True Catch ex As Exception MsgBox(ex.Message)

End Try End Function

End Class

-------------------- I changed the registry object name to be RMSTest.Component1. I still get the same error. (except now it says Attempt to execute COM object RMSTest.Component1 failed...instead of COM object RMStest.Class1.)

Anything else I can try??

Ok, I just decided to create a whole new project and try everything from scratch. At first I was just displaying a message box and that worked fine - woohoo!

But, when I tried to access the Transaction and Customer objects, I got the error: Public member 'Transaction' on type 'Integer' not found.

Here's the code:

Public Function Process(ByVal Session As Object) As Boolean Process = True

On Error GoTo ERROR_PROCESS

MsgBox("this is a test") MsgBox("Name " & Session.Transaction.Customer.Name)

Exit Function

ERROR_PROCESS:

MsgBox(Err.Description) Process = False

Exit Function

End Function End Class

-----------

the first message box displays, but I get an error on the second one.

"aozm" ha scritto nel messaggio news: snipped-for-privacy@microsoft.com...

First.. enable in project options "Register for COM "interaporability"", and when create class.. don't create standard class, but COM Class otherwise the class in not accessible from non .NET programs

bye antonio

Different hook events pass different parameters - the hook you registered passes an integer rather than a session object. Check the hooktype and parameter type for the event you are trying to catch.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required