问:
ServiceStack captures HTTP 500 internal error from Kestrel?
I have a self-host app basing on ServiceStack.Core(v1.0.44),  the ServiceStack.AppSelfHostBase from ServiceStack.Kestrel(v1.0.44) internally relies on Kestrel http server to serve the requests.

The app works fine in my local machine. but it returns an ambiguous HTTP 500 error when it is compiled and deployed by our building server.

After investigating for hours, I found the reason is assembly redirection.  Because ServiceStack lazy loads the AspNetCore and other assemblies, there is no error generated on startup.  And the HTTP 500 error happens before my code execution when it is trying to load some assembly. There is no logs at all.

My quick fix is to include all the signed assemblies in the app.config file's assemblyBinding section.

```    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework.SqlServer" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.2.10.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Authentication.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Authentication.Core" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Diagnostics.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Diagnostics" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting.Server.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting.WindowsServices" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http.Extensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http.Features" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.HttpOverrides" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Routing.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Routing" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.IISIntegration" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Core" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Https" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.WebSockets" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.WebUtilities" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.Binder" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.CommandLine" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.EnvironmentVariables" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.FileExtensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.Json" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.UserSecrets" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.FileProviders.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.FileProviders.Physical" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.FileSystemGlobbing" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Hosting.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Console" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Debug" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Options.ConfigurationExtensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.IO.RecyclableMemoryStream" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.2.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Net.Http.Headers" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Win32.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.10.4.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="NewRelic.Api.Agent" publicKeyToken="06552fced0b33d87" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.18.139.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="10.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.3.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="ServiceStack.Interfaces" publicKeyToken="e06fbc6124f57c43" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.AppContext" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.2.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.0.106.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Data.SQLite.EF6" publicKeyToken="db937bc2d44ff139" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.0.106.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Data.SQLite.Linq" publicKeyToken="db937bc2d44ff139" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.0.106.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.1" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Diagnostics.Tracing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Globalization.Calendars" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.Compression.ZipFile" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Linq" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Linq.Expressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.2" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Net.Sockets" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.4.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Reflection.TypeExtensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.2.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.X509Certificates" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Text.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.0.0" />
  </dependentAssembly>
</assemblyBinding>
```

After adding all the assemblies's redirection, the problem is solved. But still I don't know which assemblies were causing this error.
My question is: How to capture this kind of error in ServiceStack when it failes to lazy-load the assemblies?

答:
ServiceStack isn't doing any lazy loading, .NET is naturally only going to load the dependencies when it runs code that uses those dependencies. If you use the dependencies in your AppHost Configure() it will force their use on Startup so you can do something like resolving a Service and executing a test request, e.g:

```<code>using (var service = container.TryResolve<MyServices>())
{
    var response = service.Any(new MyRequest());
}
</code>```

Body:
I have a self-host app basing on ServiceStack.Core(v1.0.44),  the ServiceStack.AppSelfHostBase from ServiceStack.Kestrel(v1.0.44) internally relies on Kestrel http server to serve the requests.

The app works fine in my local machine. but it returns an ambiguous HTTP 500 error when it is compiled and deployed by our building server.

After investigating for hours, I found the reason is assembly redirection.  Because ServiceStack lazy loads the AspNetCore and other assemblies, there is no error generated on startup.  And the HTTP 500 error happens before my code execution when it is trying to load some assembly. There is no logs at all.

My quick fix is to include all the signed assemblies in the app.config file's assemblyBinding section.

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework.SqlServer" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.2.10.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Authentication.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Authentication.Core" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Diagnostics.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Diagnostics" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting.Server.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Hosting.WindowsServices" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http.Extensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Http.Features" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.HttpOverrides" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Routing.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Routing" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.IISIntegration" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Core" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Https" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.WebSockets" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.AspNetCore.WebUtilities" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.Binder" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.CommandLine" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.EnvironmentVariables" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.FileExtensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.Json" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Configuration.UserSecrets" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.FileProviders.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.FileProviders.Physical" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.FileSystemGlobbing" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Hosting.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Console" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging.Debug" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Options.ConfigurationExtensions" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.IO.RecyclableMemoryStream" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.2.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Net.Http.Headers" publicKeyToken="adb9793829ddae60" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Win32.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.10.4.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="NewRelic.Api.Agent" publicKeyToken="06552fced0b33d87" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="6.18.139.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="10.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="2.3.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="ServiceStack.Interfaces" publicKeyToken="e06fbc6124f57c43" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.AppContext" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.2.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.0.106.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Data.SQLite.EF6" publicKeyToken="db937bc2d44ff139" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.0.106.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Data.SQLite.Linq" publicKeyToken="db937bc2d44ff139" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.0.106.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.1" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Diagnostics.Tracing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Globalization.Calendars" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.Compression.ZipFile" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Linq" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Linq.Expressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.2" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Net.Sockets" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="1.4.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Reflection.TypeExtensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.2.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Cryptography.X509Certificates" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.0.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Text.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.9.9.9" newVersion="4.1.0.0" />
  </dependentAssembly>
</assemblyBinding>

After adding all the assemblies's redirection, the problem is solved. But still I don't know which assemblies were causing this error.
My question is: How to capture this kind of error in ServiceStack when it failes to lazy-load the assemblies?

Body:
ServiceStack isn't doing any lazy loading, .NET is naturally only going to load the dependencies when it runs code that uses those dependencies. If you use the dependencies in your AppHost Configure() it will force their use on Startup so you can do something like resolving a Service and executing a test request, e.g:

using (var service = container.TryResolve<MyServices>())
{
    var response = service.Any(new MyRequest());
}


来源: stackexchange

问:
VBA Compare Cell Value in two different workbook
I am trying to compare two cell value in two different workbook. I debugged and find x.Range("A" & rw).Value = y.Range("N" & re).Value this part is not working. I also tried  assigning parameters and using Cells(rw, "A"), still not working. Can some one please help?

```<code>Option Explicit

Sub findcell()

Dim rw As Integer, re As Integer

Dim extwbk As Workbook, twb As Workbook
Dim x As Worksheet, y As Worksheet
Dim Rng As Range

Set twb = ThisWorkbook
Set extwbk = Workbooks.Open(".........xlsx")
Set x = twb.Worksheets("ABC")
Set y = extwbk.Worksheets("DEF")

    For rw = 2 To x.UsedRange.Columns("A").Rows.Count

      For re = 3 To y.UsedRange.Columns("N").Rows.Count

         If x.Range("A" & rw).Value = y.Range("N" & re).Value And x.Cells(rw, 1) <> Null Then
         ' If use below line, it is working
        'If x.Cells(rw, 1) = 45032 And y.Cells(re, 14) = 45032 Then
            MsgBox x.Cells(rw, 1).Value
            MsgBox y.Cells(re, 14).Value
         Exit For
         End If

      Next re

    Next rw

extwbk.Close savechanges:=False
End Sub
</code>```

