Could not load file or assembly 'msshrtmi' - when publishing Windows Azure Websites - azure

I'm having an issue as below:
Could not load file or assembly 'msshrtmi, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'msshrtmi, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'msshrtmi, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
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].
The issue happens only when publishing to Windows Azure Websites (WAWS). I want to detect whether I am running in Windows Azure mode or not. Is this possible in WAWS? This error is happening only when I call Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.IsAvailable.
I'd assume that the WAWS environment would have the Azure SDK installed, right? Or is this only available for Cloud services?
I've looked at some solutions telling you to manually include it in x64 or x86 version, but I would like not to be limited that way, or similar workarounds.

I encountered this same error when publishing a Web App. After trying every other solution on the web, the following finally worked for me:
In the Azure Portal, select your Web App. Select 'Settings > Application settings'. Change the Platform value from 32-bit to 64-bit. Re-publish.

Related

Azure Functions ScriptHost initialization failed error

I'm attempting to write a simple Azure Function app and I want to reference some other existing projects in my VS 2017 solution. These other projects have a reference to some custom logging code which in turn references the Nuget packages Microsoft.Extensions.Logging, Microsoft.Extensions.Logging.Console and Microsoft.Extensions.Logging.Debug.
When I start my functions app in VS2017, I get the following error:
[3/21/2018 5:42:12 PM] ScriptHost initialization failed
[3/21/2018 5:42:12 PM] System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
It doesn't matter whether I directly reference the above three Nuget packages in my Functions project or not. I'm using the 1.0.9 version of Azure Functions.
I've posted a highly simplified example of a project showing this error in a GitHub repo here: https://github.com/chriswill/FunctionDemo
Thanks for reporting. Issue is being tracked here

Stackify NLog intermittent logging

We have an application where we have several Azure WebJobs set up, and we have NLog set up to report on the entry and exit of those webjobs. We have NLog hooked into Stackify so that we can use the Stackify logger to watch things move from WebJob to WebJob. The logging works (so we know the configuration is OK). The problem we are hitting is that the logging is intermittent - we have independent confirmation of messages travelling along several WebJobs, but we will only get partial logging. For example, the first log will record that a message was read off of it, but won't show the exit message. The next log will show the entry and exit. The problem is that they all leverage the exact same code, so the same log message should appear every single time. Has anyone else encountered this issue before? Before you answer, we have taken these diagnostic steps:
(1) We have verified the proper configuration settings in all webjob config files.
(2) We have verified that all of the webjob config files are properly posted in Azure.
(3) We have independently verified (via the webjob consoles in Azure) that the messages are getting to the different webjobs, processing, and then moving on to the next webjob, meaning that they would be invoking the logging code.
(4) We have verified that our Stackify log data is not being throttled (this might have made sense if the logs had simply stopped - but the fact that we just get partial logging in some cases and full logging in others during a single message transmission makes this unlikely).
(5) We have pored over the Stackify documentation, which seems to ensure that configuration is set up properly so that you get logging at all. It covers the all-or-nothing scenario, but not the some scenario.
I will be happy to provide more clarification as needed.
We discovered what is going on, and it is rather strange. The issue ended up being with our use of NLog.Targets.Stackify. We were using version 1.25.4. When I ran a test using the NLog debugger suggested by Julian, this is what showed up:
2017-01-09 10:14:43.5079 Info Loading assembly name: NLog.Targets.Stackify
2017-01-09 10:14:43.5449 Debug ScanAssembly('NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c')
2017-01-09 10:14:43.5929 Debug Start auto loading, location: C:\Dev\AffinityMain\platform\Integrity.WebJob.Rating\bin\Debug
2017-01-09 10:14:43.5929 Info Auto loading assembly file: C:\Dev\AffinityMain\platform\Integrity.WebJob.Rating\bin\Debug\NLog.Targets.Stackify.dll
2017-01-09 10:14:43.6039 Info NLog.Targets.Stackify, Version=1.18.6200.39247, Culture=neutral, PublicKeyToken=null. File version: 1.18.*. Product version: 1.25.4.
2017-01-09 10:14:43.6039 Debug ScanAssembly('NLog.Targets.Stackify, Version=1.18.6200.39247, Culture=neutral, PublicKeyToken=null')
2017-01-09 10:14:43.6249 Warn Type load exception. Exception: System.IO.FileLoadException: Could not load file or assembly 'NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'
This was followed shortly by this error when it was parsing the config:
System.ArgumentException: Target cannot be found: 'StackifyTarget'
The documentation indicates that version 4.4 of NLog is sufficient to run this library. However, the NLog debugger indicates that it is looking for version 5.0, and not finding it (which it wouldn't because we aren't using it). Now, what makes this strange is that it did work at one time, with this version, so somehow a reference to NLog 5.0 is stuck somewhere in the system, but we can't find it because everything in our solution is running NLog 4.4. We've checked the csproj, the packages config, the app config, the actual installed nuget packages - no reference to version 5.0.
The answer to the problem was to downgrade to 1.25.3. As soon as I did that, it worked. I then tried to bump it back to 1.25.4, and had the same problem again. Matt - to your point about Shutdown - we are going to add that to our webjobs, and then I will monitor to see if we are seeing complete logs. Thank you everyone for your suggestions!
You should be able to fix this problem by adding one line of code at the end of your application to StackifyLib to flush.
StackifyLib.Logger.Shutdown();
https://github.com/stackify/stackify-api-dotnet/blob/master/README.md
I hope this fixes it for you, if not, please contact Stackify support.
Could be nice with an example of the NLog-config. If using the async-wrapper, then by default the overflow action is to discard "random" messages.

