Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom tool error: Failed to generate file

Tags:

c#

.net

winforms

I'm working on a windows application (C#) that was created in VS 2012 (Framework 4.5) windows forms. The requirements requires it to be used for older versions of windows so I'm setting the target framework to .NET Framework 4 and Platform target to x86. Once its done and I try to compile I get the following error:

Custom tool error: Failed to generate file: The service reference is not valid for the current .NET Framework version or project type. You can change the service reference configuration in the .svcmap

I tried unchecking the box "Reuse types in referenced assemblies" in the Service References before flipping to framework 4 but no luck.

like image 612
Danno Avatar asked Dec 09 '13 17:12

Danno


2 Answers

Instead of re-adding the reference you can also remove the code which is not understood by .NET 4.0 from the Service References\<reference name>\Reference.svcmap file. Note that you will need to navigate to this file via explorer, it does not show up in Visual Studio. For my references, I simply removed this line

<GenerateTaskBasedAsynchronousMethod>true</GenerateTaskBasedAsynchronousMethod>

Then right-click the service reference in VS2013 and hit "Update Service reference". It will rescan the service and generate the Reference.cs file so that it is compatible with .NET 4.0.

like image 61
Chris Avatar answered Nov 01 '22 08:11

Chris


Apparently, sometimes this error can be avoided by simply re-adding the reference. Have you tried that?

like image 22
Chris Barlow Avatar answered Nov 01 '22 09:11

Chris Barlow