Running CodedUI Test From Another Application - c#

I'm planning to run my coded UI test from another project (in same solution). I added a reference of the CUIT project to my winform app project. Also I added these references as well
Microsoft.VisualStudio.TestTools.UITesting.dll
Microsoft.VisualStudio.QualityTools.CodedUITestFramework.dll
Microsoft.VisualStudio.TestTools.UITest.CodeGeneration.dll
Microsoft.VisualStudio.TestTools.UITest.Framework.dll
Microsoft.VisualStudio.TestTools.UITest.Playback.dll
My code is something like this
Playback.Initialize();
TestProject.CodedUITest1 coded = new TestProject.CodedUITest1();
coded.CodedUITestMethod1();
Playback.Cleanup();
However, I get an exception on the Playback.Initialize() call.
this is the message...
"An unhandled exception of type 'Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException' occurred in Microsoft.VisualStudio.TestTools.UITesting.dll"
Someone said that installing Test agent 2010/Test agent10 can solve this error.
I installed MS Visual studio Test Agent 2010, but same error happens.
What am I doing wrong here?
Thanks

I tried to run the test the same way you do and it worked for me.
Below are the reference dlls I have added in my projects
Please make sure you have added all the dlls. In case you are not able to find the dlls, look for them in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies.
If this doesn't work please provide the details of inner exception.

I found an answer to my problem. I found that the message of the inner exception is
"Retrieving the COM class factory for component with CLSID {27876903-E697-4406-BF49-1B8B92CB8735} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
After digging around I found that I have a 32 bit third party dll which I'm running on my 64-bit machine. The conflict is 64 bit process trying to invoke 32 bit process in 64 bit machine.
The solution is to change the project properties to target to 'X86' machine instead of 'Any'.

Related

Class not registered error when trying to use COM (even from 32 bit process)

I need to use a 3rd party COM library to interact with an API. It seems to have installed ok, and there is a test harness that has been provided to me that seems to work OK, so I'm sure there's nothing wrong with the DLL.
My .NET code looks like this (in vs 2015):
Type t = Type.GetTypeFromCLSID(new Guid("xxxxx")); //this works ok
object o = Activator.CreateInstance(t); // this throws an error
The error thrown is:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: `Retrieving the COM class factory for component with CLSID {xxxxx} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).`
I have ensured all projects including the main one are x86 (as I know the DLL is a 32 bit lib):
For good measure, I tried to re-register the lib like this: Regsvr32 xxxx.dll /s but still getting the same error.
Any help would be great! Thanks.
EDIT
The main project is indeed set to x86, "prefer 32 bit" is therefore greyed out.
Looks like you might have the wrong GUID. Run regsvr32.exe mydll.dll. As Hans suggests, run process monitor during the registry registration and check to make sure you have the right CLSID

MonoGame not working

I am just getting started with MonoGame (and game programming in general) and cant run any programs. I keep getting this exception message
An unhandled exception of type 'System.DllNotFoundException' occurred in MonoGame.Framework.dll
Additional information: Unable to load DLL 'openal32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Does anybody know how I can fix this?
You'll need to install OpenAL.
This is included in the standard MonoGame installer, and placed in "C:\Program Files (x86)\MonoGame\v3.0\oalinst.exe".
Yes, you need to install OpenAL. If you're bulding windows game project it will be wise to add OpenAL DLL file links into your project and mark them to be copied to Output directory. This way your deployed game will not require separate OpenAL installation on client (or even on another dev machine).
Dll files are:
OpenAL32.dll
wrap_oal.dll
I had the same error, when you have win10 it includes directX, so if you are using win 8 or less you need to install direct10: the link: https://www.microsoft.com/en-us/download/details.aspx?id=35&nowin10
and.... finally works!!!

Getting error on using Skype4ComLib

