Why am I receiving this when trying to create a new UE4 C++ project ? (only C++ projects)

0

I receive an IO Exception for a project file that does not exist (I just tried to create that project)

I tried Visual Studio 2017 instead of 2019 (for compatibility problems with UE 4.22.3) and I couldn't find anything wrong with my windows SDKs (some people on Unreal Engine forums said it could be the problem) and VS Configurations.

Running C:/Program Files/Epic Games/UE_4.22/Engine/Binaries/DotNET/UnrealBuildTool.exe  -projectfiles -project="C:/Users/Director/Documents/source/repos/Phz/Phz.uproject" -game -rocket -progress
Discovering modules, targets and source code for project...
ERROR: Unhandled exception: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\Director\Documents\source\repos\Phz\Intermediate\Build\BuildRules\PhzModuleRules.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
       File name: 'file:///C:\Users\Director\Documents\source\repos\Phz\Intermediate\Build\BuildRules\PhzModuleRules.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
          at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
          at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
          at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity)
          at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
          at UnrealBuildTool.DynamicCompilation.CompileAssembly(FileReference OutputAssemblyPath, HashSet`1 SourceFileNames, List`1 ReferencedAssembies, List`1 PreprocessorDefines, Boolean TreatWarningsAsErrors) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\DynamicCompilation.cs:line 358
          at UnrealBuildTool.DynamicCompilation.CompileAndLoadAssembly(FileReference OutputAssemblyPath, HashSet`1 SourceFileNames, List`1 ReferencedAssembies, List`1 PreprocessorDefines, Boolean DoNotCompile, Boolean TreatWarningsAsErrors) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\DynamicCompilation.cs:line 427
          at UnrealBuildTool.RulesAssembly..ctor(DirectoryReference BaseDir, IReadOnlyList`1 Plugins, List`1 ModuleFiles, List`1 TargetFiles, Dictionary`2 ModuleFileToPluginInfo, FileReference AssemblyFileName, Boolean bContainsEngineModules, Boolean bUseBackwardsCompatibleDefaults, Boolean bReadOnly, Boolean bSkipCompile, RulesAssembly Parent) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 109
          at UnrealBuildTool.RulesCompiler.CreateProjectRulesAssembly(FileReference ProjectFileName, Boolean bUsePrecompiled, Boolean bSkipCompile) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesCompiler.cs:line 488
          at UnrealBuildTool.ProjectFileGenerator.AddProjectsForAllTargets(PlatformProjectGeneratorCollection PlatformProjectGenerators, List`1 AllGames, ProjectFile& EngineProject, ProjectFile& EnterpriseProject, List`1& GameProjects, Dictionary`2& ProgramProjects) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 2104
          at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String[] Arguments) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 674
          at UnrealBuildTool.GenerateProjectFilesMode.Execute(CommandLineArguments Arguments) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\GenerateProjectFilesMode.cs:line 172
          at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 443

"Phz" is the project name used in those DLL names. Is there any specific .NET Framework SDK or something I'm missing ? (An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch)

unreal-engine4
asked on Stack Overflow Jul 17, 2019 by Director • edited Jul 17, 2019 by Botje

2 Answers

0

You can create a Blueprint project and convert it afterwards in a C++ project, by creating a C++ class. Go to File->New C++ Class

answered on Stack Overflow Jul 22, 2019 by ProRedMax
0

The reason why you're receiving that error message is given in the error message:

ERROR: Unhandled exception: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\Director\Documents\source\repos\Phz\Intermediate\Build\BuildRules\PhzModuleRules.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

Since the file appears to be on your local C drive, I would suspect it is a dependency you have on a network share - or perhaps you have some complex junction setup where one or more of those directories are pointing to network locations. In any case, if you search for the end of that line ie. HRESULT: 0x80131515 you can find another SO question about the same error from back in 2011.

There is a relatively simple solution, from that SO thread, that you can find here https://stackoverflow.com/a/8535963/1327399. Based on my testing however, this solution does not work. The devenv executable doesn't appear to be involved in ue4's 'generate project files' command. My research was unable to locate a binary/config file pair to apply this solution to specifically affect UE4 and as few other things as possible.

Something that did work: I was able to find what appears to be a nuclear option from another SO thread (ie. .net 4 framework-wide).

Definitely worth noting, as done in this 2011 blog post about this issue, that the solution may have unforeseen vulnerabilities as running code from a network location has clear risks.

At the end of the line you singled out, at the end of your post, you can find the basis of the above solutions.

please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

That link: http://go.microsoft.com/fwlink/?LinkId=155569

If someone were more keen, I am sure they could delve into the unreal build tool source code and find a more suitable home for the xml line. Which based on the examples, appears to need nesting inside a particular hierarchy within whichever configuration file it is placed in.

Additionally, but this probably isn't worth noting [here] - in my virtualized windows environment, ue4 generated the project files onto my NFS share but also encountered an error. An error which appears to be erroneous; likely a bug in the microsoft NFS drivers, but who knows. The error indicated there were write faults, which turned out not to have happened [at a catastrophic level at least] as the files were, in fact, written to and I was able to open them - I did not do any work, so I did not test whether I could save changes without problems.

answered on Stack Overflow Jul 19, 2020 by Josh C • edited Oct 14, 2020 by Josh C

User contributions licensed under CC BY-SA 3.0