0

I'm trying to record my Selenium tests execution with Microsoft Expression Encoder. I've found many answers about the problem I'm currently facing but none of them really solved it. So, I have a method that starts the video recording process. It goes as simple as

        scj = new ScreenCaptureJob();
        scj.OutputScreenCaptureFileName = logPath + "\\" + fileName + ".wmv";
        scj.ScreenCaptureVideoProfile.FrameRate = 25;
        scj.CaptureMouseCursor = true;
        scj.Start();

When I run it from Visual Studio 2015 it works perfectly fine. But when I run it from TeamCity in one of our build agents, I get the following message:

OneTimeSetUp: System.BadImageFormatException: Could not load file or assembly 
'Microsoft.Expression.Encoder, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. An attempt was made to load a program with an incorrect format

Now, for what I've read over some forums, this is related to my architecture selection. In TeamCity, the build step that compiles the code has the "Any CPU" platform selected whereas in Visual Studio, "Mixed Platforms" is selected.

I already tried setting everything to x86 architecture in TeamCity, force NUnit 3 to run as a 32-bits process and also changing my project's target archicteture. None of those solutions has worked. Does anyone have any idea of what else I could do?

leppie
  • 115,091
  • 17
  • 196
  • 297

1 Answers1

0

You probably installed Microsoft.Expression.Encoder from its corresponding NuGet package.

You are also most likely not keeping your packages in source control (as it should be).

For that reason, when TC checks out the code the node packages are missing which requires a build step using the NuGet Installer, which will restore your packages before TC tries to build the code.

Teamcity NuGet Installer

Wilmer SH
  • 1,417
  • 12
  • 20
  • No, actually I installed it from this [website](https://www.microsoft.com/en-us/download/details.aspx?id=18974) and then I manually added the libraries available in the C:\Program Files (x86)\Microsoft Expression\Encoder 4\SDK folder to my project. After reading your answer, I tried with NuGet, but I've got the same issue. – Johnatha Felix Apr 05 '16 at 18:07
  • Then I would try to see if my solution file yourSolution.sln and yourProject.proj are getting checked. Mainly the project file as it will contain the reference to the dll, and you MUST check in the dll itself. We do that for some DevExpress libraries – Wilmer SH Apr 05 '16 at 18:19
  • I checked and everything seems fine. I think it is because the architecture of the libray, I just can't seem to "align" them via command line in TeamCity. – Johnatha Felix Apr 06 '16 at 19:14