.NET Framework 2.0 design considerations and expected behavior
KB000152
PRODUCTThis article discusses the expected behavior of .NET 2.0 assemblies referenced in K2.net 2003. This article applies to assemblies referenced from the GAC and the file system.
Introduction
This article discusses the expected behavior of .NET 2.0 assemblies when referenced in K2.net 2003 and also applies to assemblies referenced from the GAC and the file system.
Part 1: Demonstration | |||
The following example is an illustration of the outcome when using .NET 2.0 assemblies as a reference in K2.net 2003. | |||
1) | Create the following class in VS .NET 2005 as illustrated. The purpose of the assembly is to output a text message to the K2.net Server console to test whether the correct version of the assembly was loaded with the process instance. | ||
Public Class Class1 Public Sub CallFromK2(ByVal procFolio As String) Console.WriteLine("") Console.WriteLine("################# START Test #################") Console.WriteLine(procFolio & " - .NET 2 Assembly Version: 1.0.0.0") Console.WriteLine("################## END Test ##################") Console.WriteLine("") End Sub End Class
| |||
2) | In K2.net 2003 Studio, create a process and reference the assembly illustrated above. Add a K2.net Server Event and edit the code as illustrated below: | ||
Sub Main(ByVal K2 As ServerEventContext) K2.Synchronous = True Dim oObject As New SampleClass.Class1 oObject.CallFromK2(K2.ProcessInstance.folio) End Sub
| |||
3) | Start K2.net 2003 Server in console mode for testing purposes | ||
4) | Export the process to the K2.net Server and set the necessary permissions on the process | ||
5) | Create a new process instance, the result of the assembly call is illustrated in the image below: | ||
| |||
6) | Update the assembly in VS .NET as illustrated. The code change made to the assembly included an additional output to the console to test the conditions under which the new assembly will be loaded. | ||
Public Class Class1 Public Sub CallFromK2(ByVal procFolio As String) Console.WriteLine("") Console.WriteLine("################# START Test #################") Console.WriteLine(procFolio & " - .NET 2 Assembly Version: 1.0.0.0") Console.WriteLine("Make some changes in the assembly") Console.WriteLine("################## END Test ##################") Console.WriteLine("") End Sub End Class
| |||
7) | Recompile the assembly and update the reference in K2.net Studio. Note: Remove the existing reference and add the reference again | ||
😎 | Export the process to the K2.net Server | ||
9) | Create a new process instance, the result of the assembly call is illustrated in the image below: | ||
| |||
| |||
10) | Restart the K2.net Server and create a new process instance, the result of the assembly call is illustrated in the image below: | ||
| |||
| |||
| |||
Part 2: Best Practices | |||
The following section discusses the ideal way of dealing with references in K2.net and should be used as a guideline / best practice during development and testing. | |||
1) | In VS .NET open the class created in the previous section and update the assembly version used in the "CallFromK2" method from "1.0.0.0" to "1.0.0.1". | ||
Public Class Class1 Public Sub CallFromK2(ByVal procFolio As String) Console.WriteLine("") Console.WriteLine("################# START Test #################") Console.WriteLine(procFolio & " - .NET 2 Assembly Version: 1.0.0.1") Console.WriteLine("Make some changes in the assembly") Console.WriteLine("################## END Test ##################") Console.WriteLine("") End Sub End Class
| |||
2) | Open the "AssemblyInfo.vb" or "AssemblyInfo.cs" file and update the version of the assembly to "1.0.0.1". | ||
3) | Save and recompile the assembly then update the reference in K2.net Studio. | ||
| |||
4) | Export the process to the K2.net Server | ||
5) | Create a new process instance, the result of the assembly call is illustrated in the image below: | ||
| |||
| |||
Part 3: Demonstration on testing older process versions | |||
This section demonstrates how to test older versions of the same process to ensure that the correct assembly is used with the selected version of the process | |||
1) | In K2.net 2003 Service Manager, change the default process version to the version that made use of version "1.0.0.0" of the assembly. | ||
2) | Create a new process instance and the result of the assembly call is illustrated in the image below: | ||
| |||
| |||
3) | Change the default process version back to the latest one and create a new process instance, the result of the assembly call is illustrated in the image below: | ||
| |||
Summary: | |||
As demonstrated above, the current assembly with an updated version number will effectively enable the K2.net Server to run current and older versions of the same process, without the need to restart the K2.net Server when .NET 2 assemblies are reference in K2.net 2003. |