Microsoft KB Archive/945375

= Error message when you try to drag a table from a SQL Server Compact 3.5 database file to a Windows form in Visual Studio 2008: &quot;An error occurred while performing the drop: Exception has been thrown by the target of an invocation&quot; =

Article ID: 945375

Article Last Modified on 12/27/2007

-

APPLIES TO


 * Microsoft SQL Server Compact 3.5

-



SYMPTOMS
Consider the following scenario in Microsoft Visual Studio 2008. You create a Windows Forms-based application. Next, you add a data source to this application by connecting to a Microsoft SQL Server Compact 3.5 database file. Then, you set one or more of the following properties to a value other than the default value:
 * Connect Timeout
 * Packet Size
 * Application Name

Note The default value of the Connect Timeout property is 30. The default value of the Packet Size property is 4096. The default value of the Application Name property is SQL Server Compact ADO.NET Data Provider.

In this scenario, when you try to drag a table to the Windows form in the Data Sources window, you receive the following error message:

An error occurred while performing the drop:

Exception has been thrown by the target of an invocation.



CAUSE
This behavior occurs because SQL Server 3.5 Compact does not support the connection tokens of the following properties in the runtime provider (System.Data.SqlServerCe.dll):
 * Connect Timeout
 * Packet Size
 * Application Name

Notes
 * Visual Studio 2008 adds the connection tokens of these properties to the runtime provider only if the values of these properties are not the default values. Therefore, if the values of these properties are the default values, the connection tokens of these properties are still valid.
 * SQL Server Compact 3.5 supports connection tokens in the runtime provider and in the designtime provider. However, SQL Server Compact 3.5 supports different sets of connection tokens in each of these providers. In Visual Studio 2008, Visual Studio designers use the designtime provider. Therefore, the connection tokens of these properties are valid. However, when you drag a table to a Windows form, the code that performs the drag operation uses the runtime provider. Because SQL Server 3.5 Compact does not support the connection tokens for these properties in the runtime provider, the connection tokens are invalid.



WORKAROUND
To work around this behavior, follow these steps:
 * 1) In Visual Studio 2008, right-click the project in Solution Explorer, and then click Properties.
 * 2) Click the Settings tab.
 * 3) Locate the connection string for the connection, and then click the ellipsis button (...) in the Value column.
 * 4) In the Connection Properties dialog box, click Advanced.
 * 5) In the Advanced Properties dialog box, perform the following operations, and then click OK:
 * 6) * Set the value of the Connect Timeout property to 30.
 * 7) * Set the value of the Application Name property to SQL Server Compact ADO.NET Data Provider.
 * 8) * Set the value of the Packet Size property to 4096.
 * 9) In the Connection Properties dialog box, click OK.
 * 10) On the File menu, click Save Selected Items.



STATUS
This behavior is by design.

Keywords: kbexpertiseadvanced kbtshoot kbprb KB945375

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.