Latest version 2013.1.806.0 Throws System.TypeInitializationException

16 posts, 0 answers
  1. Rajchandar
    Rajchandar avatar
    1 posts
    Member since:
    Apr 2013

    Posted 07 Aug 2013 Link to this post

    Hi,

    We have been using Telerik Testing Framework for our WPF project. It is working fine with the previous version 2012.2.1420.0.

    But today when I upgraded with the latest version 2013.1.806.0, it throws "System.TypeInitializationException" when it is trying find control using automationId (this.WpfWindow.Find.ByAutomationId<T>("automationId"))

    Details of the exception thrown are as follows

    Exception thrown during the wait for a condition. Error: Unexpected error while waiting on condition. Error: System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
     
       at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
     
       at System.Reflection.RuntimeModule.GetTypes()
     
       at System.Reflection.Assembly.GetTypes()
     
       at ArtOfTest.WebAii.Silverlight.ObjectSerializer.InitKnownTypes()
     
       at ArtOfTest.WebAii.Silverlight.ObjectSerializer..cctor()
     
       --- End of inner exception stack trace ---
     
       at ArtOfTest.WebAii.Silverlight.ObjectSerializer.Serialize(Type t, Object o)
     
       at ArtOfTest.WebAii.Silverlight.SilverlightCommand.AsString()
     
       at ArtOfTest.WebAii.Wpf.WpfProxy.CreateCommand(SilverlightCommand SlCommand)
     
       at ArtOfTest.WebAii.Wpf.WpfProxy.ExecuteSLCommand(SilverlightCommand cmd)
     
       at ArtOfTest.WebAii.Wpf.WpfProxy.GetAllVisualTrees()
     
       at ArtOfTest.WebAii.Wpf.WpfWindow.RefreshVisualTrees()
     
       at ArtOfTest.WebAii.Silverlight.VisualFind.RefreshRoot()
     
       at ArtOfTest.WebAii.Silverlight.VisualWait.WaitForExistsByFindInfo(VisualFindInfo findInfo)
     
       at ArtOfTest.Common.WaitAsync._worker_DoWork[T,V](Object waitParam)

    We have been referring three DLLs in our Project
    1. ArtOfTest.WebAii.dll
    2. Telerik.WebAii.Controls.Xaml.dll
    3. Telerik.WebAii.Controls.Xaml.Wpf.dll

    Do we need to refer any additional binaries?

    Thanks & Regards,
    Raj
     
  2. Asta
    Asta avatar
    29 posts
    Member since:
    Nov 2011

    Posted 08 Aug 2013 Link to this post

    The same with my tests. Was working until upgrade...
  3. Max
    Max avatar
    17 posts
    Member since:
    May 2012

    Posted 08 Aug 2013 Link to this post

    Hi, I work with Raj who started this post but I have done some further work into this and been able to write a simplified reproduction of this error.
    So I have taken down our application to its bare bones and created a simple test project. See attached zip file with project.

    The project is purely getting the application running with no interaction with it yet but even though Raj posted an example of when we were attempting to find a control you will see from my example that purely calling Manager.ActiveApplication.MainWindow.RefreshVisualTrees(); causes the same error
    To get it running:
    1. 1. Replace the exePath With any Wpf Application
    2. 2. replace windowsProcessNameOfExe with the process name of your Wpf Application (to help close down duplicate applications).

    The Test output for me from executing the test is:

    Debug Trace:
    ************************
    ReflectionTypeLoadException - Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    Could not load file or assembly 'Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de' or one of its dependencies. The system cannot find the file specified.
    Could not load file or assembly 'Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de' or one of its dependencies. The system cannot find the file specified.
    ************************

    Test method TelerikIssuePOC.UnitTest1.TestMethod1 threw exception: 
    System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
        at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
       at System.Reflection.RuntimeModule.GetTypes()
       at System.Reflection.Assembly.GetTypes()
       at ArtOfTest.WebAii.Silverlight.ObjectSerializer.InitKnownTypes()
       at ArtOfTest.WebAii.Silverlight.ObjectSerializer..cctor()
     --- End of inner exception stack trace ---
        at ArtOfTest.WebAii.Silverlight.ObjectSerializer.Serialize(Type t, Object o)
       at ArtOfTest.WebAii.Silverlight.SilverlightCommand.AsString()
       at ArtOfTest.WebAii.Wpf.WpfProxy.CreateCommand(SilverlightCommand SlCommand)
       at ArtOfTest.WebAii.Wpf.WpfProxy.ExecuteSLCommand(SilverlightCommand cmd)
       at ArtOfTest.WebAii.Wpf.WpfProxy.GetAllVisualTrees()
       at ArtOfTest.WebAii.Wpf.WpfWindow.RefreshVisualTrees()
       at TelerikIssuePOC.UnitTest1.Start(String exePath, String logPath) in UnitTest1.cs: line 79
       at TelerikIssuePOC.UnitTest1.TestMethod1() in UnitTest1.cs: line 21

    Here is the test code class from the attached project

    using ArtOfTest.WebAii.Core;
    using ArtOfTest.WebAii.Wpf;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System;
    using System.Diagnostics;
    using System.Linq;
    using System.Reflection;
    using System.Threading;
     
    namespace TelerikIssuePOC
    {
        [TestClass]
        public class UnitTest1
        {
            private string exePath = @"C:\Temp\TestSortedView\TestSortedView.exe";
            private static string windowsProcessNameOfExe = "TestSortedView";
            private string logPath = @"C:\Temp\TelerikTestlog";
            [TestMethod]
            public void TestMethod1()
            {
                Start(exePath, logPath);
            }
     
            /// <summary>
            /// Gets the application.
            /// </summary>
            private static WpfApplication Application { get; set; }
     
            /// <summary>
            /// Gets the manager.
            /// </summary>
            private static Manager Manager { get; set; }
     
            /// <summary>
            /// Starts the test runner.
            /// </summary>
            public static void Start(string exePath, string logPath)
            {
     
                if (Manager == null)
                {
                    StartUpManager(exePath, logPath);
                }
     
                try
                {
                    // This is in case you have the application running when you start the test
                    KillAllTestAppProcesses(windowsProcessNameOfExe);
                    // Launch Application
                    Application = Manager.LaunchNewApplication(Manager.Settings.Wpf.DefaultApplicationPath);
                }
                // sem to be getting a ReflectionType Load Exception
                // LoaderExpection = "Could not load file or assembly 'Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de' or one of its dependencies. The system cannot find the file specified.":"Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de"
                // NB: This does not exist in Framework installation.
                catch(ReflectionTypeLoadException rtle)
                {
                    Trace.WriteLine("************************");
                    Trace.WriteLine("ReflectionTypeLoadException - " + rtle.Message);
                    foreach (var le in rtle.LoaderExceptions)
                    {
                        Trace.WriteLine(le.Message);
                    }
                    Trace.WriteLine("************************");
     
                    // This is because even though the above throws an error the application still opens
                    KillAllTestAppProcesses(windowsProcessNameOfExe);
                    // NB: This time the exception above is not thrown when Application Launch is initiated
                    Application = Manager.LaunchNewApplication(Manager.Settings.Wpf.DefaultApplicationPath);
                }
                Manager.ActiveApplication.WaitForWindow("MainWindow");
     
                //This line causes exactly the same error as when we start to Find controls
                try
                {
                    Manager.ActiveApplication.MainWindow.RefreshVisualTrees();
                }
                catch(TypeInitializationException ex)
                {
                    throw;
                }
            }
     
            /// <summary>
            /// The start up manager.
            /// </summary>
            /// <param name="exePath">
            /// The exe path.
            /// </param>
            /// <param name="logPath">
            /// The log path.
            /// </param>
            private static void StartUpManager(string exePath, string logPath)
            {
                var settings = new Settings
                {
                    ExecuteCommandTimeout = 30000,
                    ExecutionDelay = 500,
                    UnexpectedDialogAction = UnexpectedDialogAction.HandleAndFailTest,
                    CreateLogFile = true,
                    LogLocation = logPath,
                    QueryEventLogErrorsOnExit = true,
                    LogAnnotations = true,
                    Wpf = new Settings.WpfSettings
                    {
                        DefaultApplicationPath = exePath,
                    },
                    SimulatedMouseMoveSpeed = 1.0f
                };
     
                Manager = new Manager(settings);
                Manager.Start();
            }
     
     
            /// <summary>
            /// The kill all current exe processes.
            /// </summary>
            public static void KillAllTestAppProcesses(string processName)
            {
                var processes = Process.GetProcesses().Where(p => p.ProcessName == processName);
                if (processes.Any())
                {
                    foreach (var atlasProcess in processes)
                    {
                        if (!atlasProcess.WaitForExit(5000))
                        {
                            atlasProcess.Kill();
                        }
                    }
                }
                // Give it a second for processes to be killed
                Thread.Sleep(1000);
            }
     
        }
    }

  4. Andreas
    Andreas avatar
    3 posts
    Member since:
    Oct 2012

    Posted 09 Aug 2013 Link to this post

    Same problem here (upgraded vom 2012.920).
    Seems that a dependency to test studio creeped in?
  5. Andrea
    Andrea avatar
    16 posts
    Member since:
    Jul 2012

    Posted 12 Aug 2013 Link to this post

    I am also having this problem.

    Telerik, could you please advise?
  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 12 Aug 2013 Link to this post

    Hello,

    Thank you for contacting us. 

    Unfortunately I was no able to reproduce this issue on our end. Please send us a sample application with a test project so we can reproduce it in our development environment and give you a proper solution.

    Thank you fro your understanding.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  7. Max
    Max avatar
    17 posts
    Member since:
    May 2012

    Posted 12 Aug 2013 Link to this post

    I did in fact attach a Test project with my post above and have reproduced it with the simplest of shell wpf applications. Did you try my project? I also assume you are doing this on a machine that does not have Test studio installed?

    Can any other posters to this thread try my project and reproduce it with your application? all you should have to change is the application path, the Process name it runs as and a log path (even though its not being output).

            private string exePath = @"C:\Temp\TestSortedView\TestSortedView.exe";
            private static string windowsProcessNameOfExe = "TestSortedView";
            private string logPath = @"C:\Temp\TelerikTestlog";
     
  8. Max
    Max avatar
    17 posts
    Member since:
    May 2012

    Posted 12 Aug 2013 Link to this post

    Please find attached a wpf application with 1 label of "Hello World!" for you to try it against.
  9. Andreas
    Andreas avatar
    3 posts
    Member since:
    Oct 2012

    Posted 12 Aug 2013 Link to this post

    Analysing the dependency in Reflector shows that Telerik.TestStudio.Interfaces.Communication.ICommunicationRequest and Telerik.TestStudio.Interfaces.Communication.ICommunicationRequestFactory are used.

    The former is used in ArtOfTest.WebAii by ArtOfTest.WebAii.Messaging.Http.WcfHttpRawRequest(Factory), the latter is used by ArtOfTest.WebAii.Messaging.Http.WcfHttpRawRequestFactory.

    Hope this helps.
  10. Max
    Max avatar
    17 posts
    Member since:
    May 2012

    Posted 13 Aug 2013 Link to this post

    Has any of the additional information helped you reproduce the problem?
  11. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 15 Aug 2013 Link to this post

    Hi Max,

    Thank you for providing the test and the application. I was able to reproduce this issue and I can confirm that this is a bug. In the new release of our framework we did not install and add in the GAC Telerik.TestStudio.Interfaces.dll.

    I have logged a bug report on this issue which you can track here.

    I've updated your account with Telerik points. 

    We really appreciate when you find bugs and take the time to report them. 

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  12. Steffen
    Steffen avatar
    4 posts
    Member since:
    Apr 2012

    Posted 20 Aug 2013 Link to this post

    Can you provide an internal build with this bugfix, please.

    Best regards
  13. Max
    Max avatar
    17 posts
    Member since:
    May 2012

    Posted 20 Aug 2013 Link to this post

    Seconded
  14. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 23 Aug 2013 Link to this post

    Hello,

    I am attaching Telerik.TestStudio.Interfaces.dll to this ticket.

    Please copy it to the bin folder of the framework and install it into the GAC. Here is an article which describes how you can do this. 

    If you have Visual Studio installed on your computer: On the taskbar, click Start, click All Programs, click Visual Studio, click Visual Studio Tools, and then click Visual Studio Command Prompt and type gacutil /i path to the dll.

    Hope this helps.

     

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  15. Max
    Max avatar
    17 posts
    Member since:
    May 2012

    Posted 30 Aug 2013 Link to this post

    Thanks as a workaround this does work.
  16. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 02 Sep 2013 Link to this post

    Hi Rajchandar,

    Glad to hear that!

    If you need additional assistance, please do not hesitate to contact us. 

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top