Visual Studio - Resx File default 'internal' to 'public'
Solution 1
Instead of the ResXFileCodeGenerator
, use the PublicResXFileCodeGenerator
.
You can do this by setting this as the Custom Tool property in the Property Window for the Resx file you want public access to.
Edit: Alternatetively you can set the Access Modifier to public when you open the resx file in Visual Studio. The Access Modifier dropdown box can be found at the top of the form.
Solution 2
Right click on Resource file (
resource.resx
) => Properties.Custom Tool => Change to
PublicResXFileCodeGenerator
Comments
-
Robin Maben almost 2 years
Every time I edit a resource file in VS, it regenerates the corresponding code and sets the class access modifier to internal.
It's a pain to Ctrl-F -> ReplaceAll every time I edit the resx. Is there a property/setting so that I can default this to public?internal class MyResource { internal static global::System.Resources.ResourceManager ResourceManager {...} }
I need all those
internal
to bepublic
all the time.-
Robin Maben over 13 years@jvanrhyn: Because I need to access its resource manager from another project in the solution.
-
-
Marc Gravell over 13 years(Good answer; but just some notes; it could also be
GlobalResourceProxyGenerator
, not justResXFileCodeGenerator
; and note also that the "Access Modofier" dropdown is often disabled) -
Robin Maben over 13 years@Anton: Thanks, works in my case. Also, I noticed that changing access modifier from the drop down changes the corresponding tool.
-
Anton over 13 years@conqenator: that's why I proposed using the Access Modifier dropdown as an alternative way of reaching the same outcome :)
-
Raheel Khan about 12 years@Anton: Thanks. Most people new to resource files miss the modifier drop down. In a rush project, I went so far as to manually strong type each resource name.
-
Céryl Wiltink over 10 yearsJup, I'm another one who missed the modifier dropdown until I found this answer! Thanks @Anton!
-
Manuel Navarro over 10 yearsBTW if the Access Modifier dropdown is disabled, you can try changing the Custom Tool property to ResXFileCodeGenerator, if that's not the value alredy. At least that work for me in an MVC project on VS 2010.
-
zaitsman over 9 yearsSo that's still a click for each resx. Any way to make VS create them public by default?
-
Thad almost 9 yearsThis is not possible. You will get an error CS0060 Inconsistent accessibility: base class 'Strings' is less accessible than class 'PublicStrings'
-
Laurent Michel almost 5 yearsFor me with Visual Studio 2017 choosing the
PublicResXFileCodeGenerator
only makes the Resources class public, not its constructor. -
Luis de Haro over 4 yearsIt works fine for Visual Studio for Mac 2019 as well.
-
Milton over 2 yearsThank you! Driven crazy by this for an entire morning