У меня проблема с загрузкой элемента с помощью Glass Mapper SitecoreService. Элемент определенно существует, и тип верен. (Он генерируется TDS).Sitecore Glass Mapper: «Дублируемое имя типа в сборке» Ошибка
var language = Language.Parse("en-GB");
var service = new SitecoreService("master");
var targetPath = String.Format("{0}-migrated", Constants.SourceProviderListPageItem);
var target = service.GetItem<IProvider_List_Page>(targetPath, language);
Приведенный выше код вызывает следующее исключение, когда service.GetItem < Т > называется.
Duplicate type name within an assembly.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Duplicate type name within an assembly.
[ArgumentException: Duplicate type name within an assembly.]
System.Reflection.Emit.ModuleBuilder.CheckTypeNameConflict(String strTypeName, Type enclosingType) +14373369
System.Reflection.Emit.AssemblyBuilderData.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +91
System.Reflection.Emit.TypeBuilder.Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, Int32 iTypeSize, TypeBuilder enclosingType) +161
System.Reflection.Emit.ModuleBuilder.DefineType(String name, TypeAttributes attr) +263
Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope modulescope, String name, Type baseType, IEnumerable`1 interfaces, TypeAttributes flags, Boolean forceUnsigned) +156
Castle.DynamicProxy.Generators.InvocationTypeGenerator.GetEmitter(ClassEmitter class, Type[] interfaces, INamingScope namingScope, MethodInfo methodInfo) +239
Castle.DynamicProxy.Generators.InvocationTypeGenerator.Generate(ClassEmitter class, ProxyGenerationOptions options, INamingScope namingScope) +124
Castle.DynamicProxy.Contributors.InterfaceProxyWithoutTargetContributor.GetInvocationType(MetaMethod method, ClassEmitter emitter, ProxyGenerationOptions options) +430
Castle.DynamicProxy.Contributors.InterfaceProxyWithoutTargetContributor.GetMethodGenerator(MetaMethod method, ClassEmitter class, ProxyGenerationOptions options, OverrideMethodDelegate overrideMethod) +100
Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementMethod(MetaMethod method, ClassEmitter class, ProxyGenerationOptions options, OverrideMethodDelegate overrideMethod) +69
Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementProperty(ClassEmitter emitter, MetaProperty property, ProxyGenerationOptions options) +128
Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(ClassEmitter class, ProxyGenerationOptions options) +306
Castle.DynamicProxy.Generators.InterfaceProxyWithoutTargetGenerator.GenerateType(String typeName, Type proxyTargetType, Type[] interfaces, INamingScope namingScope) +499
Castle.DynamicProxy.Generators.<>c__DisplayClass1.<GenerateCode>b__0(String n, INamingScope s) +38
Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func`3 factory) +757
Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors) +159
Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, IInterceptor interceptor) +129
Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.CreateInterfaceTask.Execute(ObjectConstructionArgs args) +381
Glass.Mapper.Pipelines.AbstractPipelineRunner`2.Run(T args) +616
Glass.Mapper.AbstractService.InstantiateObject(AbstractTypeCreationContext abstractTypeCreationContext) +646
Glass.Mapper.Sc.SitecoreService.CreateType(Type type, Item item, Boolean isLazy, Boolean inferType, Dictionary`2 parameters, Object[] constructorParameters) +721
Glass.Mapper.Sc.SitecoreService.CreateType(Item item, Boolean isLazy, Boolean inferType) +215
Glass.Mapper.Sc.SitecoreService.GetItem(String path, Language language, Boolean isLazy, Boolean inferType) +239
<Redacted>.Page_Load(Object sender, EventArgs e) +584
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
Любая идея, что может вызвать проблемы?
Приветствия
У вас есть полная трассировка стека? –
Привет, Майкл, спасибо за помощь - я добавил трассировку стека в соответствии с запросом. –
Похоже, вы используете [Interface as Model] (http://glass.lu/Mapper/Sc/Tutorials/Tutorial21.aspx). Поскольку вы используете TDS, также генерируются конкретные классы, вместо этого попробуйте вместо этого «Provider_List_Page». Я предполагаю, что существование интерфейса и бетона вызывает проблемы здесь, но @MichaelEdwards смогут подтвердить ... – jammykam