MSTest fails to load dll from network share - azure

I am running MSTest (on a Microsoft Azure VM) to test a DLL which is in a network file share (linked to Azure File Storage).
I get this error -
Could not load file or assembly 'file:///P:\test\bin\mydll.dll' or one
of its dependencies. Operation is not supported. (Exception from
HRESULT: 0x80131515)

Solution 1:
xcopy the folder containing the dll and its dependencies from the network share to a local disk and run it from there.
Solution 2:
This solution is preferable because it saves the copy step.
Find the folder that contains MSTest.exe. In my case here:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
Open MSTest.exe.config (it should already exist) and add the following line under<runtime> :
<loadFromRemoteSources enabled="true"/>
in context:
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
...
From: MSDN: <loadFromRemoteSources> element.
Confusingly, it says:
In the .NET Framework 4.5, assemblies on local network shares are run
as full trust by default; you do not have to enable the
<loadFromRemoteSources> element.
I am targeting .NET 4.5, but I got the error until I enabled loadFromRemoteSources.

Related

DNX (ASP.NET Core RC1) web application - cannot host in IIS

I'm trying to deploy an web application still on ASP.NET RC1 (DNX) to IIS. I went through all the Microsoft documentation, but I'm stuck on an issue. I'm getting this error when the application is starting up:
Application startup exception: System.IO.FileLoadException: Could not load file or assembly 'Web' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
File name: 'Web' ---> Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException: Startup.cs(104,39): DNX,Version=v4.5.1 error CS0012: The type 'Func<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
What does this mean? I am able to deploy to IIS on my local machine that I did the development on without any issues. However, just the server with IIS does not work.
How do I go about solving this error? The server is on Windows Server 2008 R2, and my local machine is Windows 7, if that helps.
I was able to resolve this problem using a workaround. It looks like it is an issue with Visual Studio 2015's Publish command. It looks like it does not have an option to publish into Nuget packages. This means the publish command outputs the source files. Hence the files still need to be compiled by the server.
I did not find out how to let the server compile the files correctly. However, I was able to resolve it by just compiling the code into Nuget packages before-hand. This can be done by using the dnu commandline tool.
dnu publish --out %folder% --no-source --include-symbols --runtime dnx-clr-win-x86.1.0.0-rc1-update1 --configuration Release
The important part is the --no-source option, which will package into Nuget packages.

Azure SDK 2.5.1 fails to Publish cloudService

After successfully upgrading my cloud service to the new "Azure SDK for .NET 2.5.1" I got the following error when trying packaging/publishing.
Could not load file or assembly 'Microsoft.WindowsAzure.Packaging,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file
specified. C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v12.0\Windows Azure
Tools\2.5\Microsoft.WindowsAzure.targets
The related line in the "Microsoft.WindowsAzure.targets" config file is 2930 which obviously is related to CSPack.
<CSPack
ServiceDefinitionFile="#(TargetServiceDefinition)"
Output="#(PublishServicePackage)"
PackRoles="#(Roles)"
SiteMapping="#(SiteMapping)"
RoleProperties="#(RoleProperties)"
ImportedModules="#(ImportedModules)"
CopyOnly="false"
>
</CSPack>
So I went on to create a fresh new Azure Cloud service in a fresh new project to see if something went wrong with the upgrade. Unfortunately the problem persists.
Is there a workaround or will I have to rollback to v2.4 (that will cause me significant amount of pain)
I am running on VS 2013 update 4.
Sorry for the trouble, everyone. We are investigating what's causing this. It looks like there is an odd behavior with our installers where in some environments those two binaries are not installed correctly.
We did discover if the 2.5.1 Azure Authoring Tools is removed and reinstalled, the missing binaries will be installed correctly. So if you run into this issue, please remove Authoring Tools v2.5.1 from Programs and Features, and reinstall via either the Web Platform Installer or the direct download links:
http://download.microsoft.com/download/1/E/7/1E76DD6F-66F1-47E0-A76A-3BBAAC617316/MicrosoftAzureAuthoringTools-x64.msi
http://download.microsoft.com/download/1/E/7/1E76DD6F-66F1-47E0-A76A-3BBAAC617316/MicrosoftAzureAuthoringTools-x86.msi
Apologies for the inconvenience. We will continue the investigation.
I searched locally for the required dll and found it in almost all previous versions of the Azure .Net SDK had it (from v2.0 onwards I believe).
So in order to fix this you need to copy the following dlls from the previous version v2.4 of the SDK to the similar location for v2.5.
SDK installation paths.
Src location: "C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.4\bin"
Dst location: "C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin"
Dlls to copy (missing):
Microsoft.WindowsAzure.Packaging.dll
Microsoft.WindowsAzure.ServiceModel.Common.dll
Since there may be a better answer to this I will not mark this as an answer yet.

