GetManifestResourceNames: Some resources are not embedded (Not authorized?)
up vote
1
down vote
favorite
When the embedded resource is named with this kind pattern:
whatever.{xxx}.whatever
Replace {xxx} with one of the following examples: agq,arn,asa,ast,bas,bem,bez,bin. Assembly.GetManifestResourceNames won't find them. There are about a hundred of them. (Check the code below to find them all)
I keep getting the same results be it with .Net framework or .Net core.
Is this kind of naming unauthorized because it looks like some sort of forbidden extension file name? If so, how to disable this dumb security rule.
List<string> codes = new List<string>();
for (char first = 'a'; first <= (int)'z'; first++)
for (char second = 'a'; second <= (int)'z'; second++)
for (char third = 'a'; third <= (int)'z'; third++)
codes.Add(first.ToString() + second + third);
codes = codes.Take(1000).ToList();
string slnPath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName;
while (!Directory.GetFiles(slnPath).Any(x => x.EndsWith(".sln")))
slnPath = Directory.GetParent(slnPath).FullName;
string classLibraryFolder = "ClassLibrary1";
var csjFolder = Path.Combine(slnPath, classLibraryFolder);
var csjPath = Path.Combine(csjFolder, $"{classLibraryFolder}.csproj");
string resourcesFolder = "Resources";
string resourcesPath = Path.Combine(csjFolder, resourcesFolder);
XDocument doc = XDocument.Load(csjPath);
if(!doc.Descendants().Attributes().Any(x=> x.Value == $"{resourcesFolder}\x.aaa.x"))
{
Console.WriteLine("Creating embedded resources...");
Directory.CreateDirectory(resourcesPath);
foreach (var code in codes)
File.Create(Path.Combine(resourcesPath, "x." + code + ".x")).Close();
Console.WriteLine("Updating csproj...");
var xNone = new XElement("ItemGroup");
foreach (var code in codes)
xNone.Add(new XElement("None", new XAttribute("Remove", $"{resourcesFolder}\x.{code}.x")));
var xEmbeddedResource = new XElement("ItemGroup");
foreach (var code in codes)
xEmbeddedResource.Add(new XElement("EmbeddedResource", new XAttribute("Include", $"{resourcesFolder}\x.{code}.x")));
doc.Root.Add(xNone);
doc.Root.Add(xEmbeddedResource);
doc.Save(csjPath);
Console.WriteLine("Please relaunch program.");
return;
}
string Languages2 = typeof(ClassLibrary1.Class1).GetTypeInfo().Assembly.GetManifestResourceNames().ToArray();
var present = codes.Where(code => Languages2.Any(x => x.EndsWith($"x.{code}.x"))).ToList();
var missing = codes.Except(present).ToList();
.net embedded-resource
add a comment |
up vote
1
down vote
favorite
When the embedded resource is named with this kind pattern:
whatever.{xxx}.whatever
Replace {xxx} with one of the following examples: agq,arn,asa,ast,bas,bem,bez,bin. Assembly.GetManifestResourceNames won't find them. There are about a hundred of them. (Check the code below to find them all)
I keep getting the same results be it with .Net framework or .Net core.
Is this kind of naming unauthorized because it looks like some sort of forbidden extension file name? If so, how to disable this dumb security rule.
List<string> codes = new List<string>();
for (char first = 'a'; first <= (int)'z'; first++)
for (char second = 'a'; second <= (int)'z'; second++)
for (char third = 'a'; third <= (int)'z'; third++)
codes.Add(first.ToString() + second + third);
codes = codes.Take(1000).ToList();
string slnPath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName;
while (!Directory.GetFiles(slnPath).Any(x => x.EndsWith(".sln")))
slnPath = Directory.GetParent(slnPath).FullName;
string classLibraryFolder = "ClassLibrary1";
var csjFolder = Path.Combine(slnPath, classLibraryFolder);
var csjPath = Path.Combine(csjFolder, $"{classLibraryFolder}.csproj");
string resourcesFolder = "Resources";
string resourcesPath = Path.Combine(csjFolder, resourcesFolder);
XDocument doc = XDocument.Load(csjPath);
if(!doc.Descendants().Attributes().Any(x=> x.Value == $"{resourcesFolder}\x.aaa.x"))
{
Console.WriteLine("Creating embedded resources...");
Directory.CreateDirectory(resourcesPath);
foreach (var code in codes)
File.Create(Path.Combine(resourcesPath, "x." + code + ".x")).Close();
Console.WriteLine("Updating csproj...");
var xNone = new XElement("ItemGroup");
foreach (var code in codes)
xNone.Add(new XElement("None", new XAttribute("Remove", $"{resourcesFolder}\x.{code}.x")));
var xEmbeddedResource = new XElement("ItemGroup");
foreach (var code in codes)
xEmbeddedResource.Add(new XElement("EmbeddedResource", new XAttribute("Include", $"{resourcesFolder}\x.{code}.x")));
doc.Root.Add(xNone);
doc.Root.Add(xEmbeddedResource);
doc.Save(csjPath);
Console.WriteLine("Please relaunch program.");
return;
}
string Languages2 = typeof(ClassLibrary1.Class1).GetTypeInfo().Assembly.GetManifestResourceNames().ToArray();
var present = codes.Where(code => Languages2.Any(x => x.EndsWith($"x.{code}.x"))).ToList();
var missing = codes.Except(present).ToList();
.net embedded-resource
1
Brr, fighting the .csproj file wasn't a lot of fun. You'll find the missing resources in their own satellite assembly instead of getting embedded in the dll. This decision is made by the msbuild AssignCulture task. Why it thinks that "bin", "bez", etc are valid culture identifiers is not obvious to me. You'll want a different naming convention to avoid this.
– Hans Passant
Nov 12 at 9:26
Compare to this list.
– Hans Passant
Nov 12 at 9:51
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When the embedded resource is named with this kind pattern:
whatever.{xxx}.whatever
Replace {xxx} with one of the following examples: agq,arn,asa,ast,bas,bem,bez,bin. Assembly.GetManifestResourceNames won't find them. There are about a hundred of them. (Check the code below to find them all)
I keep getting the same results be it with .Net framework or .Net core.
Is this kind of naming unauthorized because it looks like some sort of forbidden extension file name? If so, how to disable this dumb security rule.
List<string> codes = new List<string>();
for (char first = 'a'; first <= (int)'z'; first++)
for (char second = 'a'; second <= (int)'z'; second++)
for (char third = 'a'; third <= (int)'z'; third++)
codes.Add(first.ToString() + second + third);
codes = codes.Take(1000).ToList();
string slnPath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName;
while (!Directory.GetFiles(slnPath).Any(x => x.EndsWith(".sln")))
slnPath = Directory.GetParent(slnPath).FullName;
string classLibraryFolder = "ClassLibrary1";
var csjFolder = Path.Combine(slnPath, classLibraryFolder);
var csjPath = Path.Combine(csjFolder, $"{classLibraryFolder}.csproj");
string resourcesFolder = "Resources";
string resourcesPath = Path.Combine(csjFolder, resourcesFolder);
XDocument doc = XDocument.Load(csjPath);
if(!doc.Descendants().Attributes().Any(x=> x.Value == $"{resourcesFolder}\x.aaa.x"))
{
Console.WriteLine("Creating embedded resources...");
Directory.CreateDirectory(resourcesPath);
foreach (var code in codes)
File.Create(Path.Combine(resourcesPath, "x." + code + ".x")).Close();
Console.WriteLine("Updating csproj...");
var xNone = new XElement("ItemGroup");
foreach (var code in codes)
xNone.Add(new XElement("None", new XAttribute("Remove", $"{resourcesFolder}\x.{code}.x")));
var xEmbeddedResource = new XElement("ItemGroup");
foreach (var code in codes)
xEmbeddedResource.Add(new XElement("EmbeddedResource", new XAttribute("Include", $"{resourcesFolder}\x.{code}.x")));
doc.Root.Add(xNone);
doc.Root.Add(xEmbeddedResource);
doc.Save(csjPath);
Console.WriteLine("Please relaunch program.");
return;
}
string Languages2 = typeof(ClassLibrary1.Class1).GetTypeInfo().Assembly.GetManifestResourceNames().ToArray();
var present = codes.Where(code => Languages2.Any(x => x.EndsWith($"x.{code}.x"))).ToList();
var missing = codes.Except(present).ToList();
.net embedded-resource
When the embedded resource is named with this kind pattern:
whatever.{xxx}.whatever
Replace {xxx} with one of the following examples: agq,arn,asa,ast,bas,bem,bez,bin. Assembly.GetManifestResourceNames won't find them. There are about a hundred of them. (Check the code below to find them all)
I keep getting the same results be it with .Net framework or .Net core.
Is this kind of naming unauthorized because it looks like some sort of forbidden extension file name? If so, how to disable this dumb security rule.
List<string> codes = new List<string>();
for (char first = 'a'; first <= (int)'z'; first++)
for (char second = 'a'; second <= (int)'z'; second++)
for (char third = 'a'; third <= (int)'z'; third++)
codes.Add(first.ToString() + second + third);
codes = codes.Take(1000).ToList();
string slnPath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName;
while (!Directory.GetFiles(slnPath).Any(x => x.EndsWith(".sln")))
slnPath = Directory.GetParent(slnPath).FullName;
string classLibraryFolder = "ClassLibrary1";
var csjFolder = Path.Combine(slnPath, classLibraryFolder);
var csjPath = Path.Combine(csjFolder, $"{classLibraryFolder}.csproj");
string resourcesFolder = "Resources";
string resourcesPath = Path.Combine(csjFolder, resourcesFolder);
XDocument doc = XDocument.Load(csjPath);
if(!doc.Descendants().Attributes().Any(x=> x.Value == $"{resourcesFolder}\x.aaa.x"))
{
Console.WriteLine("Creating embedded resources...");
Directory.CreateDirectory(resourcesPath);
foreach (var code in codes)
File.Create(Path.Combine(resourcesPath, "x." + code + ".x")).Close();
Console.WriteLine("Updating csproj...");
var xNone = new XElement("ItemGroup");
foreach (var code in codes)
xNone.Add(new XElement("None", new XAttribute("Remove", $"{resourcesFolder}\x.{code}.x")));
var xEmbeddedResource = new XElement("ItemGroup");
foreach (var code in codes)
xEmbeddedResource.Add(new XElement("EmbeddedResource", new XAttribute("Include", $"{resourcesFolder}\x.{code}.x")));
doc.Root.Add(xNone);
doc.Root.Add(xEmbeddedResource);
doc.Save(csjPath);
Console.WriteLine("Please relaunch program.");
return;
}
string Languages2 = typeof(ClassLibrary1.Class1).GetTypeInfo().Assembly.GetManifestResourceNames().ToArray();
var present = codes.Where(code => Languages2.Any(x => x.EndsWith($"x.{code}.x"))).ToList();
var missing = codes.Except(present).ToList();
.net embedded-resource
.net embedded-resource
asked Nov 11 at 21:06
Akli
697720
697720
1
Brr, fighting the .csproj file wasn't a lot of fun. You'll find the missing resources in their own satellite assembly instead of getting embedded in the dll. This decision is made by the msbuild AssignCulture task. Why it thinks that "bin", "bez", etc are valid culture identifiers is not obvious to me. You'll want a different naming convention to avoid this.
– Hans Passant
Nov 12 at 9:26
Compare to this list.
– Hans Passant
Nov 12 at 9:51
add a comment |
1
Brr, fighting the .csproj file wasn't a lot of fun. You'll find the missing resources in their own satellite assembly instead of getting embedded in the dll. This decision is made by the msbuild AssignCulture task. Why it thinks that "bin", "bez", etc are valid culture identifiers is not obvious to me. You'll want a different naming convention to avoid this.
– Hans Passant
Nov 12 at 9:26
Compare to this list.
– Hans Passant
Nov 12 at 9:51
1
1
Brr, fighting the .csproj file wasn't a lot of fun. You'll find the missing resources in their own satellite assembly instead of getting embedded in the dll. This decision is made by the msbuild AssignCulture task. Why it thinks that "bin", "bez", etc are valid culture identifiers is not obvious to me. You'll want a different naming convention to avoid this.
– Hans Passant
Nov 12 at 9:26
Brr, fighting the .csproj file wasn't a lot of fun. You'll find the missing resources in their own satellite assembly instead of getting embedded in the dll. This decision is made by the msbuild AssignCulture task. Why it thinks that "bin", "bez", etc are valid culture identifiers is not obvious to me. You'll want a different naming convention to avoid this.
– Hans Passant
Nov 12 at 9:26
Compare to this list.
– Hans Passant
Nov 12 at 9:51
Compare to this list.
– Hans Passant
Nov 12 at 9:51
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253241%2fgetmanifestresourcenames-some-resources-are-not-embedded-not-authorized%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Brr, fighting the .csproj file wasn't a lot of fun. You'll find the missing resources in their own satellite assembly instead of getting embedded in the dll. This decision is made by the msbuild AssignCulture task. Why it thinks that "bin", "bez", etc are valid culture identifiers is not obvious to me. You'll want a different naming convention to avoid this.
– Hans Passant
Nov 12 at 9:26
Compare to this list.
– Hans Passant
Nov 12 at 9:51