答:
I agree with david that the problem might be

```<code>x.Cells(rw, 1) <> Null
</code>```

Instead try

```<code>Not IsEmpty(x.Cells(rw, 1))
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to compare two cell value in two different workbook. I debugged and find x.Range("A" & rw).Value = y.Range("N" & re).Value this part is not working. I also tried  assigning parameters and using Cells(rw, "A"), still not working. Can some one please help?

Option Explicit

Sub findcell()

Dim rw As Integer, re As Integer

Dim extwbk As Workbook, twb As Workbook
Dim x As Worksheet, y As Worksheet
Dim Rng As Range

Set twb = ThisWorkbook
Set extwbk = Workbooks.Open(".........xlsx")
Set x = twb.Worksheets("ABC")
Set y = extwbk.Worksheets("DEF")

    For rw = 2 To x.UsedRange.Columns("A").Rows.Count

      For re = 3 To y.UsedRange.Columns("N").Rows.Count

         If x.Range("A" & rw).Value = y.Range("N" & re).Value And x.Cells(rw, 1) <> Null Then
         ' If use below line, it is working
        'If x.Cells(rw, 1) = 45032 And y.Cells(re, 14) = 45032 Then
            MsgBox x.Cells(rw, 1).Value
            MsgBox y.Cells(re, 14).Value
         Exit For
         End If

      Next re

    Next rw

extwbk.Close savechanges:=False
End Sub

Body:
I agree with david that the problem might be

x.Cells(rw, 1) <> Null

Instead try

Not IsEmpty(x.Cells(rw, 1))


问:
how can I make a whole program a variable the first time its ran and make another variable the second time and compare them both?
Im doing a web scraping program at the moment and it scrapes an info table every 5 mins and thats it. It prints the same table over an over, but what I want to do is compare the first time its run and name that 'num1', and compare it to the next time its run to see if any updates has occurred to the table. We could label this 'num2', I think I would need to label the first output in the terminal and compare it to the second time etc. and do something like:

```<code>if num1 != num2:
    print("updated")
</code>```

but then I would need to compare 'num2' to 'num3' and so on....
Heres what I have so far:

```<code>import urllib
import urllib.request as request
import libxml2

totalurl = "https://www.icc-ccs.org/index.php/piracy-reporting-centre/live-piracy-report"
htmlfile = urllib.request.urlopen(totalurl)
htmltext = htmlfile.read()
source = html.fromstring(htmltext.decode())
num = source.xpath('//div[@class="fabrikDataContainer"]')
print(num[0].text_content())
</code>```

答:
Performing periodic comparison of scraping results

If you want to periodically execute the script using something like cron, then what you can do is save the scraping results to a text file and simply load the text file on the next execution to compare for changes.

```<code>import urllib
import urllib.request as request
import libxml2

totalurl = "https://www.icc-ccs.org/index.php/piracy-reporting-centre/live-piracy-report"
htmlfile = urllib.request.urlopen(totalurl)
htmltext = htmlfile.read()
source = html.fromstring(htmltext.decode())
num = source.xpath('//div[@class="fabrikDataContainer"]')
print(num[0].text_content())
with open('lastresult.txt', 'r+') as f:
    last_content = f.read()
    if num[0].text_content() != last_content:
        print("updated")
    # update last result file
    f.seek(0)
    f.write(num[0].text_content())
    f.truncate()
</code>```

Addressing encoding problems

The reason why the comparison between the new content and last content is always returning true would seem to be related to the encoding as encoding the strings before performing the comparison and saving to the file works. The correct file open modes are then ‘rb+’ and ‘wb’ since you are writing bytes to the file, not strings.

```<code>import os
import urllib
import urllib.request as request
#import libxml2
from lxml import html

totalurl = "https://www.icc-ccs.org/index.php/piracy-reporting-centre/live-piracy-report"
htmlfile = urllib.request.urlopen(totalurl)
htmltext = htmlfile.read()
source = html.fromstring(htmltext.decode())
num = source.xpath('//div[@class="fabrikDataContainer"]')
new_content = str.encode(num[0].text_content(), 'utf8')
# print(new_content.decode('utf8'))
if os.path.exists('lastresult.txt'):
    with open('lastresult.txt', 'rb+') as f:
        last_content = f.read()
        if new_content != last_content:
            print("updated")
        f.seek(0)
        f.write(new_content)
        f.truncate()
else:
    with open('lastresult.txt', 'wb') as f:
        f.write(new_content)
