Search code examples
c#sharpdevelop

Troubles with .resx files C#


Recently, I decided to update my program and decided to add the ability to change the language to it. For this, I created .resx files and filled in with data. When trying to compile I got some error related to "AL.exe". After installing the Windows SDK, the error was fixed. Unfortunately, now there was another error when trying to compile:

The task "GenerateResource" has failed unexpectedly.
System.NotSupportedException: The format of the given path is not supported.
   w System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
   w System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
   w System.IO.FileInfo.Init(String fileName, Boolean checkHost)
   w System.IO.FileInfo..ctor(String fileName)
   w Microsoft.Build.Tasks.SdkToolsPathUtility.FileExists(String filePath)
   w Microsoft.Build.Tasks.SdkToolsPathUtility.GeneratePathToTool(FileExists fileExists, String currentArchitecture, String sdkToolsPath, String toolName, TaskLoggingHelper log, Boolean logErrorsAndWarnings)
   w Microsoft.Build.Tasks.GenerateResource.ComputePathToResGen()
   w Microsoft.Build.Tasks.GenerateResource.Execute()
   w Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   w Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() (MSB4018)

Compilation is successful only if I remove all .resx files from the project. Not only those created by me, but also those generated automatically from UI.

I tried to rebuild the project, clean the project, deleted the bin and obj folders.

There isn't any ":" sign anywhere in the filenames.

Files

Deleting dots from filenames also doesn't help :/

How can I resolve my problem?


Solution

  • I solved my problem! My problem was the path of the TargetFrameworkSDKToolsDirectory environment variable.

    The value of my environment variable was TargetFrameworkSDKToolsDirectory=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools, but the correct value is

    C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools.

    The TargetFrameworkSDKToolsDirectory environment variable should be added as user variable instead of system variable.