Project-system: Create a new Resource (resx) file an error occurs

Created on 1 Feb 2017  路  39Comments  路  Source: dotnet/project-system

This bug is created from customer feedback https://developercommunity.visualstudio.com/content/problem/15297/when-creating-new-resource-resx-file-error-occurs.html

When I create a new Resource file, I get following error: "Custom tool ResXFileCodeGenerator failed to produce an output for input file ... but did not log a specific error.". Project is ASP.NET Core on .NET Framework

Blocking-Release Bug

Most helpful comment

My "Error List" window gets consistently filled with this error with every .resx file I create in Visual Studio 2017 15.4.1 and .NET Core 2.0. The project builds successfully, but right-clicking a "resx" file and selecting "Run Custom Tool" produces the error. This issue should be reopened.

untitled

All 39 comments

This looks to occur when when RESX generator returns a null output, which it does apparently when it encounters an error.

I can't repro this. Ask the customer for more info.

@davkean, I had this issue several times, so I can certainly confirm it occurs. I made the test on
1) A VS 2017 RC that has been updated successively for each release
2) A fresh new VS 2017 RC (latest as of today) on a new windows 10 Pro.

This is with .Net Core 1.1 projects. There are two kinds of bugs that are frequent for resx's with VS 2017 RC.

1) The one described here and which I often get if I copy paste the whole solution directory and launch the new copied solution. Adding a new resx gives the message you report. In addition, if you double click on the resx you obtain

this

2) Rename a resx file from Solution explorer and you have this
res2

Renaming it again solves 2, but this error message keeps popping up.

Perhaps the warning below is related to the issue while I used only the NuGet Package Manager Console to add/remove packages:
res3

@Ponant Can you share me the solution?

@davkean , my project is fairly big, so I would rather make a new one and send it to you; jus give me some time and I will come back.

BTW , it is .Net core (.Net 4.6.1)

@Ponant A repro project or specific repro steps would be great. Thanks!

I just made it.
1) Console App Core (4.6.1)
2) No update for Nuget
3) Right click Solution explorer-->new Item-->resource file, name and create

Output:
1) "Custom tool ResXFileCodeGenerator failed to produce an output for input file ... but did not log a specific error.". Project is ASP.NET Core on .NET

2) Rename the file and you get my second pic above

I have to leave in a few minutes so I am not sure I can send it up, let me know if you can repro

It seems to be with a webapp template (empty is enough), no issue with a console app so far

Thanks!

could you reproduce? cheers!

I haven't tried yet, won't be able to look at this until next week.

@Ponant Does your project look like this:
image

Okay, investigated my issue above, and it's due to https://github.com/dotnet/roslyn-project-system/issues/1538.

Also filed https://github.com/dotnet/roslyn-project-system/issues/1539 to track rename, trying to track the other two issues that you called out.

@Ponant Okay, in summary I can repro two bugs with the solution you provided me:

1) Renaming a RESX (or rather any item with metadata) displays an error: https://github.com/dotnet/roslyn-project-system/issues/1539.
2) Moving a project on disk breaks IntelliSense: https://github.com/dotnet/roslyn-project-system/issues/1538.

I cannot repro:

1) Object instance not set an instance of an object when opening a RESX
2) "Custom tool ResXFileCodeGenerator failed to produce an output for input file ... but did not log a specific error"

Can you repro these two issues consistently with a fresh project?

@davkean I can definitely confirm the existence of 1 (Object instance not set an instance of an object when opening a RESX). I have 3 projects which display this form since one week, so the only way to edit or view the resx is to open it with notepad or the like. The other one happened just yesterday.

It is hard to tell you how to make it happen. For instance, as I downloaded the very same project I gave you, I could open the file and no error showed up, which is wierd.
Perhaps the following can help:
1) open 2-3 projects simultaneously
2) create resx's and edit and rename them. VS seems to panic whenever I put a dot in the name of the file.

I can send you one resx that has issue 1, if you want, but I am not sure this will help.

I added 4-5 resx's from another project and all display "Object instance not set an instance of an object when opening a RESX"

Thanks, I'll try against tomorrow. Failing that I might have to get you to attach to VS itself and capture the stack when it occurs.

Okay, I spent another hour on this trying to repro. I can now repro the second error "Custom tool ResXFIleCodeGeneator failed to produce an output for input file" and filed: https://github.com/dotnet/roslyn-project-system/issues/1553.

I still cannot, no matter how many projects and different project types, resx's I create, rename, include "." in their names, repro the "object instance not set to an instance of a open when opening a RESX".

