SQL server 2012. Exception: attempted to read or write protected memory (MS.VS.OLE.Interop)

Sql ServerException

Sql Server Problem Overview


I am more an end-user of SQL Server 2012. When I right click on a table name and select "Edit top 200 rows" menu item. I get this message:

 Exception has been thrown by the target of an invocation. (mscorlib)
 Additional information:
   Attempted to read or write protected memory. This is often an indication that 
   other memory is corrupt. (Microsoft.VisualStudio.OLE.Interop)

If I try to do the right click again, SQL server will stop working and close. I still can use SQL commands to insert or update database. I have been searching around for a solution, and found this link: http://social.msdn.microsoft.com/Forums/vstudio/en-US/42b79da5-6f1e-4122-a2cb-00def87a1ae2/microsoftvisualstudiooleinterop-attempted-to-read-or-write-protected-memory-this-is-often-an?forum=visualstudiogeneral

But it still does not help me to understand clearly the cause or find the solution to the issue. Any help to resolve this problem is highly appreciated. Thanks.

Sql Server Solutions


Solution 1 - Sql Server

Are you attempting to edit a SQL 2014 database with the 2012 version (or earlier) of SQL Management Studio?

You can determine the SQL version of your database by running this query against your master database:

SELECT @@VERSION

I had the same problem and I was able to direct edit tables ('Edit Top 200') by installing and using SQL Server Management Studio 2014. Even if both your DB and Management Studio are version 2012, it might not hurt to upgrade Management Studio.

Solution 2 - Sql Server

I have also faced the same issue. And I noticed one thing that if you are using SQL database newer then the SQL management studio version, You will received that message. To overcome this issue just install SQL management studio equal or greater then version of database. i.e if you have SQL 2012 then you need to install SQL management studio 2012 or 2014.

Solution 3 - Sql Server

If anyone experiences the same issue in MS SQL SERVER from a different scenario ( eg - creating new database diagram )

And if this happened after fully uninstalling MS VISUAL STUDIO

Follow the Steps Below;

  1. Delete Folders MSDesigners8 and Visual Database Tools from the paths below.
  • C:\Program Files (x86)\Common Files\Microsoft Shared\MSDesigners8

  • C:\Program Files (x86)\Common Files\Microsoft Shared\Visual Database Tools

  1. Reinstall Visual Studio and Run Repair Tools from the Visual Studio Installer.

This Will Regenerate the folders we removed above and will repair partial fragments.

Now your SQL SERVER Database Diagrams should be working fine. Cheers :)

Solution 4 - Sql Server

I have found a solution which does not require restart. Go to:

C:\Users\<User Name>\AppData\Local\Temp 

and delete all the files. Before deleting, close the SSMS window.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3558286View Question on Stackoverflow
Solution 1 - Sql ServerjboekeView Answer on Stackoverflow
Solution 2 - Sql ServerKrishan DagarView Answer on Stackoverflow
Solution 3 - Sql ServerThivankaWView Answer on Stackoverflow
Solution 4 - Sql ServerAmila MadushanView Answer on Stackoverflow