</code>```

Note: I switched to lxml so I did not have to install libxml2 for python3 which is not available from the standard Ubuntu 16.04 repositories.

Body:
Im doing a web scraping program at the moment and it scrapes an info table every 5 mins and thats it. It prints the same table over an over, but what I want to do is compare the first time its run and name that 'num1', and compare it to the next time its run to see if any updates has occurred to the table. We could label this 'num2', I think I would need to label the first output in the terminal and compare it to the second time etc. and do something like:

if num1 != num2:
    print("updated")

but then I would need to compare 'num2' to 'num3' and so on....
Heres what I have so far:

import urllib
import urllib.request as request
import libxml2

totalurl = "https://www.icc-ccs.org/index.php/piracy-reporting-centre/live-piracy-report"
htmlfile = urllib.request.urlopen(totalurl)
htmltext = htmlfile.read()
source = html.fromstring(htmltext.decode())
num = source.xpath('//div[@class="fabrikDataContainer"]')
print(num[0].text_content())

Body:
Performing periodic comparison of scraping results

If you want to periodically execute the script using something like cron, then what you can do is save the scraping results to a text file and simply load the text file on the next execution to compare for changes.

import urllib
import urllib.request as request
import libxml2

totalurl = "https://www.icc-ccs.org/index.php/piracy-reporting-centre/live-piracy-report"
htmlfile = urllib.request.urlopen(totalurl)
htmltext = htmlfile.read()
source = html.fromstring(htmltext.decode())
num = source.xpath('//div[@class="fabrikDataContainer"]')
print(num[0].text_content())
with open('lastresult.txt', 'r+') as f:
    last_content = f.read()
    if num[0].text_content() != last_content:
        print("updated")
    # update last result file
    f.seek(0)
    f.write(num[0].text_content())
    f.truncate()

Addressing encoding problems

The reason why the comparison between the new content and last content is always returning true would seem to be related to the encoding as encoding the strings before performing the comparison and saving to the file works. The correct file open modes are then ‘rb+’ and ‘wb’ since you are writing bytes to the file, not strings.

import os
import urllib
import urllib.request as request
#import libxml2
from lxml import html

totalurl = "https://www.icc-ccs.org/index.php/piracy-reporting-centre/live-piracy-report"
htmlfile = urllib.request.urlopen(totalurl)
htmltext = htmlfile.read()
source = html.fromstring(htmltext.decode())
num = source.xpath('//div[@class="fabrikDataContainer"]')
new_content = str.encode(num[0].text_content(), 'utf8')
# print(new_content.decode('utf8'))
if os.path.exists('lastresult.txt'):
    with open('lastresult.txt', 'rb+') as f:
        last_content = f.read()
        if new_content != last_content:
            print("updated")
        f.seek(0)
        f.write(new_content)
        f.truncate()
else:
    with open('lastresult.txt', 'wb') as f:
        f.write(new_content)

Note: I switched to lxml so I did not have to install libxml2 for python3 which is not available from the standard Ubuntu 16.04 repositories.


问:
Pandas scraped data not working in pandas
Why is when I enter data manually into an excel, pandas works.  Yet when I scrape data, put it in to a csv.  It gives me:

```<code>    zz = df1.WE=np.where(df3.AL.isin(df1.EW),df1.WE,np.nan)
ValueError: operands could not be broadcast together with shapes (148,) (537,) ()
</code>```

It has not occurred for other sites.  Am I missing something obvious here?  Is the excel formatted incorrectly or the data is different here somehow?

df3

```<code>df3 = pd.DataFrame(columns=['DAT', 'G', 'TN', 'O1', 'L1', 'TN2', 'O2', 'L2', 'D', 'AJ', 'AK', 'AL'])
</code>```

df1

```<code>                                         EW    WE  \
0             Ponte Preta U20 v Cruzeiro U20  2.10
1  Fluminense RJ U20 v Defensor Sporting U20  2.00
2              Gremio RS U20 v Palmeiras U20  3.30
3                       Barcelona v Sporting  1.33

                                                  DA
0  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...
1  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...
2  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...
3  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...
</code>```

Code:

```<code>df3 = pd.DataFrame(columns=['DAT', 'G', 'TN', 'O1', 'L1', 'TN2', 'O2', 'L2', 'D', 'AJ', 'AK', 'AL'])

df3['DAT'] = df2['AA']

zz = df1.WE=np.where(df3.AL.isin(df1.EW),df1.WE,np.nan)
print(zz)
</code>```

I have provided all my scripts that create the dataframe 1, 2 and the pandas code up until where it creates the error here

I keep getting

Error:

```<code>    zz = df1.WE=np.where(df3.AL.isin(df1.EW),df1.WE,np.nan)
ValueError: operands could not be broadcast together with shapes (0,) (4,) ()
</code>```

Error files created from scrape and loaded as a dataframe:

In case that is not sufficient I have also loaded up the files as they are.

File 1, File 2

Working files created manually:

Working:

File 1, File 2

Any idea how this can be fixed?

答:
On a side note, I'd recommend using pandas functions with pandas:</p>

```<code>df1.loc[~df1.EW.isin(df2.AL), 'WE'] = np.nan
</code>```

Body:
Why is when I enter data manually into an excel, pandas works.  Yet when I scrape data, put it in to a csv.  It gives me:

    zz = df1.WE=np.where(df3.AL.isin(df1.EW),df1.WE,np.nan)
ValueError: operands could not be broadcast together with shapes (148,) (537,) ()

It has not occurred for other sites.  Am I missing something obvious here?  Is the excel formatted incorrectly or the data is different here somehow?

df3

df3 = pd.DataFrame(columns=['DAT', 'G', 'TN', 'O1', 'L1', 'TN2', 'O2', 'L2', 'D', 'AJ', 'AK', 'AL'])

df1

                                         EW    WE  \
0             Ponte Preta U20 v Cruzeiro U20  2.10
1  Fluminense RJ U20 v Defensor Sporting U20  2.00
2              Gremio RS U20 v Palmeiras U20  3.30
3                       Barcelona v Sporting  1.33

                                                  DA
0  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...
1  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...
2  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...
3  https://www.bet365.com.au/#/AC/B1/C1/D13/E40/F...

Code:

df3 = pd.DataFrame(columns=['DAT', 'G', 'TN', 'O1', 'L1', 'TN2', 'O2', 'L2', 'D', 'AJ', 'AK', 'AL'])

df3['DAT'] = df2['AA']

zz = df1.WE=np.where(df3.AL.isin(df1.EW),df1.WE,np.nan)
print(zz)

I have provided all my scripts that create the dataframe 1, 2 and the pandas code up until where it creates the error here

I keep getting

Error:

    zz = df1.WE=np.where(df3.AL.isin(df1.EW),df1.WE,np.nan)
ValueError: operands could not be broadcast together with shapes (0,) (4,) ()

Error files created from scrape and loaded as a dataframe:

In case that is not sufficient I have also loaded up the files as they are.

File 1, File 2

Working files created manually:

Working:

File 1, File 2

Any idea how this can be fixed?

Body:
On a side note, I'd recommend using pandas functions with pandas:

df1.loc[~df1.EW.isin(df2.AL), 'WE'] = np.nan


问:
Add placeholder or empty value to Entity Type with multiple = true in Symfony
I want to do this:

```<code> $builder->add('participants', EntityType::class, array(
        'label' => 'Teilnehmer',
        'class' => SchoolUser::class,
        'multiple' => true,
        'choices' => $this->getParticipantsOfEntry($builder),
        'empty_value'       => 'All',
        'empty_data'        => null,
        'preferred_choices' => array(null)
    ));
