Implementing a real-vb.net/approach to developing K/3 BOS plug-ins with the C #

Source: Internet
Author: User

Turn this article, originally always want to use C # to do K3 plug-in development, VB no C # with the cool Ah, this article written with 2011, it seems I did not seriously to find this method ah.

6176325

Kingdee K3 BOS the plug-in is officially used VB6 written, if

It is a pleasure to develop BOS plugins with language tools under . Net , which is self-evident, and this article is a personal initiative, implemented in vb.net or C # c++.net to develop The BOS plug-in (DLL If there is any sooner than this method, please contact the author, modify the original claim

Let's start with a few conceptual questions:

1. NET class components and COM components: VB6 developed ActiveX.dll can be registered with Regsvr32.exe, it is something suitable for COM specifications. NET development of the class suffix is also DLL, but they are not the same thing,. NET (VB, C #) is a DLL that runs on the. NET CLR and some other meta-data that has a self-describing function that does not conform to the COM + specification, Kingdee K/3 and BOS are developed with VB6, EAS that's another matter, So the BOS plug-in is also VB6 call the COM specification of the DLL, it is the principle of the original program (the host) first import the DLL placed on the BOS plug-in and then directly byref call public Sub Show (Byval XXX as Object) To pass the objects that need to be programmed, so we're going to VB6 to call. NET DLLs, what do we do? Visual Studio provides a command-line tool with a tool called Regasm.exe to help us implement this interoperability command a bit of a compilation of the masm!

2,. NET Strong name Strong name is to protect your components from being destroyed. NET-developed DLLs want to be called like COM and must have a strong name (digital signature)

’-------------------------------------------------------------------------------------------------------------- ----------------------------

Talk less, follow my detailed steps to the gourd painting scoop

1, open vs Create a class look at Figure 1.1

Figure 1.1

Note: Attention to the Red Line box on the graph, class, class name, the use of the. Net frame version of 3.5 2.0 can also, this test language I choose VB, of course, C # can also, I am basic loyal!

2, go in and add the K3ClassEvents.dll component at the menu [item]>>[Add Reference] (add it as VB6), as shown in Figure 2.1

Figure 2.1

3, write code in net Way and specification, can refer to BOS data and VB6 toolbar plug-in to generate code slightly modified as skeleton code

Figure 3.1

Detailed code attached to the attachment also with the original test project files, excluding the actual application function as an example

Imports k3classevents

Public Class MenuBar

' Define the Listevents interface. Must have a declaration to get the event

Private WithEvents M_listinterface as Listevents

Public Sub Show (ByVal olistinterface as Object)

' Listevents Interface implementation

' Note: This method must be present, do not modify

M_listinterface = Olistinterface

End Sub

Private Sub Class_Terminate ()

' Release Interface object

' Note: This method must be present, do not modify

M_listinterface = Nothing

End Sub

Private Sub M_listinterface_menubarclick (ByVal bostool as K3classevents.bostool, ByRef Cancel as Boolean) Handles M_listi Nterface. Menubarclick

' TODO: Please add code response events here

On Error Resume Next

Select Case Bostool.toolname

Case "Shangla"

' Add a click event to handle Shangla menu objects here

Dim form as New form

Form. Show ()

Case "Dizhu"

' Add a click event to handle Dizhu menu objects here

Case "Config"

MsgBox ("Add Click event Config to handle config menu object here")

Case "Info"

' To add a click event to handle the Info menu object

Dim Strid as String

Strid = M_ListInterface.DataSrv.ClassType ("FNAME")

Dim strSQL as String

strSQL = M_ListInterface.DataSrv.sqlselectdetail & "where" & M_ListInterface.DataSrv.Filter ("Filterstring")

MsgBox (strSQL)

Case Else

End Select

End Sub

Private Sub m_listinterface_menubarinitialize (ByVal omenubar as K3classevents.menubar) Handles m_ Listinterface.menubarinitialize

Try

' TODO: Please add code response events here

Dim Otool as K3classevents.bostool

Dim Oband as K3classevents.bosband

' *************** started adding BOS menu ***************

' Add Shangla Menu object and set properties

Otool = OMenuBar.BOSTools.Add ("Shangla")

With Otool

. Caption = "Pull Up"

. ToolTipText = "Pull Source document"

. Description = "Pull Up"

. ShortcutKey = 0

. Visible = True

. Enabled = True

. BeginGroup = True

. Toolpicture = "d:/documents and settings/administrator/my documents/visual Studio 2008/projects/ico/makequery.ico"

. Setpicture (0, 0)

End with

Oband = Omenubar.bosbands ("Bandtoolbar")

OBand.BOSTools.InsertBefore ("Mnubackdata", Otool) ' Inserts a menu object into the specified toolbar

' Add Dizhu Menu object and set properties

Otool = OMenuBar.BOSTools.Add ("Dizhu")

With Otool

. Caption = "Bucket landlord"

. ToolTipText = "Come and relax."

. Description = "Bucket landlord"

. ShortcutKey = 0

. Visible = True

. Enabled = True

. BeginGroup = True

. Toolpicture = "d:/documents and settings/administrator/my documents/visual Studio 2008/projects/ico/icon.ico"

. Setpicture (0, 0)

End with

Oband = Omenubar.bosbands ("Bandtoolbar")

OBand.BOSTools.InsertBefore ("Mnubackdata", Otool) ' Inserts a menu object into the specified toolbar

' Add config Menu object and set properties

Otool = oMenuBar.BOSTools.Add ("config")

With Otool

. Caption = "Settings"

. ToolTipText = "Set SQL for custom Execution"

. Description = "Execute"

. ShortcutKey = 0

. Visible = True

. Enabled = True

. BeginGroup = True

. Toolpicture = "d:/documents and settings/administrator/my documents/visual Studio 2008/projects/ico/ Progresssuccess.ico "

. Setpicture (0, 0)

End with

Oband = Omenubar.bosbands ("Bandtoolbar")

OBand.BOSTools.InsertBefore ("Mnubackdata", Otool) ' Inserts a menu object into the specified toolbar

' Add Info Menu object and set properties

Otool = OMenuBar.BOSTools.Add ("Info")

With Otool

. Caption = "Info"

. ToolTipText = "Show Off related information"

. Description = "Info"

. ShortcutKey = 0

. Visible = True

. Enabled = True

. BeginGroup = True

. Toolpicture = "d:/documents and settings/administrator/my documents/visual Studio 2008/projects/ico/server.ico"

. Setpicture (0, 0)

End with

Oband = Omenubar.bosbands ("Bandtoolbar")

OBand.BOSTools.InsertBefore ("Mnubackdata", Otool) ' Inserts a menu object into the specified toolbar

' *************** End new BOS menu ***************

Catch ex as Exception

MsgBox (ex. message.tostring)

End Try

End Sub

End Class

4.1) Go To menu [item]>[xxx Properties]> Application > assembly information in making assembly COM visible tick

2) Enter [Project]>[xxx properties]> compile [for COM interop] Tick

3) Enter [Project]>[XXX properties]> sign [sign for assembly] and < new ...> an SNK signature without a password can also be

5, go to VS tools

Key: Register net DLLs with the RegAsm command

D:/documents and settings/administrator/my documents/visual Studio 2008/projects/bos_listevent_plugins/bos_ Listevent_plugins/bin/release> regasm Bos_listevent_plugins.dll/tlb:testplugins.net.dll

6) End, call this registered DLL in the BOS development environment

Because I built a form so that one more form this

Have you seen more out of the toolbar on these few items on the menu to grab the landlord info

Point [pull up] events that appear

Select Case Bostool.toolname

Case "Shangla"

' Add a click event to handle Shangla menu objects here

Dim form as New form

Form. Show ()

Implementing a real-vb.net/approach to developing K/3 BOS plug-ins with the C #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.