Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App framework .NET 4.5.1 fails to run after installing Microsoft .NET Framework 4.7.1 update on Windows Server 2012 (KB4033369) #601

Closed
jprr773 opened this issue Jan 15, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@jprr773
Copy link

commented Jan 15, 2018

Hi,

After installing the Microsoft .NET Framework 4.7.1 for Windows 8.1 and Windows Server 2012 R2 for x64 (KB4033369) the application failed to launch.

The app is an asp.net mvc project on .net framework 4.5.1. is mantained and compiled using VS2015, framework version DNX 4.5.1.

The app is running under Kestrel. The App is launched using web command in the approot folder.

I have never updated the app to the latest framework, because it's a production huge app ,and at this time I'm not sure that all the code will work , specially connecting to other 3rd party platforms.

Error messages from the app console:

Application startup exception: System.IO.FileLoadException: Could not load file or assembly 'Metrocal' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
File name: 'Metrocal' ---> Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException: C:\inetpub\wwwroot\metrocal\approot\src\Metrocal\Startup.cs(43,31): DNX,Version=v4.5.1 error CS0104: 'ConfigurationBuilder' is an ambiguous reference between 'Microsoft.Extensions.Configuration.ConfigurationBuilder' and 'System.Configuration.ConfigurationBuilder'
   at Microsoft.Dnx.Compilation.CSharp.RoslynProjectReference.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
   at Microsoft.Dnx.Compilation.CompilationEngine.LoadProject(Project project, FrameworkName targetFramework, String aspect, IAssemblyLoadContext loadContext, AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
   at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String startupAssemblyName, IList`1 diagnosticMessages)
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup()
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices()
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()

This is part of the code Startup.cs:

public static IConfigurationRoot Configuration;

public Startup(IApplicationEnvironment appEnv, IHostingEnvironment env)
        {

          
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json", optional: true)
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true)
                .AddEnvironmentVariables();
   
           ...
       

I use a config.json file for development and another for production.

I never had issues until I installed the Microsoft .NET Framework 4.7.1 update.

If I open the app url using the browser I get an «500 internal server error».

The workaround I did was to uninstall the Microsoft .NET Framework 4.7.1 ( KB4033369) Windows update.

Some help would be great.
Kind regards

@Eilon

This comment has been minimized.

Copy link
Member

commented Jan 19, 2018

Hi @jprr773 , it looks like this app is using the never-released DNX. Because DNX never shipped, it is not supported. We highly recommend that applications use the supported .NET Core platform, which uses the .NET Core CLI and SDK.

Here are some relevant links:

@jprr773

This comment has been minimized.

Copy link
Author

commented Jan 19, 2018

Hi @Eilon ,

thank for the time and comment.

The app is build like this:
dnu publish -o appname --runtime dnx-clr-win-x64.1.0.0-rc1-final

... is there any supported DNX compatible with MVC 6 and EF 7?

At some point, I'l have to migrate the app, but for now, it's too complex , too many 3rd party integrations.

There must be a way to solve this out, I mean the error indicates somehow a DLL method name conflict between the two DLL's:

DNX,Version=v4.5.1 error CS0104: 'ConfigurationBuilder' is an ambiguous reference between 'Microsoft.Extensions.Configuration.ConfigurationBuilder' and 'System.Configuration.ConfigurationBuilder'.

There must be some way to solve this without having to migrate the whole app...
Thank you

@Eilon

This comment has been minimized.

Copy link
Member

commented Jan 19, 2018

@jprr773 sorry, no versions of DNX are supported at all. This includes DNU, DNVM, MVC 6 (which later became ASP.NET Core MVC 1), and EF7 (which later became EF Core 1).

I highly recommend upgrading to .NET Core, ideally 2.0.x (latest patch version).

@Eilon

This comment has been minimized.

Copy link
Member

commented Jan 19, 2018

Regarding this error:

DNX,Version=v4.5.1 error CS0104: 'ConfigurationBuilder' is an ambiguous reference between 'Microsoft.Extensions.Configuration.ConfigurationBuilder' and 'System.Configuration.ConfigurationBuilder'.

You need to check the using statements in the CS file that has that error and remove one of the using statements.

@jprr773

This comment has been minimized.

Copy link
Author

commented Jan 22, 2018

Hi @Eilon

thanks again for your time and comments.

Just for the record and if someone has the same issue, these were the steps I made to get the application running on the server, with update 4.7.1 :

modded Startup.cs (added namespace alias):
``
using System;
using Microsoft.Extensions.Configuration;
using ConfiguracaoAplicacao = Microsoft.Extensions.Configuration;
using ConfiguracaoAplicacaoBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;

public static ConfiguracaoAplicacao.IConfigurationRoot AppConfiguration;

        var builder = new ConfiguracaoAplicacaoBuilder()
            .SetBasePath(appEnv.ApplicationBasePath)
            .AddJsonFile("config.json", optional: true)
            .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true)
            .AddEnvironmentVariables();

        AppConfiguration = builder.Build();

Added line below to project.json:

"Microsoft.Extensions.Configuration": "1.0.0-rc1-final",

Rebuild the application & deploy to server, it's all working now.
Kinds regards,

Joao

@jprr773 jprr773 closed this Jan 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.