Try our conversational search powered by Generative AI!

PDF preview - There is already a content type registered with name: PdfFile

Jay
Jay
Vote:
 

Episerver 11.14.2

Just added PDF preview package, changed PDF model to 

public class PDFFile : MediaData, IPdfFile

but get the following error on start up
[InvalidOperationException: There is already a content type registered with name: PdfFile]
   EPiServer.DataAbstraction.Internal.DefaultContentTypeRepository.ValidateUniqueness(ContentType contentType) +222
   EPiServer.DataAbstraction.Internal.DefaultContentTypeRepository.Save(ContentType contentType) +111
   EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeSynchronizer.CreateType(ContentTypeModel contentModel) +136
   EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.CommitTypes(Boolean deleteUnusedTypes) +328
   EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.Sync(Boolean commitChanges) +224
   EPiServer.Initialization.Internal.ModelSyncInitialization.Initialize(InitializationEngine context) +390
   EPiServer.Framework.Initialization.Internal.<>c__DisplayClass2_0.<Initialize>b__0() +19
   EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key) +52
   EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context) +80
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +179

Anyone else got ideas or resolved this problem before?

Thanks


#253758
Apr 22, 2021 11:35
Vote:
 

Some suggestions:

  • Have a look in admin mode, under content types. Do you see the page type there?
  • Check the database (SELECT * FROM tblContentType) and look at the modelType column. The namespace should give a hint to the origin of the existing page type. Is it your namespace? A module?

You could delete the old pagetype, or rename your new pagetype.

#253766
Apr 22, 2021 18:47
Jay
Vote:
 

Yep PdfFile model is in there, I can't delete it as it has about 1500 content records associated with it

Tried renaming the model to PdfFileLibrary but that didn't make any difference, think the initialisation for the PDF Previewer is running first

What I don't understand is that according to the documentation for PDF Preview if there is an existing type already then the resolver should use the existing and not try add it's own one.

My PDF model isn't just a placeholder, it has quite a few properties plus it's used in the Find initialastion as it has some custom indexing, categories and a library system built around it.

PDF Preview add on is a nice to have so I don't want to be making major changes to make it work.

#253798
Apr 23, 2021 7:43
Vote:
 
  • Try to rename your class to something else (temporarily)
  • Use ServiceLocator.Current.GetInstance<ContentTypeRepository>().Load("PdfFile") to get the registered ContentType, and see where is it from 
    
    
#253799
Apr 23, 2021 7:46
Jay - Apr 23, 2021 7:51
Tried to rename the class but that made no difference.

Registered content type is my class.

I thought that by adding IPdfFile to my class that the resolver would pick it up and not try to add it's own PdfFile class
Quan Mai - Apr 23, 2021 8:05
I meant doing both, not each item. Once you find out about the duplicated content it will be easier to figure out a solution
Jay - Apr 23, 2021 8:11
I can't run that code as the site crashes as soon as I try and start it.

Thought I might be able to just start debugging and catch the error and run that code but no luck with that, debugger can't catch it and I just get the same error on the page
Vote:
 

I created bug CMS-19157 so it'll be easier to understand why a content type is duplicated 

#253801
Apr 23, 2021 7:52
Jay - Apr 23, 2021 7:59
Great thanks
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.