Could not resolve mscorlib for target framework '.NETFramework,Version=v4.0'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted wcf update service reference issue
I am feeling little good about writing this blog as this might help many, as i searched for the suggestion on the net for couple of days but may be i didn't google it properly (I can not say google does not have solution :) ), but finally if ends well everything is well, i got the solution of this nightmare kinda issues
The Issue
I faced this issue and i saw on the net the plenty like me had the same issue, that one fine morning your service reference stopped updating, or you can't do anything with them, which were working fine earlier, You can't update service reference, you can't delete them, once you remove everything and give the reference again, the error fires back again and you can't repeat the same procedure of deleting and inserting the reference over and over
See the following screen shot
Above is the screen shot which i kept on getting and searched for the solution with best of my googling capabilities untill i got the solution which is below, Before that there were many solutions like the classe names which WCF (wsdl) generates were larger than 256 characters, But i could not use that solution for some reason, other solutions were re intalling some of the MS tools and re installing them, Below is the solution which worked for me and i am posting so other can also make use of it
Solution
Creating a batch file instead of manually adding service reference (WCF reference) will only generate the wsdl files which is required to access the data of it and functions inside it and via which the above error will be gone
@ECHO OFF set UIProjectServiceRefPath =..\..\MyApplication\ServiceReferences set SVCUTILPATHValue =C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools ECHO Generating CommonService.CS "%SVCUTILPATHValue %\svcutil.exe" /o:"%UIProjectServiceRefPath %\CommonService.cs" /reference:"c:\MyDomainService\bin\Debug\Domain.dll" /serializer:Auto /edb /ct:System.Collections.Generic.List`1 /ixt /namespace:*,MyService.CommonService http://localhost/MyService.BLL/CommonService.svc?wsdl set /p delBuild=press any key to exit:
- Create a .bat file (batch file) like above, very first line after echo is where you want to have those class files to be created, this would be same path where your WCF service reference were getting created, so replace your path having that in mind
- Second Echo statement is your actual service file which you want to generate, now if you have 3 services, you will these type 3 echo statements with their respective paths, here /reference is any reference DLLs your WCF might be using, so give those DLLs path there, you can have multiple /reference nodes followed by one another
- /namespace is via which you will be referencing your classes to create their objects, and .svc is your hosted WCF service, the path which you were using to add service reference.
Now remove your existing "Service reference" folder which you have generated from previous WCF manual add service reference from windows explorere and also from your solution, and doucle click this file, it will generate "ServiceReference" folder at the smae place and inside that it will put above .CS files which is in .dat file
Your are good to go, go to your solution include this folder and build your project, if you have configured it properly it will build with no error, and now whenever you want to update the service reference, just double click this file to generate new WSDLs
Feel free to comment here in case of any doubt, I would like to mention here the valuable help from http://k-sharp-net.blogspot.in/ (Kamlesh samnani, very good colleague of mine)
This comment has been removed by the author.
ReplyDelete