Hi I am using Skype4ComLib to retrieve Skype contacts but I am getting error:
Retrieving the COM class factory for component with CLSID
{830690FC-BF2F-47A6-AC2D-330BCB402664} failed due to the following
error: 80040154 Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG)).
Skype is installed on my machine.
any idea?
I recently experienced the exact same error message, and it was simply as a result of my .NET project being compiled for "Any CPU" by default.
The SKYPE4COM library is a 32bit only binary, and as such you should make sure that the project you intend to use it with is specifically compiled for "x86" architecture.
As soon as I did this, the error message just went away.
Simply right-click on your project and select "properties". Then under the "Build" tab, choose "x86" where it says "platform target". This process may vary with your version of Visual Studio, but is correct as of version 2012.
Have you registered the DLL? Take a look at this Blog
From above blog:
In the command prompt type : regsvr32 Skype4COM.dll or "regsvr32
C:\Program Files\Common Files\Skype\Skype4COM.dll"
Also try taking a look at this SO Question

BCL.XPRB dll isn't initializing in C#.Net application

I am trying to resolve an initialization error for the optimizer library. I have a license for and installed Xpress-IVE 64bit studio, however, I need to link and use xprb facilities in a C#.Net application that is built in VS2010 and runs on IIS.
I copied xprb.dll and xprbdn.dll to application bin folder for deployment, and added them as references. Yet when the application calls XPRB.init(), it throws exception
Unable to load DLL 'xprb.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
Any suggestions on what could be missing?
It turned out to be a Windows/.Net/general instability issue. The license, although installed, wasn't found by .Net, which decided to blow up as if the dll wasn't available. Finally was resolved mysteriously after a few system reboots and updates.
I had the same issue, but running windows 8.1, xpress-ive 64bit and vs2013 with c#. I could run IVE and solve problems from there, but i got "An unhandled exception of type 'Additional information: Unable to load DLL 'xprb.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" error in runtime when running using bcl in VS. What solved the problem in my case was going through the necessary environment variables and directing them to the correct xpress folders (environment variables xpress, path and mosel.dso).

Can not reference a Dll that worked earlier

I am trying to change the Terminal Services settings programmaticly. I learned that you must use tsuserex.dll. Being c# i ran tsuserex through tlbimp and created TSUSEREXLib.dll then registered it with regasm. I got it working and wrote a framework program with it as a prof of concept. However today after I made some changes when I run my program I get the error
Unable to cast COM object of type 'System.__ComObject' to interface type 'TSUSEREXLib.IADsTSUserEx'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C4930E79-2989-4462-8A60-2FCF2F2955EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
it thows the exception on the line
IADsTSUserEx iad = (IADsTSUserEx)((DirectoryEntry)user.GetUnderlyingObject()).NativeObject;
This exact line worked fine in the test project. I know user is a valid UserPrincipal, Googleing I found this is usually just needs the dll re-registered, but even after unloading and reloading it it still will not work. What am I missing to cause my dll to stop working.
I know this is an old thread but since I had trouble recently finding all the required steps to get the Terminal Services components working on Windows 7, I wanted to share what I found. I think the steps below are more reliable than copying the tsuserex.dll from a server and trying to register it.
From what I understand, on any operating system you need Remote Server Administration Tools (RSAT) installed in order to modify Terminal Services attributes of a user account programmatically. On some versions of Windows this requires a download. But on Windows 7, RSAT is already installed.
But you may need to enable it using the configuration options in Control Panel (appwiz.cpl). Under "Turn Windows features on or off" goto "Remote Server Administration Tools" then ensure that "Remote Desktop Services Tools" is checked.
After I did this (and rebooted) I was able to use the components from tsuserex.dll via PowerShell (e.g., Set-QADUser -Identity testUser -TsHomeDirectory "c:\tshome"), and by adding a reference in Visual Studio 2010 (to "tsexusrm 1.0 Type Library").
You almost certainly need to re-register your TLB on the target machine. What likely happened is you have your assembly, interface or type GUID not hard coded in the application and hence it's changed on every rebuild. So after rebuilding and deploying your type no longer matches up with the previously registered TLB.
The correct answer is that I am a idiot for not reliseing that my build environment did change. I moved to a new workstaion that was windows 7 corprate instead of server 2003 when i started on the project. Win7 corp does not have tsuserex.dll in its system.
Visual Studio Build Setting „Platform target“ disable=> “Prefer 32-bit” solve the Problem.

Categories