Within last few days I’m facing really weird problem, I did my best to overcome it, but it seem so abstract to me that I don’t even know where to look any further. I’ve read all related threads here, on SO, and many other sites that google found for me. Case is pretty complicated, but please bear with me:
I work on a project which has MVC web portal front-end that is communicating with back-end infrastructure using WCF web services, some are written by us, some are WWF services. All services are using simple http binding. I was given a task that required me to change service’s contract, and hence updating service reference. Update did not succeed, giving me following set of warnings/errors:
Warning 43 Custom tool warning: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. PathToProject\Reference.svcmap 1 1 PortalProjectName
Warning 44 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
XPath to Error Source: //wsdl:definitions[@targetNamespace='namespaceDeclaredInService']/wsdl:portType[@name='IEntityListService'] PathToProject\Reference.svcmap 1 1 PortalProjectName
Warning 45 Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='namespaceDeclaredInService']/wsdl:portType[@name='IEntityListService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='WSHttpBinding_IEntityListService'] PathToProject\Reference.svcmap 1 1 PortalProjectName
Warning 46 Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='WSHttpBinding_IEntityListService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='EntityListService']/wsdl:port[@name='WSHttpBinding_IEntityListService'] PathToProject\Reference.svcmap 1 1 PortalProjectName
Error 47 Custom tool error: Failed to generate code for the service reference 'EntityListService'. Please check other error and warning messages for details. PathToProject\Reference.svcmap 1 1 PortalProjectName
I’ve found that this can be solved by having web service not reuse types from referenced assemblies. I Did that, then I’ve found out that (ofc) I have ambiguous types references in code. Anyway, this solution I did just for test purposes, since reusing types from referenced assemblies is just what I want. So I checked reuse checkbox back and started experimenting.
From portal project I removed all references that caused problem (from which types were ought to be reused), than updating reference worked (it’s pretty much equivalent to not reusing), build of course not.
Then I figured out that this may have something to do with some hidden error in any of these assemblies being part of the same solution. So I tested this hypothesis building one of these projects and referencing it from Portal as dll. All the same.
Then, by investigating some more I’ve found out that this error occurs also when I remove references to assemblies with types that I want to reuse and add reference to project “Resources” from portal (no types from this project are used in portal or web service).
Resources contained one class (attribute) and one resources file (cs+resx).
So now I have Portal project with added reference to resources, no reference to any project that originally caused error and error still occurs. Then I saw that access modifier in for resources file in resources project is set to Public. I switched it to internal, and then I successfully updated service reference. Problem is, that this have to stay public, since other projects use these resources, including these containing types that I want service to reuse.
While googling on this subject I’ve found people saying that these help:
- restart VS
- run VS with no admin privilages
- uninstal VS 2012 RC and reinstall VS2010
- delete and add reference from scratch, restarting VS between these
steps
In my case neither of these solutions helped.
From my point of view it is very strange, any help will be greatly appreciated, since, as for now I have no solution for this problem.
Edit:
In resources project I’ve made a proxy class, and make actual resources internal. That made build possible, and update reference worked when portal referenced only resources project. After adding references to other assemblies from project it’s all the same.
It turned out that problem was caused by log4net.dll, which was built against .NET Framework 3.5. We made our own dll against .Net 4.0 and all problems are gone.