<p><code>System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.</code></p>

<p>Anybody ever get this error and/or have any idea on it's cause and/or solution?</p>

<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=125227&amp;SiteID=1" rel="nofollow noreferrer">This link may have relevant information.</a></p>

<p><strong>Update</strong></p>

<p>The connection string is <code>=.\SQLEXPRESS;AttachDbFilename=C:\temp\HelloWorldTest.mdf;Integrated Security=True</code></p>

<p>The suggested <code>User Instance=false</code> worked.</p>

[{'answer_id': 14214, 'author': 'Jon Limjap', 'author_id': 372, 'author_profile': 'https://Stackoverflow.com/users/372', 'pm_score': 2, 'selected': False, 'text': '<p>You should add an explicit User Instance=true/false to your connection string</p>\n'}, {'answer_id': 1086442, 'author': 'Roboblob', 'author_id': 125718, 'author_profile': 'https://Stackoverflow.com/users/125718', 'pm_score': 4, 'selected': False, 'text': '<p>Here is the answer to your problem:</p>\n\n<p>Very often old user instance creates some temp files that prevent a new SQL Express user instance to be created. When those files are deleted everything start working properly.</p>\n\n<p>First of all confirm that user instances are enabled by running the following SQL in SQL Server Management Studio:</p>\n\n<pre><code>exec sp_configure \'user instances enabled\', 1.\nGO\nReconfigure\n</code></pre>\n\n<p>After running the query restart your SQL Server instance. Now delete the following folder:</p>\n\n<p><code>C:\\Documents and Settings\\{YOUR_USERNAME}\\Local Settings\\Application Data\\Microsoft\\Microsoft SQL Server Data\\{SQL_INSTANCE_NAME}</code></p>\n\n<p>Make sure that you replace <code>{YOUR_USERNAME}</code> and <code>{SQL_INSTANCE_NAME}</code> with the appropriate names.</p>\n\n<p>Source: <a href="http://aspdotnetfaq.com/Faq/fix-error-Failed-to-generate-a-user-instance-of-SQL-Server-due-to-a-failure-in-starting-the-process-for-the-user-instance.aspx" rel="noreferrer">Fix error "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance." </a></p>\n'}, {'answer_id': 17092076, 'author': 'Hamid Shahid', 'author_id': 94897, 'author_profile': 'https://Stackoverflow.com/users/94897', 'pm_score': 0, 'selected': False, 'text': '<p>I started getting this error this morning in a test deployment environment. I was using SQL Server Express 2008 and the error I was getting was</p>\n\n<p>"Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed."</p>\n\n<p>Unsure about what caused it, I followed the instructions in this post and in other post about deleting the "C:\\Users\\UserName\\AppData\\Local\\Microsoft\\Microsoft SQL Server Data\\SQLEXPRESS" directory, but to no avail.</p>\n\n<p>What did the trick for me was to change the connection string from</p>\n\n<p>"Data Source=.\\SQLExpress;Initial Catalog=<strong>DBFilePath</strong>;Integrated Security=SSPI;MultipleActiveResultSets=true"</p>\n\n<p>to</p>\n\n<p>"Data Source=.\\SQLExpress;Initial Catalog=<strong>DBName</strong>;Integrated Security=SSPI;MultipleActiveResultSets=true"</p>\n'}, {'answer_id': 29869425, 'author': 'alketraz', 'author_id': 4832647, 'author_profile': 'https://Stackoverflow.com/users/4832647', 'pm_score': 0, 'selected': False, 'text': '<p>I followed all these steps but also had to go into</p>\n\n<ol>\n<li>Control Panel > Administrative Tools > Services</li>\n<li>Right-click on SQL Server (SQLEXPRESS)</li>\n<li>Select the Log On tab</li>\n<li>Select the Local System account and then click OK</li>\n</ol>\n\n<p>Problem solved... thank you</p>\n'}, {'answer_id': 33201997, 'author': 'mukhtar ghaleb', 'author_id': 5042080, 'author_profile': 'https://Stackoverflow.com/users/5042080', 'pm_score': 0, 'selected': False, 'text': "<p>I have windows 8 and I test the solution  </p>\n\n<ol>\n<li><p>Enable user instances<br>\nexec sp_configure 'user instances enabled', 1.<br>\nGO<br>\nReconfigure  </p></li>\n<li><p>Restart your SQL Server instance.</p></li>\n<li><p>Delete the folder:\n<code>C:\\Users\\Arabic\\{YOUR_USERNAME}\\Local\\Microsoft\\Microsoft SQL Server Data</code><br>\nReplace {YOUR_USERNAME} with the appropriate names.</p></li>\n</ol>\n\n<p>the source from Roboblob</p>\n"}, {'answer_id': 68836220, 'author': 'user8128167', 'author_id': 351154, 'author_profile': 'https://Stackoverflow.com/users/351154', 'pm_score': 0, 'selected': False, 'text': '<p>Please note that I found <a href="https://stackoverflow.com/users/372/jon-limjap">Jon Limjap</a>\'s answer helpful except that after I did more research I found that it only applies to database connection strings that contain <code>AttachDBFilename</code>, so I had to change my connection string in <code>web.config</code> from:</p>\n<pre><code>connectionString=&quot;data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\aspnetdb.mdf&quot;\n</code></pre>\n<p>To:</p>\n<pre><code>connectionString=&quot;data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\aspnetdb.mdf;User Instance=true&quot;\n</code></pre>\n<p>For details please see <a href="https://stackoverflow.com/questions/9555659/if-add-user-instances-true-to-connection-string-an-exception-is-thrown/9555870#9555870">If add [user instances=true] to connection string, an exception is thrown</a></p>\n'}]
['https://Stackoverflow.com/questions/14209', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1659/']