</code>```

But I get no selected 'All' - field at all. This should not be hard, I wonder where is my mistake?

```<code>'placeholder' = 'All',
</code>```

did also not work for me.

How can I do this?

答:
I know the question was 4-months ago but I ran into a similar problem so thought I would share my solution in case it helps others.

First in the Form object:

```<code>class MealFormType extends AbstractType {
  public function buildForm( FormBuilderInterface $builder, array $options ) {
    $builder->add( 'courses', EntityType::class, array(
            'class' => MealCourse::class,
            'multiple' => true,
            ) );
    $builder->addEventListener( FormEvents::PRE_SUBMIT, function( FormEvent $event ) {
        // Remove added entries here... maybe something like
        $data = $event->getData();
        if( ($key = array_search( 'all', $data['courses'] ) ) !== false ) {
            unset( $data['courses'][$key] );
            $event->setData( $data );
        }
    } );
  }
  public function configureOptions( OptionsResolver $resolver ) {
    $resolver->setDefaults( ['data_class' => Meal::class] );
  }
  public function finishView( FormView $view, FormInterface $form, array $options) {
    $newChoice = new ChoiceView( null, 'all', 'I want them all!' );
    array_unshift( $view->children['courses']->vars['choices'], $newChoice );
  }
}
</code>```

This creates the form with multiple meal courses that can be selected, such as appetizer, soup, salad, entree, coffee, desert, ... using the buildForm() method. Also in this method an event listener for the PRE_SUBMIT event is added whose job it will be to remove any choices we have added since they are probably not real (if they were, we wouldn't have to add them in this painful way).

It sets the data_class as usual in configureOptions().

Lastly it provides the finishView() method that creates a new choice with value of 'all' that will display as 'I want them all' in the select, then adds it at the beginning for the 'choices' array for the 'courses' form entry (this would be $view->children['courses']->vars['choices'][] = $newChoice; to put it at the end).

Ok, this is fine but it really doesn't do anything more than having an additional option to click or unclick. To use this we need some Javascript to manage the form. I just stuck this Javascript in the bottom of my Twig file and use jQuery.

The Twig file:

```<code>{% block body %}
  {{ form_start(mealForm) }}
    {{ form_row(mealForm.courses,
       {'attr': {'class': 'js-meal_course-select'}}) }}
    <button type="submit">Save</button>
  {{ form_end(mealForm) }}
{% endblock %}

