Could not load file or assembly Microsoft.mshtml - windows

I have a program in c# that is using WatiN. It compiles and runs well in my development windows 7. However when I copy the program to windows 2012 datacenter in azure, it throws below exception when the application tries to start an instance of internet explorer(which exists in windows 2012 datacenter):
System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified. File name: 'Microsoft.mshtml,
Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at
WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForCompleteOrTimeout()
at WatiN.Core.IE.WaitForComplete(Int32 waitForCompleteTimeOut) at
WatiN.Core.Browser.GoTo(Uri url) at
WatiN.Core.IE.FinishInitialization(Uri uri)
I am kind of lost on this exception, what is missing on the server?
Thank.

It is a standard interop assembly that is installed in the GAC on any dev machine. Not exactly sure how it got there, most likely it is the VS installer that put it there. But it won't be in the GAC on that Azure node.
Open the References node of your project and select the Microsoft.mshtml entry. Change the Copy Local property to True. Rebuild and you'll now have a copy of the assembly in your build directory. Copy it along with the rest of your executables to the Azure node.

Related

How to solve "System.IO.FileNotFoundException" in Windows?

I'm facing the following error message:
System.IO.FileNotFoundException: 'Could not load file or assembly 'Application Server Core,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified.'
This means that the file "Application Server Core.dll", version 1.0.0.0, is not present in a runtime directory.
A runtime directory?
Yes: I have an application in one directory and a bunch of DLLs in another one. But that's not the main issue.
The point is that I'm working in a client environment, which means that the "Application Server Core" should even not be loaded.
So, I'm asking which other application or DLL is trying to load this DLL. I can't find out while checking the callstack, so I thought having a look inside the other applications or DLLs, using the Windows equivalent of the ldd or the nm UNIX/Linux commands, and you can already guess my question:
What are the Windows equivalents for the UNIX/Linux ldd and nm commands?
Thanks in advance

TFS2015 Visual Studio Test: Could not load file or assembly

