简体   繁体   中英

coiniumServ works on windows, fails on mono at runtime with System.Reflection.ReflectionTypeLoadException

I've started working on CoiniumServ code. The code will run on windows, but on my Linux server it fails.

Stack Trace:

Nancy.TinyIoc.TinyIoCResolutionException: 
Unable to resolve type: 
    CoiniumServ.Server.Web.WebServer ---> 
        Nancy.TinyIoc.TinyIoCResolutionException: Unable to resolve type: 
            CoiniumServ.Server.Web.NancyBootstrapper ---> 
                System.TypeInitializationException: An exception was thrown by the type initializer for Nancy.Bootstrapper.AssemblyTypeScanner ---> 
                System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

                  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
                  at System.Reflection.Assembly.GetExportedTypes () [0x00000] in <filename unknown>:0
                  at Nancy.Extensions.AssemblyExtensions.SafeGetExportedTypes (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0
                  at Nancy.Bootstrapper.AppDomainAssemblyTypeScanner.<UpdateTypes>b__16 (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0
                  at System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator14`3[System.Reflection.Assembly,System.Type,<>f__AnonymousType0`2[System.Reflection.Assemb]].MoveNext () [0x00000] in <filename unknown>:0
                  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1E`1[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type]].MoveNext () [0x00000] in <fn>:0
                  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type],System.Type].MoveNext () [0lename unknown>:0
                  at System.Linq.Enumerable.ToArray[Type] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
                  at Nancy.Bootstrapper.AppDomainAssemblyTypeScanner.UpdateTypes () [0x00000] in <filename unknown>:0
                  at Nancy.Bootstrapper.AppDomainAssemblyTypeScanner.LoadAssembliesWithNancyReferences () [0x00000] in <filename unknown>:0
                  at Nancy.Bootstrapper.AppDomainAssemblyTypeScanner..cctor () [0x00000] in <filename unknown>:0
                  --- End of inner exception stack trace ---

            at Nancy.Conventions.NancyConventions.BuildDefaultConventions () <0x0002f>
            at Nancy.Conventions.NancyConventions..ctor () <0x00013>
            at Nancy.Bootstrapper.NancyBootstrapperBase`1<Nancy.TinyIoc.TinyIoCContainer>..ctor () <0x0005f>
            at Nancy.Bootstrapper.NancyBootstrapperWithRequestContainerBase`1<Nancy.TinyIoc.TinyIoCContainer>..ctor () <0x00087>
            at Nancy.DefaultNancyBootstrapper..ctor () <0x00013>
            at CoiniumServ.Server.Web.NancyBootstrapper..ctor (CoiniumServ.Container.Context.IApplicationContext,CoiniumServ.Statistics.IStatisticsManager,CoiniumServ.Pools.IPoolManager,CoiniumServ.Configuration.IConfigManager) <0x00033>
            at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,object[]) <0x00357>
            at Nancy.TinyIoc.TinyIoCContainer.ConstructType (System.Type,System.Type,System.Reflection.ConstructorInfo,Nancy.TinyIoc.NamedParameterOverloads,Nancy.TinyIoc.ResolveOptions) <0x003fe>

      --- End of inner exception stack trace ---
      at Nancy.TinyIoc.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, Nancy.TinyIoc.NamedParameterOverloads parameters, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0
      at Nancy.TinyIoc.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0
      at Nancy.TinyIoc.TinyIoCContainer+SingletonFactory.GetObject (System.Type requestedType, Nancy.TinyIoc.TinyIoCContainer container, Nancy.TinyIoc.NamedParameterOverloads parameters, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0
      at Nancy.TinyIoc.TinyIoCContainer.ResolveInternal (Nancy.TinyIoc.TypeRegistration registration, Nancy.TinyIoc.NamedParameterOverloads parameters, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Nancy.TinyIoc.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, Nancy.TinyIoc.NamedParameterOverloads parameters, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0
  at Nancy.TinyIoc.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0
  at Nancy.TinyIoc.TinyIoCContainer+SingletonFactory.GetObject (System.Type requestedType, Nancy.TinyIoc.TinyIoCContainer container, Nancy.TinyIoc.NamedParameterOverloads parameters, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0
  at Nancy.TinyIoc.TinyIoCContainer.ResolveInternal (Nancy.TinyIoc.TypeRegistration registration, Nancy.TinyIoc.NamedParameterOverloads parameters, Nancy.TinyIoc.ResolveOptions options) [0x00000] in <filename unknown>:0

The files/classes are included in the build file and listed during compile. There are a couple of warning thrown during the compile,but only in reference to some unused variables in the code. I've checked that the referenced dll's are all being copied. I've also tried deleting packages pulled by nuget, and running a manual clean before the build.

I'm not really a C# person, so I'm not sure where to go from here.

[Edit] The windows version was build with VisualStudio, the linux was built on the Linux box via mono ( xbuild )

Just in case anyone pulls this up in a search, I'm posting the answer.

The mono on linux build was not generating a bunch of .xml configuration files.

This answer pointed me in the right direction: http://forum.unity3d.com/threads/ideas-reflectiontypeloadexception-the-classes-in-the-module-cannot-be-loaded.230389/

Comparing the build output on linux to the build output on Windows showed the missing files. Going the easy route, I copied the files from Windows up to Linux and it ran.

It would be good to know where to look from a pure Linux POV. I'll add comments if I find what gets left out in the Linux build instructions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM