In a Windows Phone 7 Silverlight project, I had a service reference to a WCF service. This morning when I opened up the project, suddenly the namespaces for my WCF service were unknown. The option for "Update Service Reference" in Solution Explorer was not there, so I deleted the Service Reference with the intent of re-adding it. But the option for "Add Service Reference" is also not there. Gone. Disappeared.
Closed and re-opened the solution. Restarted VS2010 Ultimate. No dice. Anyone run across this?
I don't know how this happends in the first place, so we don't know the cause yet, but I found a solution to the problem.
Open your *.csproj file in Notepad or Textpad or something like that. Find where it has the tag. Replace that tag with this:
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Close and re-open the project and the option to add service references will be usable.
In my case,
I changed my target framework from .Net Framework 2 to .Net Framework 4. The "Add Service Reference" appears immediately
Change Project Properties
I had the exact same problem with the missing "Add Service Reference" context menu option in Visual Studio 2017 with a regular C# desktop app project.
For me, the problem could be fixed by simply re-creating the entire project solution from scratch within Visual Studio. It turned out that the original project solution file had been created by an earlier version of Visual Studio, and this seems to have caused the problem.
Related
I'm having issues adding a service reference to my WPF project in VS2017. The service itself is a WCF Data Service using EntityFramework (EntityFrameworkDataService). In VS2013 that I was using before, I didn't have any issues adding services to my WPF project. I upgraded to VS2017 last month, and recently made some changes to the WCF service and needed to refresh the reference in my WPF project. I couldn't seem to get it to refresh so I deleted the reference and started trying to re-add the reference and now I'm greeted with this error message:
The specified OData API cannot be added because OData APIs are now
only supported with Connected Services.
For more information, please see:
https://aka.ms/odatavsclientguidance
That provided link does not have any info regarding VS2017 setups. It recommends to use the 'OData Connected Service' extension but that extension does not support VS2017 (tried it but got a "not compatible" message). I also found the 'VS WCF Connected Service' extension for VS2017, but it doesn't appear to support WPF projects (or atleast I couldn't figure it out).
Has anyone ran into this issue with adding a WCF Data Service reference to a WPF project? Any other suggestions that I could try?
I typically generate my clients via the DataSvcUtil.exe which is part of the .net framework
e.g.
"%windir%\Microsoft.NET\Framework\v4.0.30319\DataSvcUtil.exe" /dataservicecollection /version:2.0 /language:CSharp /out:c:\temp\DataService.cs /uri:http://localhost:16584/DataService/
The MSDN docs:
https://msdn.microsoft.com/en-us/library/ee383989(v=vs.110).aspx
As TGRA so eloquently stated, the best bet for VS2017 at time of writing is to use the dataserviceutil.exe. To make things simpler for myself I do the following:
In File Explorer, navigate to the datasvcutil.exe using the path as follows:
%windir%\Microsoft.NET\{{YOUR_PROCESSOR_ARCHITECTURE}}\{{YOUR_FRAMEWORKVERSION}}
Hold shift and right-click. Select Open Commandwindow here (or command prompt if you prefer.
Now execute a datasvcutil.exe command like so for C#: datasvcutil /language:Csharp /out:{{PATH_TO_PROJECT}}/{{SERVICE_NAME}}.cs /uri:{{URL_TO_SERVICE}}.svc
OR execute a datasvcutil.exe command like so for Visual Basic: datasvcutil /language:VB /out:{{PATH_TO_PROJECT}}/{{SERVICE_NAME}}.VB /uri:{{URL_TO_SERVICE}}.svc
And voila, you're done.
This question is different from the questions posted here and here even though the titles are the same.
The problem arises intermittently. The error always occurs if the project has been cleaned or is being built from a fresh checkout. Pushing build again immediately usually results in the build succeeding. The stacktrace I get is:
error MSB4018: The "CreateRiaClientFilesTask" task failed unexpectedly.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.
at System.IDisposable.Dispose()
at Microsoft.ServiceModel.DomainServices.Tools.CreateRiaClientFilesTask.GenerateClientProxies()
at Microsoft.ServiceModel.DomainServices.Tools.CreateRiaClientFilesTask.ExecuteInternal()
at Microsoft.ServiceModel.DomainServices.Tools.RiaClientFilesTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1c.MoveNext()
The problem also occurs intermittently during regular edit-build-execute cycles, and sometimes a restart from Visual Studio is required to make it work on these occasions.
The problem occurs both in MSBuild and Visual Studio 2010. I have all of the latest updates installed (WCF RIA Services SP2). It occurred when using the Silverlight 4 tools, and upgrading to Silverlight 5 has not solved the problem. The problem also still occurs in the beta of VS 11.
I've not been able to change the order of the build as described here (referenced from here) as MSBuild complains of a circular dependency and Visual Studio says that I can't reference a non-Silverlight project from a Silverlight one. From that page I have also tried following this link and changed the default ToolsVersion from 2.0 to 4.0 in the registry.
I'm definitely using the 32 bit version of MSBuild, as trying to use the 64 bit version fails with failing to Hydrate the entity framework model. I'm not using the /m switch to build it in parallel either.
The project was initially a web project (which hosts the site that the Silverlight control lives on, RIA services, and contains the Business logic) and a Silverlight project. Changing this to 3 projects (with a class library containing the logic) doesn't make any difference.
The next thing I'm planning on trying is having the project hosting the RIA service separate from the one hosting the Silverlight app, but that's not ideal for us (and I'm not even sure it will work).
In my case, this exception was caused by McAffee's anti-virus application. Disabling the 'On-Access' (or was it 'On-Demand') feature resolved the issue.
I had a similar issue in the past with Microsoft's Security Essentials which was resolved by adding the exclusions below. I suspect that it is the 'Temporary ASP.Net Files' folder exclusion that would be required to solve the issue here.
Excluded Files and Locations
C:\Temp\Default\NuGet.exe
C:\Temp\NativeImage\NuGet.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
NuGet.exe
Excluded Processes
C:\Program Files (x86)\Common Files\microsoft shared\DevServer\11.0\WebDev.WebServer40.EXE
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Microsoft.VisualStudio.Web.Host.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
This exception is driving me crazy! I also tried to clean ASP.Net temporary folder, clean all projects in the solution, run VS as administrator etc. But still I have this problem. My solution to the problem is twice rebuild Web project.
In our case we ran into the same problem as reported in another answer to this same question (https://stackoverflow.com/a/14125687/223837): McAfee strangely interfered with the files in 'Temporary ASP.NET Files'. But in our case we could not disable McAfee or change the excluded folders because of company policy.
But we found a different solution: what we did is update the machine.config file (in our case C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config), and add a <compilation tempDirectory="..."/> element, as follows:
<configuration>
<!-- snip -->
<system.web>
<!-- snip -->
<compilation tempDirectory="c:\A_FOLDER_THAT_IS_SKIPPED_BY_MCAFEE\TempASP.NETFiles\"/>
</system.web>
<!-- snip -->
</configuration>
(Inspiration for this solution direction came from an answer to a related question: https://stackoverflow.com/a/1255303/223837.)
I had the exact same thing happening to a couple of my projects. I found (inferred really) it was related to my upgrade path of RIA and Silverlight. I got a new machine, with all the updates on and it STILL happened. However, when I re-created the projects from scratch (copying the files over, and settings, NOT the 'generated' assembly information), the problem went away.
Not a definitive answer you'd expect I suppose, and to be honest, re-creating the solution from scratch was a pain. I do suspect (and the only conclusion I could bring) it was related to some GAC declaration or other that was asking for an earlier version of the RIA framework.
I HAD installed a version of RIA and coded using it, and there were a couple of Silverlight updates that happened in quick succession during this time. I have had no problems since.
I found a solution to this problem which has so far fixed the issue on every server and client that I've run it from.
My initial project layout had a Web Project which acted as a host for both the RIA components and the Silverlight app itself. I created a class library for the RIA services, moved all of my RIA logic into there and added a reference to it from the Web Project. Then I updated the RIA link in Silverlight to point to this new project.
I had to add the following line into the Silverlight app.xaml.cs file so that authentication worked.
((WebAuthenticationService)WebContext.Current.Authentication).DomainContext
= new RiaNamespace.AuthenticationDomainContext();
Remove or disable your virus-scanner during build. Worked for me too!
I had the same problem.
I just changed the "Assembly Version" number and my project was OK.
I have a Silverlight enabled WCF service, and a Silverlight 4 project that references it.
The service used to work nicely until I merged some changes another developer made into the service, since then the Silverlight project failed to call the service with "Server not found" error.
I removed the reference to the service, tried to add it again but this failed with error "Object reference not set to an instance of an object".
This is not limited to the above service anymore, this error happens every time I try to add any WCF service to the Silverlight project.
I am using Visual Studio 2010 and the .NET Framework 4.0 for all projects.
This problem has happened before and I was able to solve it be creating a new solution, creating fresh projects in it and then adding the code files to the projects one by one. However, this is a nightmare now that my solution contains dozens of projects and hundreds of code files.
anyone out there with a fix for this? I googled this a dozen times and all I got was fixes to similar problems that happened with Silverlight 2 and Visual Studio 2008, but these fixes didn't work for me.
Thanks.
Make sure your WCF service is working properly. Right click on the SVC file and select View in browser. If there is a runtime problem, that should point you in the right direction.
Have you tried switching WCF tracing on? I find it normally provides clues to the problem source. Also, have you checked your Silverlight client config? Are the end point addresses all correct?
My VS2010 doesn't stop at breakpoints inside of silverlight application. It appears that no symbols for it have been loaded during debugging. When I hover over the break point it says "The braekpoint will not currently be hit, no symbols have been loaded".
I have tried all of possible solutions offered by google and have no success. The problem occurs even when I create brand new silverlight app hosted by an ASP .NET web project. All of my project configuration looks fine - silverlight debugging is enabled in the Web project.
I am using silverlight 4.
here a link to the sample project created out from the tepmlate.
Any thoughts ?
P.S I just tried to reinstall VS2010 and the problem still exists.
EDIT: I just tested the same project on another machine and it stops at the break point it seams that the problem is somewhere in the configuration of VS or silverlight.
with Matt Dotson's help I managed to attach the debugger manually. However this solution is not good enough for daily use.
Depending on my experience in Silverlight following these steps keep your project debug-gable.
Condition 1>
Firstly we need to be ensure that in Web Project's properties there is a Web section, as you see below Silverlight checkbox must be checked.
Condition 2>
Follow In Menu Debug => Attach Debugger>
Visual Studio sometimes can't attach debugging platform you need to lead the way :) . By this way you may debug other platforms,(also you may debug your product platform but pdb files must be sync and don't forget you may suspend your product platform using this).
Condition 3> Your default web browser may be Firefox,Chrome or other than IE.By Visual Studio default try to attach to IE. But when you run VS calls default browser,so you need to have a manual attachment in Condition 2 or set your default browser by right clicking on default page > Browse with .
Condition 4> There is xap file generally located in web project\ClientBin directory. Sometimes after build operations this file can't be replaced and your ProjectDll and your Project PDB files not be sync. This cause wrong line match while debugging or can't find a debugging file attached caution. I strongly suggest delete all generated files in Bus project and delete Clientbin\ProjectName.xap file. After rebuild all it must be ok!
Hope helps.
What broswer are you using? You need to be using Internet Explorer to debug silverlight projects.
I have had a similar frustrating experience with this but in my case the solution was very simple. It seems that somehow, and I really have no idea how, the debugger option for Silverlight had become unchecked in the properties on the hosting ASP.NET project.
I just assumed that as I had been previously debugging, this option was set and I didn't bother to make sure that this was this case. Just goes to show that one should always check the basics first; if I had done that it would have saved me some time.
To check this in VS2010, right-click on the project and select properties, change to the Web tab and check the Silverlight option at the bottom of the page, in the debuggers section.
Also see the debugger to a silverlight process
http://msdn.microsoft.com/en-us/library/cc838267(VS.95).aspx
If that doesn't work, then
reset iis (if you are debugging in that)
delete temporary asp.net files (%SystemRoot%\Microsoft.NET\Framework\versionNumber\Temporary ASP.NET Files)
clean and rebuild your solution
The resolution came after 2 days of headbanging. It appears that the link which Malcolm gave covers exactly my problem but my I was narrow-minded enough not to pay it enough attention because when I run the debugger as long with the app my default browser was FF. So I thought that after the FF starts I can load the page from IE or Chrome.
Actually the problem is that the debugger cannot be attached to the silverlight project because of the FF. And when I load the app from IE or Chrome the debugger dis still not attached.
Thanks to everyone that tried to help.
if you have multiple project, Rebuild the project separately that you want break point. Its work for me
Try also picking internet explorer from browser list menu as your browser
I built a WPF application in VS.NET 2008 using ClickOnce deployment. It ran great on any machine that had VS.NET installed, but my business users received an error: "Unable to install or run the application. The application requires that assembly Microsoft.Windows.Design.Extensibility Version 3.5.0.0 be installed in the Global Assembly Cache (GAC) first."
I was surprised to discover that this dll is not part of the standard .NET 3.5 SP1 client installation, but somehow, my application thought it was needed. I checked my Publish tab for the project and it showed up as a prerequisite.
Oddly enough, I was able to just remove this (and all of the other Microsoft.Windows.Design.* dlls) and it just worked everywhere. I removed them from my project entirely, and everything was fine.
Can someone explain why the VS.NET 2008 project wizard forced these to be included in the project, and more importantly, why ClickOnce thought they needed to be on the client machine to run?
This is just a curiosity question, but I'm sure I'm not the first to be bitten by it. Hopefully, this post will at least save someone else the headache.
Try to remove all references to *.Design.dll. In my case it was WPFToolkit.Design.dll.
This is old and the OP is gone, but I ran into this today, so I thought I'd mention that my solution was removing a reference to one of the WPFToolkit references that ends with .Design.
I had referenced System.Windows.Controls.Input.Toolkit, but also had a reference to System.Windows.Controls.Input.Toolkit.Design, which should not have been there. Removed it, and all was right with the world again.
A way to find out the code that is loading the assembly is explained here:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/755272f6-0e79-4a6d-ae50-4412d0f2bc4c
I found that I was using the SelectionCommands.Clear property which is inside the Microsoft.Windows.Design.Interaction namespace inside the Microsoft.Windows.Design.Extensibility Version dll.
Beats be why this dll isn't included in the .NET 3.5 install.