Skip to main content

Microsoft Silverlight

Answered Question Failed to generate code for the service reference RSS Feed

(0)

ScCrow
ScCrow

Member

Member

44 points

107 Posts

Failed to generate code for the service reference

I have a solution with several projects, more than one of which call my WebService and they work.  I added a new project to the solution, put some fields and a button on the screen.  I recompile the solution, and there are no errors.  When I try to add  service reference to my WebService, I get the error below.  Remove the Service reference and no errors.  I also copied the clientConfig from one of the other projects over since the one being genereated is basically empty.  And I copied a version to my base .Web project.   I still get the errror. 

Next, I added a new project, copied over all the code...it worked!   For a few minutes.  But now Im getting the same error again.

Currently, if I delete the clientConfig, and do an update service reference, the file only contains

      <configuration />

And as stated, copying over a good clientConfig does not resolve the problem.

Error 7 Custom tool error: Failed to generate code for the service reference 'myWebSvc'.  Please check other error and warning messages for details. D:\!SilverLight\IsildoSilverlight\Members\Service References\myWebSvc\Reference.svcmap 1 1 Members

Wardy
Wardy

Member

Member

71 points

59 Posts

Re: Failed to generate code for the service reference

D:\!SilverLight\IsildoSilverlight\Members\Service References\myWebSvc\Reference.svcmap <

I dabble in ...
SOA, WCF, Silverlight, XNA, ASP.NET, BPM, Data Cleansing / processing.
... Come visit me @ www.ccoder.co.uk

My current setup ...
Dell XPS M1730 with Windows 7
Raid and SLI in a laptop with the latest from Microsoft, what more could a programmer want !

ScCrow
ScCrow

Member

Member

44 points

107 Posts

Re: Failed to generate code for the service reference

I now have 2 projects with this problem in this solution.  The project compiles and runs if I dont try to reference the WebService in the code.(with the above error message).

I dont know if this helps any, but in the affected projects, I looked at the files in my Web Service.  I see the usual files, I see Reference.Svcmap with a sub of Reference.vb but the two .datasource files are not being generated. 

The two projects deal with login and member data, so Im not going to get much futher unless I can reference the WebService.

Update ***  Ok, I totally reconstructed the project.  Before copying over the code, I created all my Web references,etc. Once that was working, I copied over all the 10 projects code, resources,classes. etc. 

It worked.  That is until I needed to make a change to the WebService. I had to add a space to the end of a Select statement line.  I recompiled the WebService, did an Update Service Reference ...BOOM.  No  .datasource files in some of the projects

On possible clue. All the user controls that are being called into another project are OK.  Top level projects all are failing.  So,,, Next I guess Im going to create a dummy project that does nothing but call the next projects. 

ReConstructing the projects every time just isnt working for me!

 

ScCrow
ScCrow

Member

Member

44 points

107 Posts

Answered Question

Re: Failed to generate code for the service reference

Well,, no responses.   I have finally gotten a solution thats doesnt have this error.  So, If your having this problem do this

  • 1: Go thru all your projectes and delete all the clientConfigs, webService References, and the Service References Directories.
  • 2: In one method or another delete the existing Web Service and Create a new one with all your subs and functions copied over.
  • 3. DO NOT name it the same thing, so somethng like myWebSvc_03_ for the 3d time you have done this process.  Fortunately, on this interation, all seems well. I can even do an update WebService without destroying the links.  Makes me wonder how much junk is hanging out in the code somewhere.  I dont know if this is true or not, but it seemed to have worked best when I created all the projects and then added the sebService last. I do know that I had problems when adding a new project to the solution after the web service was working.
  • 4. Rebuild, and then go add you service references back into your solutions and update the code as needed.

Maybe I should just make the webservice a totally separate entity, but I am the ony one that would use it, so that seemed a additional complication. 

One sort of unrelated note... You may have a solution that has a user control called in it, but itself is not using the web service.  My project requires that I copy a clientConfig from another project.  And then if you do a rebuild of the web service, you my have to update this as well.

Im rather new to Silverlight, but this has been a real pain and a lot of work time lost due to this issue.

So, not an answer, but perhaps a workaround that will save you some of the pain that I have encountered.

Im marking this as answered, although its not really.  At best its a workaround.

lixin123
lixin123

Member

Member

88 points

46 Posts

Re: Re: Failed to generate code for the service reference

Check this,

http://software-development-toolbox.blogspot.com/2009/02/creating-service-reference-failed-to.html

It really fixed the problem for me

klogan
klogan

Member

Member

5 points

5 Posts

Re: Failed to generate code for the service reference

I'm having a similar problem. It was working then stop all of a sudden.  I thought I'd post in hopes of helping someone else figure out their problem.

You can find what is causing the error following these steps. This utility also shows you all the activity that is taking place with your WCF service.

http://msdn.microsoft.com/en-us/library/ms732023.aspx
1. Setup the web.config (or app.config) of the project the service is located in to save the trace
<system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="sdt"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="wcfTrace2.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
a. initializeData can be a path.
2. Download the svcviewer
3. Setup the external tool in VS.
a. C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\SvcTraceViewer.exe
4. View the log to find problems and see what WCF is doing

monica_barback
monica_b...

Member

Member

4 points

2 Posts

Re: Failed to generate code for the service reference

re: "silverlight Failed to generate code for the service reference" 

I do something similar to ScCrow but it might be slightly easier. 

1. Delete the service

2. Add it back with a new name that you never used before

3. Build (you will get errors for your reference)
   Check (e.g. with Intellisense) that the reference to the service exists

4. Delete the service

5. Add it back with the original name

6. It should work :)

 

Michael Knopf
Michael ...

Member

Member

4 points

5 Posts

Re: Re: Failed to generate code for the service reference

Here is another solution: I have had this exact same issue before. In the Properties for the project ensure that you do not have dot-seperated assembly names, in other words an assembly named MyProjects.MyAssemby because this can cause the issue. I was able to resole the issue by removing this the dot (so MyProjects.MyAssemby ==> MyProjectsMyAssembly) and then simply executed the "Update Service Reference". The Reference.cs file, which had been empty on previous attempts, was correctly populated and the service worked as it should have. Hope this helps others who run into this issue

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities