Skip to main content

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)

Comments

Post a Comment

Popular posts from this blog

Sitecore Technical Workshops - Top FAQs customers asked on XM Cloud

Hi Readers, I want to talk to you about interesting things which we have been doing which is "Technical Workshops" for our customers, so here goes the scenarios. So, we have been doing multiple types of technical workshops.  1) Training customer and their Sitecore technical team on latest and the greatest technologies like XM Cloud & Another composable stack and try enabling them for new Sitecore tech stack. 2) Customers / Potential Customers have their agenda of existing pain points, and we take a workshop on topics around them with best practices etc. little on new technologies, so they also know the future. Basically, we prepare custom targeted presentations & demos for individual workshops, and make sure it helps them answer their questions and they get insights of where Sitecore eco systems has to offer from their versatile toolset and try to keep them up to date with it. So, Purpose of this blog is, because in all these customer & their technical team's

Set up leprechaun code generation with Sitecore XM Cloud Starterkit

Hi Sitecorians, It has been amazing learning year so far and with the change in technology and shift of the focus on frontend frameworks and composable products, it has been market demand to keep learning and exploring new things. Reasons behind this blog Today's topic is something that was in my draft from April-May, and I always thought that there is already a good documentation out there for  Leprechaun  and a blog post is not needed, Until I realized that there was so many of us facing same kind of issues and same kind of problems and spending same amount of time, That is where I thought, if I could write something which can reduce that repetitive troubleshooting time, That would really help the community. 1)  In a project environment, if we get into some configuration issues, we resolve them, we make sure we are not blocked and continue, but if you think same issue, same step and same scenario will come to other people, so if we can draft it online, it will help other people 2

Sitecore Solr/SearchStax Auto Suggestions - suggester was not built error and fix

HI Team, This one will be very quick blog post, But sharing it here so it helps anyone on the internet having same issue Problem We are using SearchStax and we have been using auto suggestions functionality of it, Everything was working fine and suddenly lot of users started reporting that they are not able to search anything in the search box. As this was P1, I started looking into the probable cause and logs, first i saw in console that we were getting 500 error, that means there is some issue being thrown from the backend. Upon checking logs found following in logs  The error was "suggester was not built" Well, I knew there is some issue with suggester which causing it to fail, but puzzle was, It has always been working for us Now, because we have this error on SearchStax documentation, If you refer below link, it says  https://www.searchstax.com/docs/hc/suggester-was-not-built/ "The root cause is often query fields that are not defined in the Solr schema. Look in the