Error Deployment WCF windows server 2012

1

I am making a deployment of some services WCF , when consuming the services; in a server it works correctly, but in another server in which it must be deployed, it is throwing me the following error:

The type initializer for 'Compensar.CyA.Mapper.Entidades.Servicio.ClienteEmpresaExtend' threw an exception.
   at Compensar.CyA.Servicios.Implementacion.ClienteEmpresa.<>c__DisplayClass14.<CrearSucursal>b__13()
   at Compensar.CyA.Servicios.Implementacion.LanzadorOperaciones.Ejecutar[TEntity](headerMessage header, Func'1 action)

I have reviewed the two servers, to find the differences of configuration but I still do not give with the joke.

I found the detail of the error

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly()
   at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load()
   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData)
   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action'1 logLoadMessage, Object& loaderCookie, Dictionary'2& typesInLoading, List'1& errors)
   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action'1 logLoadMessage)
   at System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection)
   at System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly)
   at System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType)
   at System.Data.Objects.ObjectContext.GetEntitySetFromContainer(EntityContainer container, Type entityCLRType, String exceptionParameterName)
   at System.Data.Objects.ObjectContext.GetEntitySetForType(Type entityCLRType, String exceptionParameterName)
   at System.Data.Objects.ObjectContext.CreateObjectSet[TEntity]()
   at Intergrupo.Data.Repository.EntityFramework.DataRepository'1.get_ObjectSet()
   at Intergrupo.Data.Repository.EntityFramework.DataRepository'1.GetFirst(Func'2 filtro)
   at Compensar.CyA.Dominio.GestionarCliente.Consultar(TipoCliente tipoCliente, ICollection'1 opcionesConsulta, Int32 tipoIdentificacion, String numeroIdentificacion, Decimal idSucursal, Decimal idCentroCosto)
   at Compensar.CyA.Servicios.Implementacion.ClienteEmpresa.<>c__DisplayClassa.<Consultar>b__7()
   at Compensar.CyA.Servicios.Implementacion.LanzadorOperaciones.Ejecutar[TEntity](headerMessage header, Func'1 action)

But I still do not understand why one server works and the other does not.

I appreciate any help.

    
asked by Jairo1010 03.02.2016 в 16:30
source

1 answer

1

> > > > > > > > > > > In a shared library for both services and a web application, where Data Annotations are implemented in some DTO

There's the problem you should not use presentation validations with persistent objects, these concepts should be separated.

On the one hand you must define the entities of EF that you would use in the context and when these should be joined in UI you create other different objects known as ViewModel if you use asp.net mvc these classes will be in the folder Model .

Then you use automapper to map from the controller an EF entity with an entity that uses the view.

In your case, being WCF is the same but you do it in the ServiceContract, on the one hand you will have entities of DTO (which will surely have DataMember attributes) and on the other the entities of EF , you should not Persistently map any entity you use up to the presentation. To convert from one layer to another, you use automapper .

This way you separate responsibilities and avoid having references to libraries that you should not add, as is the case of Web libraries in project Class Library .

    
answered by 03.02.2016 / 17:54
source