Generation: N-tiers development mode (Modification and modification of COM + components)
After the component security is complete, the next task is to call the components we have installed. The names of components we have set are as follows:
Package: kdmo1000
Project: pdmomenu
Class:
Cdmomenu1 (no transaction)
Cdmomenu2 (with Transaction)
One function in the false cdmomenu1 is getnodename. The number of nodeids (integer) is imported into the role, and the return value is nodename (string)
Getnodename (byval nodeid as integer) as string
Late binding:
The usage method I mentioned here is to useLate binding. That is to say, the component will not be registered to yourASP. NETOr yourVB. NETWhen the system is runningServerSet this objectBind. The disadvantage is that you cannotOBJ.You can select the attribute method in the pop-up component. You must use the attribute method by yourself.KeyinGo in. However, when your components have been changedReferenceYour components.ASP,ASP. NET,VB,VB. NETYou call components in the same way.
Call components:
Call components are as follows:
ASP:SetOBJ= Createobject("Pdmomenu. cdmomenu1")
Nodeid= 2
Nodename=OBJ. getnodename (nodeid)
VB: Dim OBJ As Object
Set OBJ = Createobject ( " Pdmomenu. cdmomenu1 " )
Dim Nodeid As Integer
Nodeid = 2
Dim Nodename As String
Nodename = OBJ. getnodename (nodeid)
ASP. NET/VB. NET Dim Nodeid As Integer = 2
Dim OBJ As Object = Createobject ( " Pdmomenu. cdmomenu1 " )
Try
Dim Nodename As String = OBJ. getnodename (nodeid)
Catch Ex As Exception
Me . Lblerrmsg. Text = Ex. Message. tostring ()
Finally
' Resource Recovery
OBJ. Dispose ()
OBJ = Nothing
End Try
NetCall components must be released by themselves:
From the aboveProgramCode, You can find that the call component process is almost the same, using. NetAt the time of writing, the call method can be simpler.
After the component is called for execution, you can find Package The components in are called and switched. If you use ASP, VB6 Call the component, you can find that when the call is complete, the component turns to stop, and the component number in the call is also reset to zero. However . Net Call components, if not written 【 Try... catch... finally... end tryAnd 【 OBJ. Dispose () ],【 OBJ = nothing ] Put in Finally The components in [Component Service] will not stop. This is because ASP, VB6 After the program is executed 【Resource RecyclingBut in . Net Medium 【Resource Recycling] Must be manually executed by the program designer. Otherwise, it must be started when the system resources are insufficient. GC Can be recycled.