{% block javascripts %}
  {{ parent() }}

  <script>
    var mealCourseAllSelected = false;

    jQuery(document).ready( function() {
      // This will be called whenever an entry is selected or deselected
      $('.js-meal_course-select').change( function() {
        var selectedSet = $(this).val();
        if( mealCourseAllSelected  &&
            (selectedSet.length != $(this).get(0).options.length - 1 ||
             selectedSet.includes( 'all' )) ) {
          var opts = $(this).get(0).options;
          var len = opts.length;
          for( var i = 0; i < len; ++i ) {
            if( opts[i].value == 'all' ) opts[i].selected = false;
          }
          mealCourseAllSelected = false;
        } else if( selectedSet.includes( "all" )  ||
                   selectedSet.length == $(this).get(0).options.length - 1 ) {
          $('.js-meal_course-select option').prop( 'selected', true );
          mealCourseAllSelected = true;
        }
      }
    );
  </script>
{% endblock %}
</code>```

The JavaScript responds to changes to what is selected. If the select option with the value of 'all' is in the selected set, then all the select options are marked as selected, and a flag is set to say so. This is also done if everything is selected except the 'all' entry because that is kind of the definition of all.

If the 'all are selected' flag is set and there is a change, then that change must be deselecting at least one, unless that one is the select option with the value of 'all', it deselects the selection option with the value of 'all' and clears the 'all are selected' flag. If all are selected and the user tries to unselect just the select option with the value of 'all', it is just reselected.

ContentLicense: CC BY-SA 4.0

Body:
I want to do this:

 $builder->add('participants', EntityType::class, array(
        'label' => 'Teilnehmer',
        'class' => SchoolUser::class,
        'multiple' => true,
        'choices' => $this->getParticipantsOfEntry($builder),
        'empty_value'       => 'All',
        'empty_data'        => null,
        'preferred_choices' => array(null)
    ));

But I get no selected 'All' - field at all. This should not be hard, I wonder where is my mistake?

'placeholder' = 'All',

did also not work for me.

How can I do this?

Body:
I know the question was 4-months ago but I ran into a similar problem so thought I would share my solution in case it helps others.

First in the Form object:

class MealFormType extends AbstractType {
  public function buildForm( FormBuilderInterface $builder, array $options ) {
    $builder->add( 'courses', EntityType::class, array(
            'class' => MealCourse::class,
            'multiple' => true,
            ) );
    $builder->addEventListener( FormEvents::PRE_SUBMIT, function( FormEvent $event ) {
        // Remove added entries here... maybe something like
        $data = $event->getData();
        if( ($key = array_search( 'all', $data['courses'] ) ) !== false ) {
            unset( $data['courses'][$key] );
            $event->setData( $data );
        }
    } );
  }
  public function configureOptions( OptionsResolver $resolver ) {
    $resolver->setDefaults( ['data_class' => Meal::class] );
  }
  public function finishView( FormView $view, FormInterface $form, array $options) {
    $newChoice = new ChoiceView( null, 'all', 'I want them all!' );
    array_unshift( $view->children['courses']->vars['choices'], $newChoice );
  }
}

This creates the form with multiple meal courses that can be selected, such as appetizer, soup, salad, entree, coffee, desert, ... using the buildForm() method. Also in this method an event listener for the PRE_SUBMIT event is added whose job it will be to remove any choices we have added since they are probably not real (if they were, we wouldn't have to add them in this painful way).

It sets the data_class as usual in configureOptions().

Lastly it provides the finishView() method that creates a new choice with value of 'all' that will display as 'I want them all' in the select, then adds it at the beginning for the 'choices' array for the 'courses' form entry (this would be $view->children['courses']->vars['choices'][] = $newChoice; to put it at the end).

Ok, this is fine but it really doesn't do anything more than having an additional option to click or unclick. To use this we need some Javascript to manage the form. I just stuck this Javascript in the bottom of my Twig file and use jQuery.

The Twig file:

{% block body %}
  {{ form_start(mealForm) }}
    {{ form_row(mealForm.courses,
       {'attr': {'class': 'js-meal_course-select'}}) }}
    <button type="submit">Save</button>
  {{ form_end(mealForm) }}
{% endblock %}

{% block javascripts %}
  {{ parent() }}

  <script>
    var mealCourseAllSelected = false;

    jQuery(document).ready( function() {
      // This will be called whenever an entry is selected or deselected
      $('.js-meal_course-select').change( function() {
        var selectedSet = $(this).val();
        if( mealCourseAllSelected  &&
            (selectedSet.length != $(this).get(0).options.length - 1 ||
             selectedSet.includes( 'all' )) ) {
          var opts = $(this).get(0).options;
          var len = opts.length;
          for( var i = 0; i < len; ++i ) {
            if( opts[i].value == 'all' ) opts[i].selected = false;
          }
          mealCourseAllSelected = false;
        } else if( selectedSet.includes( "all" )  ||
                   selectedSet.length == $(this).get(0).options.length - 1 ) {
          $('.js-meal_course-select option').prop( 'selected', true );
          mealCourseAllSelected = true;
        }
      }
    );
  </script>
{% endblock %}

The JavaScript responds to changes to what is selected. If the select option with the value of 'all' is in the selected set, then all the select options are marked as selected, and a flag is set to say so. This is also done if everything is selected except the 'all' entry because that is kind of the definition of all.

If the 'all are selected' flag is set and there is a change, then that change must be deselecting at least one, unless that one is the select option with the value of 'all', it deselects the selection option with the value of 'all' and clears the 'all are selected' flag. If all are selected and the user tries to unselect just the select option with the value of 'all', it is just reselected.


问:
I need to decrypt a file efficiently

I am trying to decrypt an encrypted file with unknown key - the only thing I know about it is that the key is an integer x, 0 <= x < 1010 (i.e. a maximum of 10 decimal digits).

```<code>public static String enc(String msg, long key) {
    String ans = "";
    Random rand = new Random(key);
    for (int i = 0; i < msg.length(); i = i + 1) {
        char c = msg.charAt(i);
        int s = c;
        int rd = rand.nextInt() % (256 * 256);
        int s2 = s ^ rd;
        char c2 = (char) (s2);
        ans += c2;
    }
    return ans;
}

private static String tryToDecode(String string) {
    String returnedString = "";
    long key;
    String msg = reader(string);
    for (long i = 0; i <= 999999999; i++) {
        System.out.println("decoding message with key + " + i);

        key = i;
        System.out.println("decoding with key: " + i + "\n" + enc(msg, key));

    }
    return returnedString;
}
</code>```

I expect to find the plain text

The program works very slowly, is there any way to make it more efficient?

答:
First things first:  You can't println billions of lines.  This will take forever, and it's pointless - you won't be able to see the text as it scrolls by, and your buffer won't save billion of lines so you couldn't scroll back up later even if you wanted to.  If you prefer (and don't mind it being 2-3% slower than it otherwise would be), you can output once every hundred million keys, just so you can verify your program is making progress.

You can optimize things by not concatenating Strings inside the loop.  Strings are immutable, so the old code was creating a rather large number of Strings, especially in the enc method.  Normally I'd use a StringBuilder, but in this case a simple character array will meet our needs.

And there's one more thing we need to do that your current code doesn't do:  Detect when we have the answer.  If we assume that the message will only contain characters from 0-127 with no Unicode or extended ASCII, then we know we have a possible answer when the entire message contains only characters in this range.  And we can also use this to further optimize, as we can then immediately discard any message that has a character outside of this range.  We don't even have to finish decoding it and can move on to the next key.  (If the message is of any length, the odds are that only one key will produce a decoded message with characters in that range - but it's not guaranteed, which is why I do not stop when I get to a valid message.  You could probably do that, though.)

Due to the way random numbers are generated in Java, anything in the seed above 32 bits is not used by the encoding/decoding algorithm.  So you only need to go up to 4294967295 instead of 9999999999.  (This also means the key that was originally used to encode the message might not be the key this program uses to decode it, since 2-3 keys in the 10 digit range will produce the same encoding/decoding.)

```<code>private static String tryToDecode4(String msg) {
    String returnedString = "";

    for (long i=0; i<=4294967295l; i++)
    {
        if (i % 100000000 == 0) // This part is just to see that it's making progress. Remove if desired for a small speed gain.
            System.out.println("Trying " + i);

        char[] decoded = enc4(msg, i);
        if (decoded == null)
            continue;

        returnedString = String.valueOf(decoded);
        System.out.println("decoding with key: " + i + " " + returnedString);
    }

    return returnedString;
}

private static char[] enc4(String msg, long key) {
    char[] ansC = new char[msg.length()];
    Random rand = new Random(key);
    for(int i=0;i<msg.length();i=i+1)
    {
        char c = msg.charAt(i);
        int s = c;
        int rd = rand.nextInt()%(256*256);
        int s2 = s^rd;
        char c2 = (char)(s2);
        if (c2 > 127)
            return null;
        ansC[i] = c2;
    }
    return ansC;
}
</code>```

This code finished running in a little over 3 minutes on my machine, with a message of "Hello World".

This code will not work well for very short messages (3-4 characters or less.) It will not work if the message contains Unicode or extended ASCII, although it could easily be modified to do so if you know the range of characters that might be in the message.

Title: I need to decrypt a file efficiently

Body:
I am trying to decrypt an encrypted file with unknown key - the only thing I know about it is that the key is an integer x, 0 <= x < 1010 (i.e. a maximum of 10 decimal digits).

public static String enc(String msg, long key) {
    String ans = "";
    Random rand = new Random(key);
    for (int i = 0; i < msg.length(); i = i + 1) {
        char c = msg.charAt(i);
        int s = c;
        int rd = rand.nextInt() % (256 * 256);
        int s2 = s ^ rd;
        char c2 = (char) (s2);
        ans += c2;
    }
    return ans;
}

private static String tryToDecode(String string) {
    String returnedString = "";
    long key;
    String msg = reader(string);
    for (long i = 0; i <= 999999999; i++) {
        System.out.println("decoding message with key + " + i);

        key = i;
        System.out.println("decoding with key: " + i + "\n" + enc(msg, key));

    }
    return returnedString;
}

I expect to find the plain text

The program works very slowly, is there any way to make it more efficient?

Body:
First things first:  You can't println billions of lines.  This will take forever, and it's pointless - you won't be able to see the text as it scrolls by, and your buffer won't save billion of lines so you couldn't scroll back up later even if you wanted to.  If you prefer (and don't mind it being 2-3% slower than it otherwise would be), you can output once every hundred million keys, just so you can verify your program is making progress.

You can optimize things by not concatenating Strings inside the loop.  Strings are immutable, so the old code was creating a rather large number of Strings, especially in the enc method.  Normally I'd use a StringBuilder, but in this case a simple character array will meet our needs.

And there's one more thing we need to do that your current code doesn't do:  Detect when we have the answer.  If we assume that the message will only contain characters from 0-127 with no Unicode or extended ASCII, then we know we have a possible answer when the entire message contains only characters in this range.  And we can also use this to further optimize, as we can then immediately discard any message that has a character outside of this range.  We don't even have to finish decoding it and can move on to the next key.  (If the message is of any length, the odds are that only one key will produce a decoded message with characters in that range - but it's not guaranteed, which is why I do not stop when I get to a valid message.  You could probably do that, though.)

Due to the way random numbers are generated in Java, anything in the seed above 32 bits is not used by the encoding/decoding algorithm.  So you only need to go up to 4294967295 instead of 9999999999.  (This also means the key that was originally used to encode the message might not be the key this program uses to decode it, since 2-3 keys in the 10 digit range will produce the same encoding/decoding.)

private static String tryToDecode4(String msg) {
    String returnedString = "";

    for (long i=0; i<=4294967295l; i++)
    {
        if (i % 100000000 == 0) // This part is just to see that it's making progress. Remove if desired for a small speed gain.
            System.out.println("Trying " + i);

        char[] decoded = enc4(msg, i);
        if (decoded == null)
            continue;

        returnedString = String.valueOf(decoded);
        System.out.println("decoding with key: " + i + " " + returnedString);
    }

    return returnedString;
}

private static char[] enc4(String msg, long key) {
    char[] ansC = new char[msg.length()];
    Random rand = new Random(key);
    for(int i=0;i<msg.length();i=i+1)
    {
        char c = msg.charAt(i);
        int s = c;
        int rd = rand.nextInt()%(256*256);
        int s2 = s^rd;
        char c2 = (char)(s2);
        if (c2 > 127)
            return null;
        ansC[i] = c2;
    }
    return ansC;
}

This code finished running in a little over 3 minutes on my machine, with a message of "Hello World".

This code will not work well for very short messages (3-4 characters or less.) It will not work if the message contains Unicode or extended ASCII, although it could easily be modified to do so if you know the range of characters that might be in the message.


问:
How to debug this Binary Search code?
I don't know what's wrong with this binary search code of mine. It seems fine to me, but always displaying "not found" in output. I don't know why. Can someone identify the problem?</p>

```<code>#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define SIZE 100
void binarySearch(int, int*);

int arr[SIZE];
int low = 0, high = SIZE - 1;

int main() {
    int arr[SIZE] = { 10, 47, 67, 78, 95, 99 };
    binarySearch(95, arr);
}

void binarySearch(int key, int *arr) {
    if (arr[low] == key) {
        puts("Found!");
        return;
    }
    while (low <= high) {
        int mid = low + (high - 1) / 2;
        if (key == arr[mid]) {
            printf("Data found at index: %d\n", mid);
            return;
        }
        else if (key > arr[mid]) {
            low = mid + 1;
        }
        else {
            high = mid - 1;
        }
    }
    puts("\nData not found!");
}
</code>```

答:
Though your array is sorted here, initializing high to a constant value of SIZE (100) is the problem. If you trace the values of low and high in iterations, you will know that. Instead you can use this:

```<code>int arr[] = {10, 47, 67, 78, 95, 99};
int n = sizeof(arr)/ sizeof(arr[0]);
</code>```

and pass n to the function and initialize high = n-1.

Title: How to debug this Binary Search code?

Body:
I don't know what's wrong with this binary search code of mine. It seems fine to me, but always displaying "not found" in output. I don't know why. Can someone identify the problem?

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define SIZE 100
void binarySearch(int, int*);

int arr[SIZE];
int low = 0, high = SIZE - 1;

int main() {
    int arr[SIZE] = { 10, 47, 67, 78, 95, 99 };
    binarySearch(95, arr);
}

void binarySearch(int key, int *arr) {
    if (arr[low] == key) {
        puts("Found!");
        return;
    }
    while (low <= high) {
        int mid = low + (high - 1) / 2;
        if (key == arr[mid]) {
            printf("Data found at index: %d\n", mid);
            return;
        }
        else if (key > arr[mid]) {
            low = mid + 1;
        }
        else {
            high = mid - 1;
        }
    }
    puts("\nData not found!");
}

Body:
Though your array is sorted here, initializing high to a constant value of SIZE (100) is the problem. If you trace the values of low and high in iterations, you will know that. Instead you can use this:

int arr[] = {10, 47, 67, 78, 95, 99};
int n = sizeof(arr)/ sizeof(arr[0]);

and pass n to the function and initialize high = n-1.


问:
not able to update access table field using VBA
I have a userform in access which submits the data to a table, there are two fields in table which I want to get populated  automatically whenever user makes a new entry in form. I am using the below vba code with that form :

```<code>Option Compare Database

Public Function GetUserName() As String
 Dim obj1 As Object
 Set obj1 = CreateObject("WScript.Network")
 GetUserName = DLookup("[BAFUser]", "BAF_User", "[BRID] = '" & obj1.UserName & "'")
 Set obj1 = Nothing

End Function

Private Sub Form_BeforeInsert(Cancel As Integer)
 Owner2 = CreateObject("WScript.Network").UserName
 AdvisorName = GetUserName

End Sub

Private Sub Form_Load()
 Me.DataForm.Form.Recordset.MoveLast

End Sub

Private Sub SaveBtn_Click()
 RunCommand acCmdSaveRecord
 Me.Requery
 Me.DataForm.Form.Recordset.MoveLast
End Sub
</code>```

I am able to get the value in "owner" field but not in "AdvisorName" field.
What can be the possible reason behind this ?
is there any mistake in my code or is there any better method of doing this ?

答:
The below code should commit both values to your table using a querydef. This is my preferred approach but there are other ways to do it as well. The qdf represents a sql string that can accept parameters from code. We are inserting the values of our variables directly into the sql string.

I copied the code from the save button to re-establish the form state after entry. This should bring the last record back up, but it will depend on the cursortype of the recordset whether the saved record is represented or not (it might go backwards).

```<code>Private Sub Form_BeforeInsert(Cancel As Integer)

    Dim qdf As QueryDef
    Dim Owner2 As String
    Dim AdvisorName As String

    Owner2 = CreateObject("WScript.Network").UserName
    AdvisorName = GetUserName

    Set qdf = CurrentDb.CreateQueryDef("", "INSERT INTO Mau_con (Owner, AdvisorName) VALUES ('" & Owner2 & "', '" & AdvisorName & "')")
    qdf.Execute
    Me.Requery
    Me.DataForm.Form.Recordset.MoveLast
    Set qdf = Nothing

End Sub
</code>```

Body:
I have a userform in access which submits the data to a table, there are two fields in table which I want to get populated  automatically whenever user makes a new entry in form. I am using the below vba code with that form :

Option Compare Database

Public Function GetUserName() As String
 Dim obj1 As Object
 Set obj1 = CreateObject("WScript.Network")
 GetUserName = DLookup("[BAFUser]", "BAF_User", "[BRID] = '" & obj1.UserName & "'")
 Set obj1 = Nothing

End Function

Private Sub Form_BeforeInsert(Cancel As Integer)
 Owner2 = CreateObject("WScript.Network").UserName
 AdvisorName = GetUserName

End Sub

Private Sub Form_Load()
 Me.DataForm.Form.Recordset.MoveLast

End Sub

Private Sub SaveBtn_Click()
 RunCommand acCmdSaveRecord
 Me.Requery
 Me.DataForm.Form.Recordset.MoveLast
End Sub

I am able to get the value in "owner" field but not in "AdvisorName" field.
What can be the possible reason behind this ?
is there any mistake in my code or is there any better method of doing this ?

Body:
The below code should commit both values to your table using a querydef. This is my preferred approach but there are other ways to do it as well. The qdf represents a sql string that can accept parameters from code. We are inserting the values of our variables directly into the sql string.

I copied the code from the save button to re-establish the form state after entry. This should bring the last record back up, but it will depend on the cursortype of the recordset whether the saved record is represented or not (it might go backwards).

Private Sub Form_BeforeInsert(Cancel As Integer)

    Dim qdf As QueryDef
    Dim Owner2 As String
    Dim AdvisorName As String

    Owner2 = CreateObject("WScript.Network").UserName
    AdvisorName = GetUserName

    Set qdf = CurrentDb.CreateQueryDef("", "INSERT INTO Mau_con (Owner, AdvisorName) VALUES ('" & Owner2 & "', '" & AdvisorName & "')")
    qdf.Execute
    Me.Requery
    Me.DataForm.Form.Recordset.MoveLast
    Set qdf = Nothing

End Sub


问:
Can't get item with python beautifulsoup
I'm trying to learn how to webscrape with beautifulsoup + python, and I want to grab the name of the cinematographer from https://letterboxd.com/film/donnie-darko/ but I can't figure out how to isolate the text. The html for what I want is written as below, what I want to output is "Steven Poster":

```<code><h3><span>Cinematography</span></h3>
<div class="text-sluglist">
    <p>
        <a href="/cinematography/steven-poster/" class="text-slug">Steven Poster</a>
    </p>
</div>
</code>```

within my code I've done soup.find(text="Cinematography"), and a mixture of different thigns like trying to find item or get_text from within the a and p tags, but ...

答:
Use CSS partial text selector:</p>

```<code>soup.find('a[href*="cinematography"]').text
</code>```

Body:
I'm trying to learn how to webscrape with beautifulsoup + python, and I want to grab the name of the cinematographer from https://letterboxd.com/film/donnie-darko/ but I can't figure out how to isolate the text. The html for what I want is written as below, what I want to output is "Steven Poster":

Cinematography

        Steven Poster

within my code I've done soup.find(text="Cinematography"), and a mixture of different thigns like trying to find item or get_text from within the a and p tags, but ...

Body:
Use CSS partial text selector:

soup.find('a[href*="cinematography"]').text


问:
where are the inserted and deleted pseudo tables stored?
SQL Server triggers allow access to  two special tables. INSERTED -
 with the "after" values and DELETED with the "before" values.

Where are these stored?. Are they present in tempdb or in the same database as the table being acted upon?

答:
It's crazy talk. Those tables exists in memory* for the scope of the transaction.

Using triggers is just bad enough don't try to mess with the INSERTED and DELETED tables. If you want to it badly you can, inside the trigger, fill another (temporary?) table with it's data.

Triggers are considered anti-pattern in almost any case it's just not a plain log. In general you can use the data fired the trigger in first place and keep a concise and easy to maintain business logic.

*in memory: Most of times SQL Engine will try to let everything in RAM memory, if for any reason it needs more memory there are avaiable pages it will start to use the disk by the mean of  the tempBD but it's entirely transparent and out of your control.

Edit

Martin Smith answer is an excellent one. I know something similar can be done for temp tables but never tried it for triggers tables. I just want to point implementing anything requires direct manipulation of objects like that can raise suspicious of implementantion going in the wrong direction.

Here some sources for my "rant" against (bad use of) triggers

Are database triggers evil?

When are database triggers bad?


问:
Class static getter which returns class in Javascript
I have some code:

```<code>//Main class
class Tools {

  //Subclass implemented by static getter
  static get SUPPORTED_UNITS () {
    return class {
      //Another one
      static get Size () {
        return class {
          //Some data (constants in my case)
        };
      }
    };
  }
}
</code>```

I want to use it like Tools.SUPPORTED_UNITS.Size and I want to receive some data as a result of it.
I use WebStorm for writing JavaScript code, so it shows me this when I tried to use it.

I don't know exactly, maybe I just haven't done some setup to my WebStorm, but.. What I need to do that I can use construction like Class.Subclass.SubClassMethod/SubSubclass.

I need that:

It be not a method

It be static

It be immutable (without Object.freeze or something like that) - so I can't change my Class.Subclass by typing Class.Subclass = foo;

It be indexing by IDE - so I have some help from IDE (like I type Class.Su and she suggest Class.Subclass)

Is it real in ES6 and WebStorm? Or maybe I have to use ES7 and Babel or someting like that?

P.S. That code is working, but I need suggestions from IDE or it will be like a hell.

答:
Following @estus and @Felix Kling suggestion... (likely being misrepresented here)

```<code>const TOOLS = {
    get SUPPORTED_UNITS() {
        return {
            get SIZE() {
                return {
                    get Bar() {
                        return 1;
                    }
                }
            }
        }
    }
};
console.log(TOOLS.SUPPORTED_UNITS.SIZE.Bar) // 1;

TOOLS.SUPPORTED_UNITS.SIZE = "Hello";
// TOOLS.SUPPORTED_UNITS.SIZE = "Hello";
//                            ^
// TypeError: Cannot set property SIZE of #<Object> which has only a getter
</code>```

That works but as remarked by @bergi, it creates a new object in every lookup:

```<code>console.log(TOOLS.SUPPORTED_UNITS === TOOLS.SUPPORTED_UNITS); // false
</code>```

Yep...

An alternative still using getters would be encapsulate all those objects in an IIFE:

```<code>const TOOLS = (function () {
    const SIZE = {
        get Bar() { return 1; }
    }
    const SUPPORTED_UNITS = {
        get SIZE() {
            return SIZE;
        }
    }
    return {
        get SUPPORTED_UNITS() {
            return SUPPORTED_UNITS;
        }
    }
}());

console.log(TOOLS.SUPPORTED_UNITS.SIZE.Bar === TOOLS.SUPPORTED_UNITS.SIZE.Bar); // true
console.log(TOOLS.SUPPORTED_UNITS.SIZE === TOOLS.SUPPORTED_UNITS.SIZE);  // true
console.log(TOOLS === TOOLS); // true

TOOLS.SUPPORTED_UNITS = "hello"; // still throws an error
</code>```

Third update:

The second example solves the issue related to creation of a new object every lookup but it also does not take in consideration that the access to every nested property results in a function call to reevaluate something that is not supposed to change:

```<code>//A naive measurement:
for(let counter = 0; counter < 5; counter++) {
    let start = Date.now();
    for(let i = 0; i < 200000; i++){
        let somevar = Tools.SUPPORT_UNITS.SIZE;
    }
    let end = Date.now();
    console.log(`Elapsed using nested getters: ${end - start}ms.`);
}
// Something like:
/** Elapsed using nested getters: 20ms.
 * Elapsed using nested getters: 14ms.
 * Elapsed using nested getters: 9ms.
 * Elapsed using nested getters: 10ms.
 * Elapsed using nested getters: 10ms.
 *
 // While the same as ordinary properties:
 * Elapsed ordinary properties: 2ms.
 * Elapsed ordinary properties: 5ms.
 * Elapsed ordinary properties: 1ms.
 * Elapsed ordinary properties: 0ms.
 * Elapsed ordinary properties: 0ms.
 */
</code>```

So it is also better to check alternatives before using this approach if running 200000 times loops is in the foreseeable future.

Body:
I have some code:

//Main class
class Tools {

  //Subclass implemented by static getter
  static get SUPPORTED_UNITS () {
    return class {
      //Another one
      static get Size () {
        return class {
          //Some data (constants in my case)
        };
      }
    };
  }
}

I want to use it like Tools.SUPPORTED_UNITS.Size and I want to receive some data as a result of it.
I use WebStorm for writing JavaScript code, so it shows me this when I tried to use it.

I don't know exactly, maybe I just haven't done some setup to my WebStorm, but.. What I need to do that I can use construction like Class.Subclass.SubClassMethod/SubSubclass.

I need that:

It be not a method

It be static

It be immutable (without Object.freeze or something like that) - so I can't change my Class.Subclass by typing Class.Subclass = foo;

It be indexing by IDE - so I have some help from IDE (like I type Class.Su and she suggest Class.Subclass)

Is it real in ES6 and WebStorm? Or maybe I have to use ES7 and Babel or someting like that?

P.S. That code is working, but I need suggestions from IDE or it will be like a hell.

Body:
Following @estus and @Felix Kling suggestion... (likely being misrepresented here)

const TOOLS = {
    get SUPPORTED_UNITS() {
        return {
            get SIZE() {
                return {
                    get Bar() {
                        return 1;
                    }
                }
            }
        }
    }
};
console.log(TOOLS.SUPPORTED_UNITS.SIZE.Bar) // 1;

TOOLS.SUPPORTED_UNITS.SIZE = "Hello";
// TOOLS.SUPPORTED_UNITS.SIZE = "Hello";
//                            ^
// TypeError: Cannot set property SIZE of #<Object> which has only a getter

That works but as remarked by @bergi, it creates a new object in every lookup:

console.log(TOOLS.SUPPORTED_UNITS === TOOLS.SUPPORTED_UNITS); // false

Yep...

An alternative still using getters would be encapsulate all those objects in an IIFE:

const TOOLS = (function () {
    const SIZE = {
        get Bar() { return 1; }
    }
    const SUPPORTED_UNITS = {
        get SIZE() {
            return SIZE;
        }
    }
    return {
        get SUPPORTED_UNITS() {
            return SUPPORTED_UNITS;
        }
    }
}());

console.log(TOOLS.SUPPORTED_UNITS.SIZE.Bar === TOOLS.SUPPORTED_UNITS.SIZE.Bar); // true
console.log(TOOLS.SUPPORTED_UNITS.SIZE === TOOLS.SUPPORTED_UNITS.SIZE);  // true
console.log(TOOLS === TOOLS); // true

TOOLS.SUPPORTED_UNITS = "hello"; // still throws an error

Third update:

The second example solves the issue related to creation of a new object every lookup but it also does not take in consideration that the access to every nested property results in a function call to reevaluate something that is not supposed to change:

//A naive measurement:
for(let counter = 0; counter < 5; counter++) {
    let start = Date.now();
    for(let i = 0; i < 200000; i++){
        let somevar = Tools.SUPPORT_UNITS.SIZE;
    }
    let end = Date.now();
    console.log(`Elapsed using nested getters: ${end - start}ms.`);
}
// Something like:
/** Elapsed using nested getters: 20ms.
 * Elapsed using nested getters: 14ms.
 * Elapsed using nested getters: 9ms.
 * Elapsed using nested getters: 10ms.
 * Elapsed using nested getters: 10ms.
 *
 // While the same as ordinary properties:
 * Elapsed ordinary properties: 2ms.
 * Elapsed ordinary properties: 5ms.
 * Elapsed ordinary properties: 1ms.
 * Elapsed ordinary properties: 0ms.
 * Elapsed ordinary properties: 0ms.
 */

So it is also better to check alternatives before using this approach if running 200000 times loops is in the foreseeable future.


问:
How to set up a cron job via PHP (not CPanel)?
How to set up a cron job via PHP (not CPanel)?</p>

答:
From pure PHP I will create deamon that will manage this (those) cron job(s).

how to create it:
http://kevin.vanzonneveld.net/techblog/article/create_daemons_in_php/ to start with

ContentLicense: CC BY-SA 2.5