If you can consistently repro this, can I ask you to do the following:

  1. Start another instance of Visual Studio
  2. Choose Debug -> Windows -> Exception Settings
  3. Uncheck the checkbox next to Language Runtime Exceptions
  4. Expand it, and check System.NullReferenceException
  5. Choose Debug -> Attach to Process
  6. Choose devenv.exe, make sure you've selected _Managed (v4.6, v4.5, v4.0) code_
  7. Click Attach
  8. In the other VS instance, repro the bug
  9. When VS breaks in the debugger, Copy the stack from Call Stack window and paste it here.

@davkean I will strip out a project and send it to you.
Here is what I find in csproj, a file which does not exist (but reminiscent of a copy paste)
<EmbeddedResource Update="Resources\Controllers - Copy.HomeController.fr-FR.resx">

@davkean ok go and have a beer and I will do it today, cheers

@davkean , before doing what you want, can you clone and double click on the res files there?
https://github.com/Ponant/ResBugV2

There's no code in that repo. :)

done, I removed controllers and unnecessary stuff and I see the bug appearing, try it out, otherwise I will Stack

@Ponant Awesome I got something - from initial reports it looks like https://github.com/dotnet/roslyn-project-system/issues/1499.

So what, we are done?

You can pull the repo now I have the source, still debugging - want to absolutely confirm that it's the underlying cause.

I deleted the services folder and close the solution and restart and now I can open the resx again. Funny.

Yeah, similar to #1499 - but it's not. Looks like the References are in a bad state and we're null-referring on accessing them.

ok happy to contribute to the mess, cheers

Actually, can you keep that code around? I'm seeing a few other issues as well that I'd like us to fix.

Sure, I will leave them

My "Error List" window gets consistently filled with this error with every .resx file I create in Visual Studio 2017 15.4.1 and .NET Core 2.0. The project builds successfully, but right-clicking a "resx" file and selecting "Run Custom Tool" produces the error. This issue should be reopened.

untitled

I am getting the same problem. I have, in the past tried to move this solution to a different directory, but then moved it back to it's original location. Based on the history, that may be relevant.

Microsoft Visual Studio Community 2017
Version 15.4.1
VisualStudio.15.Release/15.4.1+27004.2005
Microsoft .NET Framework
Version 4.7.02558

Installed Version: Community

Visual Basic 2017 00369-60000-00001-AA555
Microsoft Visual Basic 2017

Visual C# 2017 00369-60000-00001-AA555
Microsoft Visual C# 2017

Visual C++ 2017 00369-60000-00001-AA555
Microsoft Visual C++ 2017

Visual F# 4.1 00369-60000-00001-AA555
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package 8.9.00809.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.0.30925.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2012 4.0.20601.0
For additional information, visit https://www.asp.net/

ASP.NET Web Frameworks and Tools 2017 5.2.50921.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 15.0.30915.0
Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.3.0000.1
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio 2.3.0000.1
Microsoft Azure Data Lake Tools for Visual Studio

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 3.0.17262.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Dotfuscator Community Edition 5.30.0.5167-c98e2f8
PreEmptive Protection - Dotfuscator CE

Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events

GitHub.VisualStudio 2.2.0.10
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

Merq 1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node 2.3.0000.1
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.3.0000.1
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 1.8
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.3.0000.1
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50719.1

Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 4.7.4-pre (c2d89eb)
Support for debugging Mono processes with Visual Studio.

Node.js Tools 1.4.10918.1
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 4.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Python 3.0.17262.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - Django support 3.0.17262.1
Provides templates and integration for the Django web framework.

Python - IronPython support 3.0.17262.1
Provides templates and integration for IronPython-based projects.

Python - Profiling support 3.0.17262.1
Profiling support for Python projects.

SQL Server Data Tools 15.1.61707.200
Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript 2.3.5.0
TypeScript tools for Visual Studio

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio tools for CMake 1.0
Visual Studio tools for CMake

Visual Studio Tools for Unity 3.4.0.2
Visual Studio Tools for Unity

VisualStudio.IoT 1.0
Package with IoT components for Visual Studio

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

WebJobs Tools v1.0.0 15.0.30923.0
WebJobs Tools v1.0.0

Xamarin 4.7.10.22 (fe36bec)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK 8.0.0.33 (HEAD/7a6a056e8)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.2.0.8 (9a9f054)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Opened dotnet#2934.

Was this page helpful?
0 / 5 - 0 ratings