Last post Oct 10, 2018 08:58 AM by Edward Z
Oct 03, 2018 05:22 AM|DilushiF|LINK
I'm getting below error in log file when trying to start the .Net Core API application deployed on IIS. Tried many workarounds according to many posts (configuration changes in IIS, etc) but still couldn't resolve this issue. Specially tried to add logs
to find specific missing dlls using this link, related to .Net Core ReflectionTypeLoadException in ASP.NET Core MVC application
But it didn't log any specific log message related to this exception. Only the above mentioned error is there in the log.
This is a .Net Core API application (Net Core 2.0 with Visual Studio 2017). Deployed on IIS in both Windows 10 & Windows Server 2012 R2. Same error is there in log file.
Main issue I found here is: this project has added a reference to a SOAP service (asmx service). When this service reference is removed, no such error. Seems the application is trying to get relevant dlls from some where else, instead of getting from published
folder. May be from GAC. But copied the dlls related to "system.servicemodel.*" to GAC as well (these are the automatically added dlls (from Nuget) when adding that service reference via Connected Services in Visual Studio).
This happens only after deployed (on IIS). When runing this application from source code, this works fine. No such error. I'm not sure if these new version of .Net Core doesn't support asmx services after deployed.
Appreciate any help to resolve this issue, as we need that asmx service reference in this project. Thank you.
2018-10-01T10:10:42.6383743+01:00 0HLH7FMNJ4U50:00000002 [ERR] Connection id ""0HLH7FMNJ4U50"", Request id ""0HLH7FMNJ4U50:00000002"": An unhandled exception was thrown by the application. (560e7d32) System.Reflection.ReflectionTypeLoadException: Unable
to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeAssembly.get_DefinedTypes() at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable1
parts, ControllerFeature feature) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.GetControllerTypes() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.BuildModel()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.GetDescriptors() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context) at Microsoft.AspNetCore.Mvc.Internal.ActionDescriptorCollectionProvider.UpdateCollection()
at Microsoft.AspNetCore.Mvc.Internal.ActionDescriptorCollectionProvider.get_ActionDescriptors() at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.GetTreeRouter() at Microsoft.AspNetCore.Mvc.Internal.AttributeRoute.RouteAsync(RouteContext context) at Microsoft.AspNetCore.Routing.RouteCollection.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame1.d__2.MoveNext()
2018-10-01T10:10:42.6385488+01:00 0HLH7FMNJ4U50:00000002 [INF] Request finished in 11.3774ms 500 (791a596a)
Oct 04, 2018 06:38 AM|Xing Zou|LINK
Have your tried to set Copy Local as true of the asmx service (Right click the service in Dependencies -> Properities) as this link suggested:
Also,you could use below code to determine what is missing:
//The code that causes the error goes here.
catch (ReflectionTypeLoadException ex)
StringBuilder sb = new StringBuilder();
foreach (Exception exSub in ex.LoaderExceptions)
FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
if (exFileNotFound != null)
string errorMessage = sb.ToString();
//Display or log the error based on your application.
Oct 04, 2018 07:48 AM|DilushiF|LINK
Thank you very much @Xing for your reply.
According to the link I have mentioned above (https://stackoverflow.com/questions/46124858/reflectiontypeloadexception-in-asp-net-core-mvc-application),
I added codes to log specific error message (similar to your code). But no any specific log messages were created. Only the same System.Reflection.ReflectionTypeLoadException error was there.
I tried copy local option as well. As no Copy local option in .Net Core, I added it manually in project file by editing the xml.
<None Update="System.ServiceModel.*"> (specific dlls)
But same. Because those dlls are already there in relevant folders. But seems it's trying to get those specific dlls related to asmx service (system.servicemodel.*) from some where else. So I copied those dlls into GAC as well. But the issue is same.
Oct 09, 2018 05:38 AM|Edward Z|LINK
To check whether it is related with the specific asmx serivce, could you create a new simple asmx service without changing anything, and then try to consume it from .net core, will you hit this error again?
I fail to reproduce your issue with a simple asmx serivce.
It would be helpful if you could share us detail steps to reproduce your issue.
Oct 09, 2018 10:49 AM|DilushiF|LINK
Hi @Edward Z,
Thank you for your reply.
This happens for our specific service as well as a sample service I created.
I have uploaded a sample project here: https://github.com/dilushi/NetCoreAndASMX
Oct 10, 2018 08:58 AM|Edward Z|LINK
I fail to reproduce your issue under Windows 10.
I suggest you install "Development time IIS support" under ".NET Core cross-platform development" in Visual Studio Installer, and then try to debug your project with IIS.