I have an "old" XAML Build Definition, made in Visual Studio; which builds a solution and following runs unit tests.
Now I've tried to make the same in the new TFS 2015 web surface.
I've created a build task, following Visual Studio Test.
But now the Test-Task exit with code 1 and gives me a lot of
"System.IO.FileNotFoundException: Could not load file or assembly" errors.
And also "Warning: MSTestAdapter failed to discover tests in class ..."
All the DLLs are where they have to be, the new definition has the same directory structure like the old one, but the test-task says there are missing assemblys.
Any ideas?
Update:
No, I still have the same error messages:
Warning: Unable to load types from the test source 'J:\xyz-Tests.dll'. Some or all of the tests in this source may not be discovered. If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit http://go.microsoft.com/fwlink/?LinkId=238340 for more info. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'xyz_Commons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'xyz_Processing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'xyzCommons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
This should exactly be the issue mentioned in below article, please try following the workaround to fix it:
Running Coded UI Tests built using Visual Studio 2013 with Team Foundation Server 2015
Test execution is failing in this scenario because test execution
engine is not able to resolve the old version binaries while executing
tests in a 14.0 environment (TFS 2015).
So, you need to update the projects to reference the new versions of the assemblies (VS 2015 in this scenario) using the assembly bindings in the test projects config file.
As a workaround to this issue, add an ‘app.config’ file to your
solution (See how to add app.config
https://msdn.microsoft.com/en-in/library/ms184658.aspx) and update the
contents of the file with the shared on OneDrive . The updated
configuration files contain assembly redirects from version 12.0 to
14.0, which will make sure that the test agent machine is able to resolve the framework assemblies. Check-in the updated configuration
file into the source control repository and run the BDT scenario once
again. The tests should run fine this time. If the test execution
again throws an error complaining version mismatch for some other
assembly, add the assembly to the app.config file and retry.
You can also reference this article :
http://www.dotnetcatch.com/2015/10/01/tfs-2010-to-2015-upgrade-codedui-feature-test-builds/

Application exe not running properly. There is a log in CLR_v4.0_32\UsageLogs. What does this mean?

I have an EXE application we use that is very important. On some PC's it runs fine -- some it doesn't. I have seen it work on fresh install of Win7x64 -- after installing the 180 updates it no longer runs properly.
I upgraded to Windows 10 and it ran fine. Had a hardware problem and had to reinstall the OS. After doing drivers,updates,etc the application won't run.
I found a log file in: C:\Users\username\AppData\Local\Microsoft\CLR_v4.0_32\UsageLogs
1,"fusion","GAC",0
1,"WinRT","NotApp",1
3,"System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System\08da6b6698b412866e6910ae9b84f363\System.ni.dll",0
3,"System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Core\f6ebd52be27fe627fed0d185c6a9c0d5\System.Core.ni.dll",0
3,"Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","C:\windows\assembly\NativeImages_v4.0.30319_32\Microsoft.V9921e851#\02386c57c46556747a75089068a31af0\Microsoft.VisualBasic.ni.dll",0
3,"System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Drawing\c2abcda8f96d67fa6ff5665fd21dddff\System.Drawing.ni.dll",0
3,"System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Windows.Forms\c02fbf560e52a1aab432a90d4c613af4\System.Windows.Forms.ni.dll",0
3,"System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Runt73a1fc9d#\272d1cf3a7cbd4cd648a2ff2d7a8889a\System.Runtime.Remoting.ni.dll",0
I can't find much information on why these logs are created and if this shows any useful information as to why it's not running properly. The application is not supported so I'm trying to get it to run until we have another solution.
I think this log file has nothing related to the issue that your application "doesn't run fine".
You should build in your application your own kind of tracing to locate the issue, what kind of exception is raised? Could you provide maybe more information about whats going wrong?
Here are some information about the log file mentioned above:
With Windows 8 (.NET 4.5), a new NGen mode: "Auto NGen" has been
introduced. Basically, the .NET runtime generates usage logs for
managed applications. Source
Every time the application run it creates a new type of logs called
“Assembly Usage Logs” in the AppData windows directory.
Source
On my research I found out mostly that it only does this job on Windows 8+.
But in this source it says also on Windows Server 2012, but I have tried it on a Windows Server 2012 R2 and could NOT reproduce it!

Missing MSBuild task when compiling C++/CLI

I am trying to compile some C++/CLI using MSBuild. I am getting an error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppClean.
targets(74,5): error MSB4062: The "CppClean" task could not be loaded from the assembly Microsoft.Build.CppTasks.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not load file or assembly 'Microsoft.Build.CppTasks.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
A colleague of mine has fixed this error by installing Visual Studio 2010 SP1 on his machine, but I already have that installed (as well as Visual Studio 2012 with Update 1) yet am getting this error. I have checked the path from the error message, and both the Microsoft.CppClean.targets and Microsoft.Build.CPPTasks.Common.dll files exist.
The CPPClean task appears to be part of the MSBuild tasks specific to Visual C++. Is there any way to get this as a separate installer so that I can repair it, or as part an installer for another set of tools? Failing that, is there another way of fixing this error?
Prompted by Lanorkin's comment, I checked the GAC and the Microsoft.Build.CppTasks.Common.dll assembly was not in there. I added it manually, and it now builds.

Getting MSBuild and CruiseControl .NET to build and deploy VS2010 database projects

I almost have a NAnt script together that will build and deploy VS2010 database projects, but one error stands in my way:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.TSqlTasks.targets(56,5): error MSB4062: The "SqlBuildTask" task could not be loaded from the assembly Microsoft.Data.Schema.Tasks.Sql, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not load file or assembly 'Microsoft.Data.Schema.Tasks.Sql, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [xxx]
Failed to start MSBuild.
External Program Failed: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe (return code was 1)
I can see that the Microsoft.Data.Schema assemblies are not in the MSIL GAC on the build server - is there any clean way to do this without a full-freight installation of VS2010 on the build server?
For the curious, I asked Barclay Hill at Microsoft who answered this for me:
You can’t build database projects on
machines unless they have VS or TFS
2010 installed on them. It is not a
supported scenario. You can deploy
database project build outputs without
VS/TFS installed using vsdbcmd. The
only way to do this and be in line
with the licensing and support is to
install a local copy of VS Pro or
higher on your build box if not using
TFS.

Resources