Skip to main content

Posts

Showing posts from March, 2014

No exports were found that match the constraint: ContractName Microsoft.VisualStudio

Today morning when I opened one of my projects in Visual Studio 2012, I got mentioned below error: “No exports were found that match the constraint: ContractName Microsoft.VisualStudio.Utilities.IContentTypeRegistryService RequiredTypeIdentity Microsoft.VisualStudio.Utilities.IContentTypeRegistryServicePlease correct before proceeding. (You might rename the current web.config and add a new one).” Reason: It seems error occur when the .NET 4.5 framework is updated via recent windows 7 updates. Solution: I resolved this issue by removing the files inside the Visual Studio Component Model Cache folder at this specific location for Visual Studio 2012. C:\Users\{username}\AppData\Local\Microsoft\VisualStudio\11.0\ComponentModelCache If you facing this issue with Visual Studio 2010 then the relevant location is: C:\Users\{username}\AppData\Local\Microsoft\VisualStudio\10.0\ComponentModelCache Or if you facing this issue with Visual Studio 2013 then the relevant lo

System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException: Operation is not valid due to the current state of the object.

You might have sometime faced the below exception while attempting to update an entity property: System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException: Operation is not valid due to the current state of the object. Reason: After looking into the issue I found that this error occurs when an attempt is made to change a foreign key when the entity is already loaded. In this case, I was trying to assign a value to the foreign key property, and an exception is thrown as foreign key fields and association properties don’t match, when changes are submitted. In such a scenario there are two values, one in the foreign key field or the one on the other side of the relationship and it doesn’t know which value is correct, and as a result exception is thrown. Solution: To avoid the exception the best way to update the relationship is by changing the association property and not the foreign keys. And then it will automatically keep the foreign keys in sync when you assign the association prop

C#: Understand about IEnumerable vs. IQueryable vs. ICollection vs. IList

In this article we’ll understand about the interfaces ( IEnumerable, IQueryable, ICollection and IList) available for holding and querying the data. IEnumerable:   ·          IEnumerable exists in System.Collections Namespace. ·          IEnumerable is most generic item of all and a core interface which is used to iterate over collection of specified type. ·          IEnumerable provides Enumerator for accessing collection. ·          IEnumerable is forward only collection likes LinkedList. It doesn’t move between items or backward, i.e. one can't get at fifth item without passing first four items. ·          It is read-only collection and it doesn't support add or remove items. ·          IEnumerable is best to query data from in-memory collections like List, Array etc. ·          It mainly implements two methods: o    MoveNext: This method tells whether there are more records to move on or not. o    GetCurrent: This method returns the current record fr