Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Technically, yes it is possible but there are some pitfalls. First, let me show you an example. Suppose my <code>App_GlobalResources</code> folder looks like so:</p> <pre><code>/App_GlobalResources /Test TestSubresource.resx TestResource.resx </code></pre> <p>Each resource file has a single entry called "TestString". I added each resource file using the Visual Studio menu so it created a class for me. By default, all classes added to the <code>App_GlobalResources</code> folder will have the same namespace of <code>Resource</code>. So, if I want to use the class generator and I want <code>Test</code> in the namespace, I need to go into the TestSubresource.Designer.cs file and manually change the namespace. Once I do that, I can do the following:</p> <pre><code>var rootResource = Resources.TestResource.TestString; var subResource = Resources.Test.TestSubResource.TestString; </code></pre> <p>I can also reference them using <code>GetGlobalResourceObject</code>:</p> <pre><code>var rootResource = GetGlobalResourceObject( "TestResource", "TestString" ); var subResource1 = GetGlobalResourceObject( "TestSubresource", "TestString" ); </code></pre> <p>Notice that I still use the "TestSubresource" as the means to reference the resources in that file even though it is in a subfolder. Now, one of the catches, is that all the files must be unique across all folders in <code>App_GlobalResources</code> or your project will throw a runtime error. If I add a resource named "TestResource.resx" to /Test, it will throw the following runtime error:</p> <blockquote> <p>The resource file '/App_GlobalResources/TestResource.resx' cannot be used, as it conflicts with another file with the same name.).</p> </blockquote> <p>This is true even if I change the namespace on the new resource.</p> <p>So, in conclusion, yes it is possible, but you increase the odds of getting a runtime error because of two identically named resource files in different parts of the <code>App_GlobalResources</code> folder structure which is allowed by the file system but not by .NET.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload