????? ????? ???? .NET serviced ?? Basic.NET ????? ?? Visual Basic 2005

?????? ????????? ?????? ?????????
???? ???????: 312902 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ????? ???? .NET serviced ?????? ?????????. ???? ??? ??????? ????? ????? ????? ???? ??????? ???? serviced. ??????? Microsoft ???? ????? Microsoft COM + ????? ???????? .NET.

??????? ????

  • ??????? ??? ???? ??????? serviced.
  • ????? ?????? serviced ?? "????? ??????? ??????? ??????? ???????" (GAC) ????? ??????? ????? ??????. ????? ??????? ?????? ?? GAC. ???? Microsoft ????? ??????? ??????? ?? GAC ? ??? ????? ?? ?? ??? ??? ???????.
  • ????? ??????? ???? ????? ??????? ?????? ???????? serviced ?? + COM:
    • ??????? ??????? ??????? ?????? ???????? serviced ????????.
    • ??????? ?????? ???????? Regsvcs.exe ?????? ???????? serviced ??????. ???? Regsvcs.exe ?? ?????? ??????:
      \WINNT\Microsoft.NET\Framework\ Framework Version
      ????? ?? ????????? ??? Regsvcs.exe Microsoft .NET ???? ????? ?????? ????? ????? ??????? (SDK) Framework.
  • ????? Microsoft SQL Server ??? ????????? ?????? ??????? ?????? ?? ??? ???????.
  • ???? ??? ??????? ??? ?????? ???????. ????? ??????? ??????? SELECT ?? ???? ?? ??????? ???? ?????? COM + ????? ??? COM + ?????? ???? ????? ??? ????????. ?????? ???? ??? ????? ?????? ??????? ??????? ????? ??????? ???????? ???.

????? ?????? .NET serviced

  1. ????? ????? Visual Basic ????? ?????? ???? ?? ??? ServicedCOM.
  2. ????? ????? ??? ?????????? VBServCom.
  3. ????? ???? ??? ????? ????? System.EnterpriseServices.
  4. ???? ?? ???? ???????? ???????? ??????? ??? ????? ?????:
    Imports System.EnterpriseServices
    Imports System.Data.SqlClient
    					
  5. ?? ?????? ????????? ???????? ??????? ??? ??????? ?????:
        Inherits EnterpriseServices.ServicedComponent
    					
  6. ?? ?????? ????????? ???????? ??????? ??? ????? ??? (?? ???? ??? ?????? ????? "_"):
    <Transaction(TransactionOption.RequiresNew)> _
    					
  7. ????? ?????? ??????? ??? ??? AssemblyInfo.vb:
    <assembly: ApplicationActivation(ActivationOption.Library)>
    <assembly: ApplicationName("SimpleTrans")>
    						
    ?????????:
    • ??? ActivationOption ??????? ??? ?? ??? ??? ???? ??? ????? ?????? ?? ????? ??????. ????? ????? Activation.Option????? ?? ????.
    • ??? ??? ??????? ?? ????? ???? ???? ?????? + COM ?? ?????? COM + "?" ???? ?????? "????? ????? ????????".
  8. ????? ????? ?????????? ??????? ??? AssemblyInfo.vb ?????:
    <Assembly: Description("Simple Transactional application to show Enterprise Services")>
    						
    ??? ????? ????? ??? ????? + COM ?? ???? ?????? ?????? COM + "?" ????? ????? ????????.
  9. ??? ??????? ?????? ??? ??? Class1.vb ?? VBServCom.vb ????????? ??? ??? ????? ????? ????? ? ?????:
        ' Shows Explicit SetComplete/SetAbort.
        Public Function DoTrans() As String
            Dim connection As SqlConnection
            Dim command As SqlCommand
            Dim reader As SqlDataReader
            Dim name As String
            Dim query As String
    
            Try
                query = "SELECT au_lname, au_fname FROM authors"
                connection = New SqlConnection("data source=localhost;initial catalog = pubs;UID=sa;PWD=")
                command = New SqlCommand(query, connection)
    
                connection.Open()
                reader = command.ExecuteReader()
    
                reader.Read()
                name = reader.GetString(0) & ", " & reader.GetString(1)
            Catch exc As Exception
                ContextUtil.SetAbort()
                Throw exc
            End Try
            DoTrans = name
        End Function
    
        ' Show implicit SetComplete/SetAbort.
        <AutoComplete(True)> _
        Public Sub DoTxAuto()
            'Do stuff
        End Sub
    					
  10. ????? ????? SqlConnection ?????? ?????? ??.

????? ????? ?? ??????? ??? ??? ????

  1. ???? ??? ???? ? ???? ??? ???????? ???? ??? Microsoft Visual Studio .NET ?? ???? ??? ????? .NET Visual Studio ??? Visual Studio .NET ???? ???????.
  2. ?? ???? ???????? ???? ????? ??????:
    ???? sn.exe ServicedCOM.snk
    ???? ??? ??????? ????? ?? ??????? ??? ??? ????.

    ????? ?? ????????? ??? Regsvcs.exe ???? ????? Microsoft .NET Framework ????? ?????? ??????? (SDK).
  3. ??? ServicedCOM.snk ??? ???? ???????.
  4. ?? ??? AssemblyInfo.vb ??????? ??? AssemblykeyFile ???????? ???????? ???????:
    <Assembly: AssemblyKeyFile("..\\..\\ServicedCOM.snk")>
    					

????? ???? serviced ??? COM +

????? ?????? ???? ???? ??? ????? ?????? ?????. ?? ????? ?????? ????? ?????? ?? Regsvcs.exe. ???????? Regsvcs.exe ???? ??????? ???????:
  1. ???? ??? ???? ???? ??? ??????? ??? ??? Microsoft Visual Studio .NET ?? ?? ???? ??? ????? .NET Visual Studio ???? ???? ????? .NET.
  2. ?? ???? ????? .NET ? ???? regsvcs servicedcom.dll.

    ???? ??? ??? ????? ????? ????? COM + ??? ??? ????? ??? ??? ?????.

?????? ?????? ????? ??

  1. ?? Microsoft Notepad? ???? ??? ???.
  2. ?? ???? ???????? ???????? ??????? ?? ?????:
    set o =createobject("VBServCOM.VBServCOM")
    
    MsgBox o.DoTrans()
    					
  3. ?? ??????? ???? ???? ??? ???.
  4. ?? ?????? ??? ????? ? ???? Test.vbs. ?? ??????? ??? ???? ? ???? ??? ???? ??????? ?? ???? ??? ???.
  5. ???? ????? ??????? ??? ????? ????? ??????.

???????

???? ???????: 312902 - ????? ??? ??????: 28/???? ??????/1435 - ??????: 5.5
????? ???
  • Microsoft Enterprise Services (included with the .NET Framework) 1.0
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic 2005
????? ??????: 
kbnosurvey kbarchive kbmt kbhowtomaster KB312902 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????312902

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com