locked
Consuming ASMX service in .Net Core API: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types RRS feed

  • Question

  • 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

    • Created a ExceptionCatchMiddleware extension class.
    • Added it in Configure() method in Startup.cs:

    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)

    Thank you.

    • Moved by CoolDadTx Tuesday, October 2, 2018 2:30 PM ASP.NET related
    Tuesday, October 2, 2018 12:24 PM

All replies

  • 64-bit Dll on 32-bit server?

    Or opposit

    32-bit DLL on 64-bit server with disabled 32-bit support? 


    Sincerely, Highly skilled coding monkey.

    Tuesday, October 2, 2018 1:18 PM
  • ASP.NET Core is at the ASP.NET forums.

    http://forums.asp.net/

    Tuesday, October 2, 2018 1:27 PM
  • hi @Andrey.

    Platform target -> Any CPU.

    Environment is Windows 2012 R2 64 bit.

    I set the 32 bit application True in Application pool as well. But same.

    Appreciate any workaround to resolve this.

    Thank you.

    Wednesday, October 3, 2018 5:11 AM
  • Some time AnyCPU didn't work and require specific x32 or x64. 

    Try 

    Dependency Walker

    to figure out where is a DLL which prevent loading.


    Sincerely, Highly skilled coding monkey.

    Wednesday, October 3, 2018 7:41 AM