HOW TO: ????? ???? .NET Serviced ?? Visual C# .NET

?????? ????????? ?????? ?????????
???? ???????: 306296 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

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

??????? ????

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

????? ?????? .NET Serviced

  1. ????? ????? ????? Visual C# ?? ?????? ???? ???? ServicedCOM.
  2. ????? ????? ??? ?????????? ???? ?? Class1.cs ??? SimpleTrans.cs. ?????? ????? ???? ??????? ???????:
    1. ?? ?????? "??? ???" ? ???? ??? ?????? ?????? ??? Class1 ??? ?? ???? ??? ?????.
    2. ?? ????? ? ????? ????? ????? ??? SimpleTrans.
  3. ????? ???? ??? ????? ????? System.EnterpriseServices.
  4. ????? ??????? ??????? ????? ?????? SimpleTrans.cs ? AssemblyInfo.cs:
    using System.EnterpriseServices;
    ??? ???? SimpleTrans.cs ????? ??????? ???????:
    using System.Data.SqlClient;
  5. ??? ????? ServicedComponent (??? ???? ???? ????: System.EnterpriseServices.ServicedComponent).
  6. ?? ?????? ????????? ???????? ??????? ??? ??? * ????? ?????? * ?????:
    [Transaction(TransactionOption.RequiresNew)]
    					
  7. ????? ??????? ?????? ??? ???? AssemblyInfo.cs:
    [assembly: ApplicationActivation(ActivationOption.Library)]
    [assembly: ApplicationName("SimpleTrans")]	
    					
    • ??? ActivationOption ??????? ??? ?? ??? ??? ???? ????? ?????? ???? ????? ??????. ????? ????? Activation.Option ??? ????? ?? ??? ????.
    • ??? ??? ??????? ?? ????? ???? ???? ?????? + COM ?? ?????? COM + "?" ???? ?????? "????? ????? ????????".
  8. ????? ????? ?????????? ??????? ??? SimpleTrans.cs ??? ??? ???????? ??????:
    [assembly: Description("Simple Transactional application to show Enterprise Services")]
    						
    ??? ????? ????? ??? ????? + COM ?? ???? ?????? ?????? COM + "?" ????? ????? ????????.
  9. ??? ??????? ?????? ??? SimpleTrans.cs:
    // Demos Explicit SetComplete/SetAbort
            public string DoTrans()
            {
                SqlConnection	connection;
                SqlCommand		command; 
                SqlDataReader	reader;
                string		name;
                string		query;
    		
                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(Exception exc)
                {
                    ContextUtil.SetAbort();
                    throw exc;
                }
                return name;
        }
    // Demo implicit SetComplete/SetAbort
    [AutoComplete]
    public void DoTxAuto()
    {
        // Do stuff
    }
    					
  10. ????? ????? SqlConnection ??? ?? ????? ?????.

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

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

    ?????? ??? ??????? ??? ????????? ??????? ?? ????? ???? ???? ????? .NET Framework ????? ?????? ??????? (SDK).
  3. ??? ServicedCOM.snk ??? ???? ???????.
  4. ?? AssemblyInfo.cs ? ?????? ??? AssemblykeyFile ???????? ???????? ???????:
    [assembly: AssemblyKeyFile("..\\..\\ServicedCOM.snk")]
    					

????? ???? ???? Serviced ??? COM +

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

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

  1. ?? ???????? ???? ??? ???.
  2. ?? ???? ???????? ???????? ??????? ?? ?????:
    set o =createobject("ServicedCOM.SimpleTrans")
    
    MsgBox o.DoTrans()
    					
  3. ?? ??????? ???? ???? ??? ???.
  4. ?? ???? ?????? ???? ???? ??? ????? ???? Test.vbs. ?? ??????? ??? ???? ? ???? ??? ???? ??????? ?? ???? ??? ???.
  5. ???? ????? ??????? ??? ????? ????? ??????.

???????

???? ???????: 306296 - ????? ??? ??????: 21/???/1424 - ??????: 4.1
????? ???
  • Microsoft Enterprise Services (included with the .NET Framework) 1.0
  • Microsoft Visual C# .NET 2002 Standard Edition
????? ??????: 
kbmt kbhowtomaster KB306296 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????306296

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

 

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