Select the product you need help with
You receive an error message when you run an application, script, or functionality from an earlier SQL Server installation that uses common language runtime features in SQL Server 2008 or in SQL Server 2008 R2: "A .NET Framework error occurred"Article ID: 955629 - View products that this article applies to. On This PageSYMPTOMSAfter you upgrade to Microsoft SQL Server 2008 or to Microsoft SQL Server 2008 R2, when you run an application, a script, or a functionality from an earlier Microsoft SQL Server installation that uses common language runtime (CLR) features, you receive an error message that resembles the following error message: Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate routine name: System.InvalidOperationException: Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method. System.InvalidOperationException Scenario 1You use a method that has the following characteristics:
Scenario 2You use the INIT method in a CLR table-valued function that performs impersonation.Scenario 3You use the FillRow method in a CLR table-valued function that performs impersonation.CAUSEThis problem occurs because of a change in the Database Engine features in SQL Server 2008 and in SQL Server 2008 R2. WORKAROUNDTo work around the problem as described in the scenarios in the "Symptoms" section, use one of the following methods. Method 1: To work around this problem in Scenario 1 and in Scenario 2To work around this problem, add the DataAccessKind.Read property to the method.Method 2: To work around this problem in Scenario 3To work around this problem, do the following:
REFERENCESFor information about the DataAccessKind.Read property and other custom attributes for CLR routines, visit the following Microsoft TechNet Web site: http://technet.microsoft.com/en-us/library/ms131050.aspx For information about breaking changes in the Database Engine features in SQL Server 2008, visit the following Microsoft TechNet Web site:
(http://technet.microsoft.com/en-us/library/ms131050.aspx)
http://technet.microsoft.com/en-us/library/ms143179(SQL.100).aspx
(http://technet.microsoft.com/en-us/library/ms143179(SQL.100).aspx)
PropertiesArticle ID: 955629 - Last Review: March 19, 2009 - Revision: 2.1 APPLIES TO
|


Back to the top








