Windows Azure Error - Could not load file or assembly MFCMIFC80 - angularjs

I have created an Angular/WebAPI/MongoDb project and using StructureMap for dependency injection and I have it published to a private BitBucket account.
I have create an Azure Webapp and set it up to auto deploy whenever I commit a change to my BitBucket repo.
When I run it locally (from Visual Studio) my main page is:
http://localhost:37071/index.html#/
It makes API calls to http://localhost:37071/api/stock?stkSymbol=ORCL successfully.
However, when it is deployed, my page loads successfully at: http://myAzureProject.azurewebsites.net/index.html#/
However, all API calls to: http://myAzureProject.azurewebsites.net/api/stock?stkSymbol=ORCL
Fail with this error message:
Server Error in '/' Application.
Could not load file or assembly 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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].
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
System.Reflection.RuntimeAssembly.GetExportedTypes() +21
StructureMap.Graph.TypePool.<.ctor>b__0(Assembly assembly) +10
StructureMap.Util.LightweightCache`2.get_Item(TKey key) +65
StructureMap.Graph.<>c__DisplayClass3.<For>b__2(Assembly x) +37
System.Linq.<SelectManyIterator>d__14`2.MoveNext() +232
StructureMap.StringExtensions.Each(IEnumerable`1 enumerable, Action`1 action) +140
StructureMap.Graph.AssemblyScanner.ScanForTypes(TypePool types, PluginGraph pluginGraph) +128
StructureMap.<>c__DisplayClass2.<RunConfigurations>b__1(AssemblyScanner x) +21
StructureMap.StringExtensions.Each(IEnumerable`1 enumerable, Action`1 action) +131
StructureMap.PluginGraphBuilder.RunConfigurations() +143
StructureMap.PluginGraphBuilder.Build() +13
StructureMap.PipelineGraph.For(Action`1 action) +49
myAzureProject.DependencyResolution.IoC.Initialize() +82
myAzureProject.App_Start.StructuremapMvc.Start() +10
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +155
WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +57
WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +350
WebActivatorEx.ActivationManager.Run() +78
[InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +547
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521
[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36215
I'm not familiar with what MFCMIFC80 is or what I need to do in order to be able to get it deployed to my Azure web app.
Any help would be appreciated.
Thanks!

MFCMIFC80.dll is an MFC library (https://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library). It most probably is a requirement for your MongoDB drivers. As I do not recall any dependency on MFC for regular Web API als using AngularJS.
You cannot deploy MFC on Azure Web Apps (former Web Sites).
Look for alternative MongoDB drivers which do not have dependencies on MFC.
Another reason for this error could be that in your project you refernece .NET 2.0 assemblies, while your main project targets .NET 4.0. Which may be the case with the MongoDB driver indeed (it may be only compiled against .NET 2.0 and it would cause the issues).
So go through all of your referneces (incl. StructureMap and MongoDB drivers) to make sure that all your refenreced assemblies are targetinng .NET 4.0 and not .NET 2.0.
Note that although .NET 4.0 actually runs in the .NET 2.0 Runtime environment, there still might be issues when referencing .NET 2.0 assemblies from a .NET 4.0 targeted project.

Finally figured it out. In my solution, I have one line to tell structuremap to scan for assemblies from path.
scan.AssembliesFromPath(Environment.CurrentDirectory);
Removing this line resolves the issue.

Related

PostgreSQL connection issue from LLBLGen via Npgsql

We are trying to configure connection to PostgreSQL database (version 9.4.9) in LLBLGen Pro v 5.9.2 but we have following error:
Exception information.
LLBLGen Pro version: v5.9. Build: 5.9.2
Exception details:
Message: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Source: Npgsql Stack trace: at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.g__OpenLong|0() at Npgsql.NpgsqlConnection.Open(Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlConnection.Open() at SD.LLBLGen.Pro.Gui.Controls.WizardPages.MetaDataRetrievalWizard_Step_ConnectionData.TestConnectionData(Boolean showSuccess)
Inner exception:
stack trace: LLBLGen Pro version 5.9. Build 5.9.2 -----[Core exception]-------------------- at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.g__OpenLong|0() at Npgsql.NpgsqlConnection.Open(Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlConnection.Open() at SD.LLBLGen.Pro.Gui.Controls.WizardPages.MetaDataRetrievalWizard_Step_ConnectionData.TestConnectionData(Boolean showSuccess)
Please advise.
Many thanks.

SSIS execution and deployment error "System.IO.FileLoadException: Could not load file or assembly"

I've a few SSIS deployed to SQL 2012 since last year, all up and running without any issue. This error started to prompt
A .NET Framework error occurred during execution of user-defined routine or aggregate "set_system_informations":
System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection'
threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The paging file is too small for this operation to complete. (Exception from HRESULT: 0x800705AF)
System.IO.FileLoadException:
at System.Data.SqlClient.SqlConnection..cctor()
System.TypeInitializationException:
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Microsoft.SqlServer.IntegrationServices.Server.SystemInformations.SetSystemInformations(SqlInt64 operationId)
. Source: .Net SqlClient Data Provider
It just failed to run, I tried to deploy again to SQL and similar error appear as follows
A .NET Framework error occurred during execution of user-defined routine or aggregate "deploy_project_internal":
System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection'
threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The paging file is too small for this operation to complete. (Exception from HRESULT: 0x800705AF)
System.IO.FileLoadException:
at System.Data.SqlClient.SqlConnection..cctor()
System.TypeInitializationException:
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Microsoft.SqlServer.IntegrationServices.Server.ServerConnectionControl.GetOperationInfo(SqlInt64 operation_id, OperationType type, ServerOperationStatus status, Int64& object_id)
at Microsoft.SqlServer.IntegrationServices.Server.ServerConnectionControl.checkParameters(SqlInt64 object_id, SqlInt64 operation_id, OperationType type)
at Microsoft.SqlServer.IntegrationServices.Server.ServerApi.DeployProjectInternal(SqlInt64 deployId, SqlInt64 versionId, SqlInt64 projectId, SqlString projectName)
. (.Net SqlClient Data Provider)
I've no problem to run the SSIS from the VS2017(SSDT) directly, just can't deploy and get it run on server. I'm not sure what is the root cause of this, all running fine yesterday and start throwing error today.
Anyone encounter this issue before?
You might have referenced a different version of System.Configuration. It could be added as a dependency by another library. It is possible that the version number has jumped during this time and you are referencing older versions. Anyway, you can overwrite the version in your csproj.

Error Loading Self Signed Certificate on Azure App Service with linux container with IdentityServer 4 AddSigningCredential

I have my asp.net core 3.1 app configured to use identity server 4. Everything works fine in my local machine and in my local IIS. If I publish to Azure App Service, the certificate loading fails with the below error:
2020-04-05T02:01:46.200965138Z Documentation: http://aka.ms/webapp-linux
2020-04-05T02:01:46.200972938Z Dotnet quickstart: https://aka.ms/dotnet-qs
2020-04-05T02:01:46.200980839Z ASP .NETCore Version: 3.1.0
2020-04-05T02:01:46.200988739Z Note: Any data outside '/home' is not persisted
2020-04-05T02:01:46.624585930Z Running oryx -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand ''
2020-04-05T02:01:46.758919856Z Oryx Version: 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
2020-04-05T02:01:46.769077531Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-04-05T02:01:46.770324503Z Could not find operation ID in manifest. Generating an operation id...
2020-04-05T02:01:46.771110686Z Build Operation ID: 2c1fda2a-9303-49d7-8d96-2fd6b961de83
2020-04-05T02:01:48.583605155Z Writing output script to '/opt/startup/startup.sh'
2020-04-05T02:01:48.934026596Z Trying to find the startup DLL name...
2020-04-05T02:01:48.934770080Z Found the startup D name: IDP.dll
2020-04-05T02:01:48.935266269Z Running the command: dotnet "IDP.dll"
2020-04-05T02:01:50.341053110Z [02:01:50 Information]
2020-04-05T02:01:50.341106512Z Starting host...
2020-04-05T02:01:50.341118212Z
2020-04-05T02:01:52.133020171Z [02:01:52 Fatal]
2020-04-05T02:01:52.133081573Z Host terminated unexpectedly.
2020-04-05T02:01:52.133093173Z Interop+Crypto+OpenSslCryptographicException: error:2006D002:BIO routines:BIO_new_file:system lib
2020-04-05T02:01:52.133102374Z at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)
2020-04-05T02:01:52.134995630Z at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
2020-04-05T02:01:52.135015331Z at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
2020-04-05T02:01:52.135025731Z at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
2020-04-05T02:01:52.135048232Z at IDP.Startup.ConfigureServices(IServiceCollection services) in C:\Users\xxxx\IDP\Startup.cs:line 47
2020-04-05T02:01:52.135072332Z at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
2020-04-05T02:01:52.140072381Z at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2020-04-05T02:01:52.140095582Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
2020-04-05T02:01:52.140545195Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
2020-04-05T02:01:52.140562795Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
2020-04-05T02:01:52.140572496Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
2020-04-05T02:01:52.140919606Z at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
2020-04-05T02:01:52.140980508Z at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
2020-04-05T02:01:52.141103111Z at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
2020-04-05T02:01:52.141119512Z at Microsoft.Extensions.Hosting.HostBuilder.Build()
2020-04-05T02:01:52.141498823Z at IDP.Program.Main(String[] args) in C:\Users\xxxx\IDP\Program.cs:line 37
2020-04-05T02:01:52.141564625Z
2020-04-05 02:01:53.668 ERROR - Container xxxxidp_0_bb9e5be5 for site xxxxidp has exited, failing site start
2020-04-05 02:01:53.676 ERROR - Container xxxxidp_0_bb9e5be5 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2020-04-05 02:01:53.693 INFO - Stoping site xxxxidp because it failed during startup.
Status_WatchFile :: Error Error: ENOENT: no such file or directory, open '/appsvctmp/status.txt'
Here is my configure services in startup:
builder.AddSigningCredential(new X509Certificate2($"{Environment.ContentRootPath}\\Certificate\\my certificate.pfx", Configuration.GetValue<string>("CertificatePassword")));
Here is my certificate in my project folder structure,
Please assist if I'm doing something wrong. Trying for more than a day and not able to figure where I'm going wrong.
After almost weeks and analyzing all possibilities, I figured out where I went wrong. It is the \ that is causing trouble. I have certificate added in my application. The below line works with windows machine,
builder.AddSigningCredential(new X509Certificate2($"{Environment.ContentRootPath}\\Certificate\\my certificate.pfx", Configuration.GetValue<string>("CertificatePassword")));
However I understood that \ doesn't work in linux when it comes to path. So I replaced the \ to forward slash / and it worked in both windows and linux.
builder.AddSigningCredential(new X509Certificate2($"{Environment.ContentRootPath}/Certificate/my certificate.pfx", Configuration.GetValue<string>("CertificatePassword")));
Hope this really helps some one.

Deploying to Azure causes fatal error

I am attempting to publish my demo IdentityServer4 app to Azure web app service for testing.
Everything works beautifully including the app load.
However, no logs are being generated so i got suspicious and checked the diagnostics and found this:
2018-02-28 08:54:21.626 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Internal.WebHost: Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureKeyVault.HostingStartup failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureKeyVault.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
Not only are logs not being generated, some of my actions don't work as they should. In this case ability to log in to identityserver4 (i built a custom storage).
Can anyone decipher what i am doing wrong here? Not sure where to start looking.
It looks like you're missing the Microsoft.AspNetCore.AzureKeyVault.HostingStartup assembly.
Can you check that it's definitely part of your deployment package?
The issue seems to relate to the way Azure Web App Service operates.
For some reason or other it is making a call to this assembly for unknown function.
Unfortunately Asp Net Core 2.0 doesn't have this assembly as part of any packages, and from looks of it it doesn't exists in any pre 2.1 libraries.
The solution was to do a dirty installation of the package:
dotnet add package Microsoft.AspNetCore.AzureKeyVault.HostingStartup --version 2.1.0-preview1-27946 --source https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
This essentially deployed the package which wasn't compatible with ASP CORE 2.0, but when published to Azure was picked up, eliminating the problem once and for all.
On that note this package will be part of the Microsot.AspNetCore.All 2.1 that is coming up soon.

Silverlight application broken with FileNotFoundException in System.Windows.Controls

I've been working on converting a Silverlight project from Silverlight 2 to Silverlight 3. Note that I've never had SL 2 binaries or development components installed on my machine (it's only a month old).
This has been going fine and the app was running until I started getting a build error with ValidateXaml raising a FileNotFoundException in System.Core. I don't know why this suddenly started happening but from some searching around the answer seemed to be putting various Silverlight DLLs in the GAC. This did indeed solve the build errors. I didn't try testing to check if the app ran correctly after that.
Some time later I'm trying to run the app again. Now I'm getting yet another FileNotFoundException, this time in System.Windows.Controls. I've tried removing all Silverlight DLLs from the GAC and adding them back in again without any success. Here's the stack trace:
Message: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at MyNamespace.Page.InitializeComponent()
at MyNamespace.Page..ctor()
at MyNamespace.App.Application_Startup(Object sender, StartupEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
This entire experience has been very frustrating and I'd love to know what is causing these problems and how to fix them?
Have you tried the fusion log viewer? In a VS command shell, fuslogvw.exe, set it to show bind errors in options, clear out the log, run your app. Afterwards it will give you a detailed explanation why it could not load the assembly. fuslogvw has helped me here many times.
Do note the or one of its dependencies. That is key, it's rare that it's the assembly the exception is complaining about, it's often a dependency issue.
I have reinstalled the Silverlight runtime and all of the development components and the problem has now gone away.
I'm leaving this unanswered for now in case someone has some ideas on what caused this.

Resources