Error when trying to debug. VS2012 gives error

I am trying to debug my application. It was working fine but now I get the below error.
An unhandled exception of type 'System.InvalidOperationException' occurred in PizzaPosManagement.exe
Additional information: An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'PIzzaPOS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
If there is a handler for this exception, the program may be safely continued.
If I change it to Release mode and compile it, it works fine and the application will run. It has to be a setting but I don't know what.

CRM 2013 Change DB Owner

When you install CRM 2013 on-premise it sets the DB Owner of the databases to the installation account. Is it supported to change the DB Owner after the install is finished and if so what are the required permissions?
We've done it multiple times in our Dev and QA environments when they get a refresh from Prod. By default the owner of the DB is in a domain that doesn't exist, and so we get errors like this:
Exception: System.Data.SqlClient.SqlException (0x80131904): An error
occurred in the Microsoft .NET Framework while trying to load assembly
id 65536. The server may be running out of resources, or the assembly
may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE.
Run the query again, or check documentation to see how to solve the
assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly
'microsoft.crm.sqlclr.helper, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. An error
relating to security occurred.
I can't speak to the actual rights but this is the query we've ran:
ALTER DATABASE Contoso_MSCRM SET TRUSTWORTHY ON
USE Contoso_MSCRM
GO
EXEC sp_changedbowner 'dev\crmdv2administrator'

Dynamics CRM - Stamp out new Org, Build / Deploy Plugins all from MSBUILD - Issues

I'm getting a run time exception in my deployed, exported, and then imported to another box... CRM Solution. The Exception is:
System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
It only occurs when I use a MSBUILD script to do this. When I use VS (2010) by hand to do this, all is well. So, first suspect is my script. My script uses a MSBUILD custom task, inspired by http://fczaja.blogspot.com/2012/07/continuous-integration-with-crm.html.
My sense is the issue could be on the Export step - which uses the Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy, up-cast to IOrganizationService.Execute, passing an ExportSolutionRequest object. We set the SolutionName and Managed properties only. Perhaps we're missing another property?
I'm trying to narrow it's root cause.
Are you by any chance using ILMerge on your plugin assembly?
If so I suspect it is an issue with your reference assemblies, perhaps having .NET 4.5 on the build server but not on the machine where you build it manually.
These links will explain futher if this is indeed the case:
http://www.mattwrock.com/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx
The fundamental fix is to change your ILMerge reference assemblies to be -/targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0"

Resources