Problem creating a theme.

Jan 24, 2011 at 8:10 PM

Does anyone have any resources on making a theme for orchard besides the orchard project documentation.  I have stepped through the documentation a number of time but I always get an error that says "An item with the same key has already been added".

I can download themes just fine and install them.  But even if I generate a new theme and copy paste files from it.  I get the same error.

Tried downloading the project again, the source, even the most recent commits.  Can't seem to get it going.

Jan 24, 2011 at 8:26 PM

Does the error message look something like this?

[ArgumentException: An item with the same key has already been added.]
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +12673712
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +387
Orchard.DisplayManagement.Descriptors.<>c__DisplayClassb.<GetShapeTable>b__2(AcquireContext`1 x) in DefaultShapeTableManager.cs:50

Jan 24, 2011 at 8:30 PM

very similar.  Except I get the line:

System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52

appearing between your first line and second line.

Jan 24, 2011 at 8:49 PM

Did you specify a base theme in your theme.txt? If so then try changing the names of any CSS or JS files you copied over.

Jan 24, 2011 at 8:56 PM

no i didn't.

I used the command "codegen theme MyName /CreateProject:true /IncludeInSolution:true

Jan 25, 2011 at 10:51 PM

Any other ideas on this.  I am sure I am missing something really simple.  I am just stepping through the instructions on this page.

Jan 25, 2011 at 11:09 PM

Can you check where the theme is? If it's under modules, move it out of there into Themes.

Jan 25, 2011 at 11:22 PM

it is under themes.  I am thinking that maybe I did something wrong when I first built it, so even though I had keep retrying it it would just through the same error(since I always name the theme the same thing.  So what I did this time was uninstall the theme from the control panel.  Now no matter what I have tried I cant get the theme to show back up in the available themes.

Jan 25, 2011 at 11:24 PM

Start over? move it out of the site, recreate it and bring files back progressively?

Jan 26, 2011 at 2:04 PM

still not working for me.  Oh well.  I am sure I am missing something completely stupid.  Going to try to download a themes and see what i am missing.

Jan 26, 2011 at 2:09 PM

One more intresting thing, if i don't set the theme as current and just do the preview.  it seems to work fine.

Jan 26, 2011 at 3:58 PM

OK still trying to figure this out.  it seems to be something with this file when I create my own theme.


Source File: c:\Users\Jeff Williams\Documents\My Web Sites\\Core\Routable\Views\Item\Display.cshtml    


if I use codegen to make a new theme (codegen theme MyTheme). And then drag files into it from a theme that works.  I end up in the same boat with the same error.  Totally confused here.  So still looking for help cause I would really like to give orchard a try.


Jan 26, 2011 at 4:27 PM

Are you getting that error if you drag any file in there? What makes you think display.cshtml is responsible for it?

Jan 26, 2011 at 4:34 PM

well it seems i get it once I drag any layout.cshtml.  I am not trying to say that the file is bad, but it seems to be the file that is throwing the error.

Server Error in '/' Application.

An item with the same key has already been added.

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: An item with the same key has already been added.

Source Error:

Source File: c:\Users\Jeff Williams\Documents\My Web Sites\\Core\Routable\Views\Item\Display.cshtml    Line: 1

Line 1:  @Display(Model)

I am sure it has something to do with how i create the themes.  If i install a theme from the gallery it works.  If i use codegen to make a container and copy those theme files over to the new created theme, I get this error.  If i follow the steps outlined in Writing a new theme I get this error.

Jan 26, 2011 at 4:45 PM

Also, something I just noticed when comparing the stack trace of the error message referenced above and the one I am getting they are different.  Although the first few lines are very similar I start getting a bunch of references to d:/teamcity.

Orchard.DisplayManagement.Descriptors.<>c__DisplayClassb.<GetShapeTable>b__2(AcquireContext`1 x) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\DisplayManagement\Descriptors\DefaultShapeTableManager.cs:50
Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Caching\Cache.cs:41
Orchard.Caching.<>c__DisplayClass3.<Get>b__0(TKey k) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Caching\Cache.cs:17

Jan 26, 2011 at 5:14 PM

Wild guess from Louis: try Layout.cshtml with uppercase L. If that works, we have a bug here.

(the Teamcity part is not relevant here: it just comes from the machine where the build was made)

Jan 26, 2011 at 7:07 PM

Well I told you I was just doing something stupid that was different from everyone else.  That solved the problem.  I am on my way now thanks.

Jan 26, 2011 at 7:11 PM

Well, that's not your fault at all, it should have worked. I created to track the issue. Thanks for reporting it.

Jan 26, 2011 at 7:15 PM

np, thanks for the assistance