Microsoft.SqlServer.Types, Version=11.0.0.0 missing

I have published the project on Azure websites and it throws exception:
Microsoft.SqlServer.Types, Version=11.0.0.0 missing when I try to
run report. Locally everything works fine. I have
RepowrtViewer.WebForms and ReportViewer.Common both version 11.0.0.0
in the project. On the machine locally in SDK/Assemblies
I have Microsoft.SqlServer.Types, Version=11.0..2100.6. I have tried to add this to the project but did not work. The same exception,
Where do I find Microsoft.SqlServer.Types 11.0.0.0?
Thank you
You're probably referencing the DLL's from the global assembly cache on your local machine but they aren't present in the GAC in Azure.
Open up visual studio and right click on the Microsoft.SqlServer.Types assembly reference in your project and select properties. Change the copy local flag from False to True and recompile your application. You should now have the the Microsoft.SqlServer.Types.dll file in your applications bin folder.
Redeploy to azure and hopefully the error will have vanished.
How I got this solved.
I had to add 5 files altogether and I moved these 5 files to my bin directory. I then added these references by browsing to the bin directory and adding them. I rebuilt my project and copied to web server - all working fine.
Microsoft.SqlServer.Types.dll (make sure you copy the correct version as I had sql 2008 but using report viewer 11)
Microsoft.ReportViewer.ProcessingObjectModel.dll
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.WebForms.dll
Microsoft.ReportViewer.WinForms.dll
Also make sure you have the correct version of these dll's from the GAC in the bin directory and I installed report viewer on the server. These are the steps that worked for me.
The best solution would be to install the Microsoft.SqlServer.Types NuGet package.
PM> Install-Package Microsoft.SqlServer.Types
And follow instructions from its readme.htm
I had exactly the same issue but found the solution quite quickly. It was using the Assembly within this folder C:\Program Files (x86)\Microsoft SQL Server\100 where I then removed my reference via Visual Studio and referenced the right file from within this folder C:\Program Files (x86)\Microsoft SQL Server\110
If you still need this reference then please make use of this method.
Cheers,
Check your SQL server ProductVersion using the following query,
SELECT
SERVERPROPERTY('MachineName') AS ComputerName,
SERVERPROPERTY('ServerName') AS InstanceName,
SERVERPROPERTY('Edition') AS Edition,
SERVERPROPERTY('ProductVersion') AS ProductVersion,
SERVERPROPERTY('ProductLevel') AS ProductLevel;
GO
It will be like something this,
You can see in my case ProductVersion = 13.0.1601.5. In your project go to NuGet package manager and search Microsoft.SqlServer.Types. From there you can see, Microsoft.SqlServer.Types with the same ProductVersion and Install it.
My Experience
I used to face this kind of problems until I understand the GAC and Bin deploy
Your computer has all the installed DLLs into a place called GAC (Global Assembly Cache). so your local programs can search for their needs in there if they can not find the required DLL in the execution path. It's often work for developer itself, but when you deploy your program to the client, problems may appear.
Remember that, you can always Bin deploy your DLLs. first, go to the references tree in your project and add the required Dll by browsing your GAC (usually c:\windows\assembly\GAC_MSIL...) then go to the property window of the added Dll and set Copy Local to True . Now you can publish or deploy your project and be sure that it will works.
Make sure you are not missing a binding redirect
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
https://www.microsoft.com/en-us/download/details.aspx?id=56041
Download from here if this needs to be installed in your machine

Azure Emulator - Could not load file or assembly

