Skip to main content

XM Cloud - Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies

Hello Folks,

Today's blog post is to share one of the weirdest behavior i came across while working with Sitecore XM Cloud head repository.

I worked on it for couple of days, Created new projects for custom resolver and tested everything in local, and all the time i was using publishing profile and it was just working fine.

But out of the blue my local started getting below exception

Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Looking at error you generally match dll versions, web.config had different bindings and bin also had same file but somehow my docker->deploy->Platform->bin was getting 5.2.6.0 version instead of 5.2.7.0

but suddenly i realized, my docker->deploy->Platform->bin should only have those DLLs which are my custom code, my project DLLs but it had all DLLs and that broke the whole site

So actual issue was my docker->deploy->platform->bin folder should only have those file which are either of custom projects & platform DLLs, but in my bin i had all sorts of DLLs being copied, see below screenshot, Instead of all DLLs, it should only have my custom DLLs of project.


 

So, I tried below steps 

1) I cleared package manager cache

2) Removed all reference of the project from platform & again redeployed

3) I changed from debug to release in publish profile configuration like below 

<LastUsedBuildConfiguration>Release</<LastUsedBuildConfiguration>

3) Deleted BIN and changed the publish folder path in my config to something else instead of platform, as out of the clue just wanted to see there is nothing related to that, but with my surprise it only copied my custom DLLs

4) I cleaned the project and build it again & republished again, and the most wired thing, it copied all those DLLs again and again i run into DLL hell issue of YSOD

Out of the clue i reached out to SLACK channel & Sitecore support for this behavior and they acknowledged that it is a bug currently in publishing profile & if you do not change anything and deploy, it copies all the DLLs & publishing profile target's are not working as expected.

Following is my OOTB platform.wpp.targets file which shipped with head repository 

https://github.com/sitecorelabs/xmcloud-foundation-head


 

Issue is with line no.16 where the " <Target Name="ExcludeSitecoreAssemblies" AfterTargets="Compile">" 

If you remove that line completely and make sure to restart your visual studio and do Clean & Publish, it will not only copy needed DLLs and everything will work

So finally my wpp file looks like below (Make sure to restart VS studio after the change)

As you can see in above image Target node is removed and now if i close my visual studio and do clean & build and publish again, it is only copying needed DLL and no more DLL hell issues 


Key take away & solution

1) Target tag which is available OOTB in wpp file works unpredictable

2) Publishing profile is misleading because, Sometime it works when we apply filter only when compilation happened, if no changes to the project it will publish everything. 

3) You have to remove Target tag from the wpp file & restart visual studio to make it work. 

NOTE: This was registered as a bug in Sitecore bug tracking system and reference number for this bug is 582640

I hope this will help other do not end up in the same issue as i did


Comments

Popular posts from this blog

Why SitecoreAI - Getting into the shoes of the customer how to select right CMS

Hi Team, Lately, I have been talking to lot of our customers / potential customers and having pre-sales demos where one question always comes is "Why Sitecore" ?  Now this question can be for any product which is out for sell. And as a technician I always get into product technical features, but at the same time as a pre-sales guy, it also makes me think, surely all competitive products have same features, so definitely answer to this is not in the technicalities.  If you step back and think, we are also a customer in our daily life and buy lot of things, what is that process we go through? When we buy, how can your customer decide if this is a right fit for you or not, why we select A over B? Is it price? is it service? Is it a brand? Is it about features? Is it about brand loyalty?  When it is a technical product, I am sure it cannot start with the technicalities of the product or selecting product itself, 100% not, I feel decision is always business strategy first and ...

Hell of sitecore aliases pipeline breaking the site with 500 error

Hello Friends, I belive this blog post is very important for everyone because, It has some very serious effect on working of your headless website, i will share my experience what we faced and how we resolved it Issue we started facing Our site started giving "Key cannot be null or empty" with YSOD like following  Side affect Because of this 500 error, Our site pages were showing 500 custom error page intermittently and our MAU (Monthly Active User) drop rate increased. Sitecore KB There is already Sitecore KB article talking about this error but the patch which is provided on this link is confusing as well as very huge and it could bring other issues along with it as that upgrade patch also has lot of other things too which i did not want to introduce in our stable CMS. Known Issues - Retrieving the child items of resource items is not thread-safe Observation Though the surfaced exception was looking similar and giving same error and behavior given on this article, We looked...

401.1 Unauthorized with windows authentication error code 0xc000006d

How many of you have faced this hosting issue when you do everything what it takes to run the site with windows authentication but still you are getting the same error again and again? If you think you also have faced the same issue and you tired of reading MSDN KBs for it and still have not found the issue (If KB has solved the issue, well and good, if not you can try this trick),Please Read below Typical scenario In typical hosting with IIS, i did every possible things like enabling windows authentication, changing it in web.config, configuring connection pool, authorization rules, it asks me for window authentication login and despite of entering correct credentials it always fails and keeps on asking for login, and when pressed cancel it gives 401.1 with 0xc000006d error code Solution (Which worked for me at-least after trying for almost 6-9 hrs) You need to change the Loop Back Check in registry so that it allows the host names which you are giving in url are allowed and au...