E
Ebenezer Illango
Guest
Hi Team,
How to make the Windows form application which runs a coded UI method to run on a different machine which does not have Visual Studio?
I have a written Coded UI Script. A very basic one, running operation in calculator using recorded and playback.
Now, I am calling the Coded UI script using a button in a Windows Form.
I tried installing the Windows form in a Non Visual studio machine and it is throwing error.
The Below is the Full error message
Microsoft.VisualStudio.TestTools.UITest.Extension.InvalidUITestExtensionPackageException: The following package failed to load: C:\Program Files (x86)\Common Files\Microsoft Shared\VSTT\14.0\Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll. ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Program Files (x86)\Common Files\Microsoft Shared\VSTT\14.0\Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestExtensionPackageManager.LoadAssembly(String assemblyFile)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestExtensionPackageManager.LoadAssembly(String assemblyFile)
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestExtensionPackageManager.LoadAssemblies(String[] assemblyNames)
at Microsoft.VisualStudio.TestTools.UITest.Framework.AbstractUITestExtensionPackageManager..ctor()
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestService.Initialize()
at Microsoft.VisualStudio.TestTools.UITesting.Playback.Initialize()
at WFCalculator.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I tried use this Code which I found in the internet to redirect the assemblies to the application
The below is the Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WFCalculator3
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private static Assembly ExecutingAssembly = Assembly.GetExecutingAssembly();
private static string[] EmbeddedLibraries =
ExecutingAssembly.GetManifestResourceNames().Where(x => x.EndsWith(".dll")).ToArray();
[STAThread]
static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
// Get assembly name
var assemblyName = new AssemblyName(args.Name).Name + ".dll";
// Get resource name
var resourceName = EmbeddedLibraries.FirstOrDefault(x => x.EndsWith(assemblyName));
if (resourceName == null)
{
return null;
}
// Load assembly from resource
using (var stream = ExecutingAssembly.GetManifestResourceStream(resourceName))
{
var bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
return Assembly.Load(bytes);
}
}
}
}
But is throwing the below error.
Exception thrown: 'System.ArgumentException' in mscorlib.dll
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
The path is not of a legal form.
Could you please help me on how to resolve this issue to make the application which works in my system to get working in others' non Visual Studio systems?
Thanks,
Ebenezer Illango
Continue reading...
How to make the Windows form application which runs a coded UI method to run on a different machine which does not have Visual Studio?
I have a written Coded UI Script. A very basic one, running operation in calculator using recorded and playback.
Now, I am calling the Coded UI script using a button in a Windows Form.
I tried installing the Windows form in a Non Visual studio machine and it is throwing error.
The Below is the Full error message
Microsoft.VisualStudio.TestTools.UITest.Extension.InvalidUITestExtensionPackageException: The following package failed to load: C:\Program Files (x86)\Common Files\Microsoft Shared\VSTT\14.0\Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll. ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Program Files (x86)\Common Files\Microsoft Shared\VSTT\14.0\Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestExtensionPackageManager.LoadAssembly(String assemblyFile)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestExtensionPackageManager.LoadAssembly(String assemblyFile)
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestExtensionPackageManager.LoadAssemblies(String[] assemblyNames)
at Microsoft.VisualStudio.TestTools.UITest.Framework.AbstractUITestExtensionPackageManager..ctor()
at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestService.Initialize()
at Microsoft.VisualStudio.TestTools.UITesting.Playback.Initialize()
at WFCalculator.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I tried use this Code which I found in the internet to redirect the assemblies to the application
The below is the Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WFCalculator3
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private static Assembly ExecutingAssembly = Assembly.GetExecutingAssembly();
private static string[] EmbeddedLibraries =
ExecutingAssembly.GetManifestResourceNames().Where(x => x.EndsWith(".dll")).ToArray();
[STAThread]
static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
// Get assembly name
var assemblyName = new AssemblyName(args.Name).Name + ".dll";
// Get resource name
var resourceName = EmbeddedLibraries.FirstOrDefault(x => x.EndsWith(assemblyName));
if (resourceName == null)
{
return null;
}
// Load assembly from resource
using (var stream = ExecutingAssembly.GetManifestResourceStream(resourceName))
{
var bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
return Assembly.Load(bytes);
}
}
}
}
But is throwing the below error.
Exception thrown: 'System.ArgumentException' in mscorlib.dll
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
The path is not of a legal form.
Could you please help me on how to resolve this issue to make the application which works in my system to get working in others' non Visual Studio systems?
Thanks,
Ebenezer Illango
Continue reading...