All.
I've got Azure SDK 1.7 installed.
All the assemblies in the solution are compiled with 'Any CPU' set up. But one of them fails when i start the solution in Azure emulator on my machine.
The error is very strange: "Could not load file or assembly 'XXX' or one of its dependencies. is not a valid Win32 application."
It becomes more complicated to find the reason, cause on the other machine everything works fine. Also I have no error when deploy it to Azure environment.
Tried to start emulator using IIS Express 8 and full IIS. Also tried to enable 32bit apps support when hosted under full IIS. Converted project to use 1.8 SDK.
But with no success.
Here is also some info from Visual Studio General output. Seems, here is the reason for the issue.
Windows Azure Tools: Warning: Unable to delete file fr000001.xml.
Windows Azure Tools: Warning: Unable to delete file fr000002.xml.
Windows Azure Tools: Warning: Unable to delete file fr000001.xml.
Windows Azure Tools: Warning: Unable to delete file fr000002.xml.
Windows Azure Tools: Warning: Unable to delete file fr000001.xml.
Windows Azure Tools: Warning: Unable to delete file fr000002.xml.
Windows Azure Tools: Warning: Unable to delete file fr000001.xml.
Windows Azure Tools: Warning: Unable to delete file fr000002.xml.
Windows Azure Tools: Warning: Unable to delete directory deployment17(397)
Couldn't find the process that can create such behavior. Of course, tried to restart my machine and to remove all the readonly properties from project files.
Will be glad to see any possible solution.
Thanks in advance.
Ok. I've found the source of problem.
When installed RedGate .NET Reflector, it created environment variable with name DEVPATH.
It's value is: "C:\ProgramData\Red Gate.NET Reflector\DevPath"
I've looked through this path and found there obsolete dll for my project. As result, it searched for the reference as it performs with GAC and always found incorrect one.
Removed and everything works.

Error doing web.config transformation for different environments

I was trying to deploy my app into different environments then i started following this how to:
Deploying an ASP.NET Web Application to a Hosting Provider using Visual Studio or Visual Web Developer: Web.Config File Transformations - 3 of 12
was perfect until I clicked in Preview Transform, I received this error:
Microsoft Visual Studio
Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
(I created just one transformation Web.DebugQA.config and of course the default ones, debug and release)
my Web.DebugQA.config looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
</system.web>
<appSettings>
<add key="EnvironmentName" value="QADev" xdt:Transform="SetAttributes(value)"
xdt:Locator="Match(key)" />
</appSettings>
</configuration>
but then I install this plugin:
SlowCheetah - XML Transforms
and I solved my preview transform error, but then when I was trying to publish using the QADev transform I got this error:
The "ImportParametersFile" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Web.Publishing.Tasks.ImportParametersFile.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I'm using Visual Studio Pro 2012.
I fixed this by repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012" from Control Panel --> Programs and Features.
The file Microsoft.Web.XmlTransform.dll was missing from the path C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web.
I had a similar error, although it was caused for different reasons.
I solved it copying the following DLL from another PC with VS2012 installed:
Microsoft.Web.XmlTransforms.dll
from: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
I hope this helps
I had same problem in VS2012, could not 'Preview Transform' for the PublishPackage tranforms e.g. Web.Staging.config complaining about Microsoft.Web.XmlTransform
I got it working by adding the Package https://nuget.org/packages/Microsoft.Web.Xdt to my Mvc 4.5 project. This package is still in pre release.
PM> Install-Package Microsoft.Web.Xdt -Pre
This package contains the Microsoft.Web.XmlTransform.dll
I still get an error during building complaining about "Could not load file or assembly Microsoft.Web.XmlTransform". The Mvc project has still built ok.
I did try adding the Microsoft.Web.XmlTransform.dll to the Gac using the gacutil but that did not fix the problem.
However I use Team Foundation Service build server and it works and creates the correct Web.config after applying the Web.Release.config and then the Web.Staging.config.
I tried below two things but it did not work for me.
1) copying the Microsoft.Web.XmlTransforms.dll DLL to location C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
2) And repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012"
Then I uninstalled Microsoft Azure tool V2.6 from control panel -> Programs and Features. And then I can able to publish my site.
This may have been fixed in Visual Studio 2012 Update 2 (and Visual Studio 2013).
Web.config "Preview Transform" gives an error
...
Posted by Microsoft on 3/1/2013 at 2:46 PM
Thanks for reporting the issue! It will be fixed in Visual Studio 2012 Update 2. Please install it when it becomes available.

Resources