5
votes

I have a resources file in my portable class library which is currently holding around 30 strings. They are accessible from my Windows Phone 8 app and the strings that are already in the file work fine.

However, now when I try to add a new string as I did before it causes a compilation error:

'System.Type' does not contain a definition for 'Assembly' and no extension method 'Assembly' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)

Looking in the .designer.cs file it's clear that this is the problem. When a new string is added two changes occur:

  • using System.Reflection; disappears
  • `global::System.Resources.ResourceManager("ViewModels.Resources.StringResources", typeof(StringResources).Assembly); appears in place of:

    new global::System.Resources.ResourceManager("ViewModels.Resources.StringResources", typeof(StringResources).GetTypeInfo().Assembly);

The .GetTypeInfo() and disappearing using statement are the problem but I can't put them back because the file is generated by visual studio and changes back. Any ideas?

The only significant change I can think of is the new Visual Studio 2012 update 2?

Also worth noting: If I add another resx anywhere else in the project (the wp8 app or another pcl) then this exhibits the exact same behaviour when adding a string.

1
I repro on Update 2, not close to an Update 1 machine right now. This could be very painful. Post this to connect.microsoft.com. The crummy workaround until you hear back is to edit the .cs file by hand and avoid the designer. - Hans Passant
@HansPassant as it mentions at the end of the connect post: I've got it to compile now by deleting and readding the resx and designer file. But for some reason in solution explorer the designer file is no longer nested. The resx can be updated with new strings but the designer file doesn't reflect these changes - so not ideal. I also can't work out how to reattach them. Any ideas? - James Mundy
@JamesMundy Does this happen if you create a new PCL or does it just seem to be this specific project? Can you attach a repro to the connect bug you filed? Thanks! - Daniel Plaisted
@DanielPlaisted When I add a new pcl it works fine, it's only when I edit an existing resources file that was added before the update. I can't really upload the project I'm working on as it's sensitive and tied has a few dependencies. I can stop the compile error by turning code generation off of the resx file but that's not ideal. - James Mundy

1 Answers