System.InvalidOperationException'发生并被捕获 [英] System.InvalidOperationException' occurred and was caught

查看:281
本文介绍了System.InvalidOperationException'发生并被捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将.net 3.5与sqlserver 2012一起使用,并间歇性地遇到错误.

Type:System.InvalidOperationException,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089
消息:由于连接已断开,无法完成请求的操作.
资料来源:System.Data
帮助链接:
数据:System.Collections.ListDictionaryInternal
TargetSite:无效ExecuteTransaction(TransactionRequest,System.String,System.Data.IsolationLevel,System.Data.SqlClient.SqlInternalTransaction,Boolean)
堆栈跟踪:   at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest,字符串名称,IsolationLevel iso,SqlInternalTransaction internalTransaction,布尔值isDelegateControlRequest)
    at System.Data.SqlClient.SqlDelegatedTransaction.Initialize()
    at System.Transactions.TransactionStatePSPEOperation.PSPEInitialize(InternalTransaction tx,IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
    at System.Transactions.TransactionStateActive.EnlistPromotableSinglePhase(InternalTransaction tx,IPromotableSinglePhaseNotification promotableSinglePhaseNotification,Transaction atomicTransaction)
    at System.Transactions.Transaction.EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
    at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
    at System.Data.SqlClient.SqlInternalConnection.EnlistTransaction(交易事务)
    at System.Data.SqlClient.SqlConnection.EnlistTransaction(交易事务)
    at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser用户)
    at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
    at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
    at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(表达式查询)
    at System.Data.Linq.Table`1.GetEnumerator()
    at System.Data.Linq.Table`1.System.Collections.Generic.IEnumerable< TEntity> .GetEnumerator()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList [TSource](IEnumerable`1源)

解决方案

>

虽然众所周知.Net是必须单独安装的功能,但显而易见的是Windows 2012上实际上根本没有安装.Net 3.5.

我是从博客获得的: https ://social.msdn.microsoft.com/Forums/zh-CN/09b48db1-7778-45b2-94b1-a6ca68d8cd79/connection-has-been-broken?forum = linqprojectgeneral

https://support.microsoft.com/en-us/kb/973256

最诚挚的问候,

克里斯汀


We are using .net 3.5 with sqlserver 2012 and getting below error intermittently.

Type : System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The requested operation cannot be completed because the connection has been broken.
Source : System.Data
Help link : 
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ExecuteTransaction(TransactionRequest, System.String, System.Data.IsolationLevel, System.Data.SqlClient.SqlInternalTransaction, Boolean)
Stack Trace :    at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
   at System.Data.SqlClient.SqlDelegatedTransaction.Initialize()
   at System.Transactions.TransactionStatePSPEOperation.PSPEInitialize(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
   at System.Transactions.TransactionStateActive.EnlistPromotableSinglePhase(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Transaction atomicTransaction)
   at System.Transactions.Transaction.EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
   at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
   at System.Data.SqlClient.SqlInternalConnection.EnlistTransaction(Transaction transaction)
   at System.Data.SqlClient.SqlConnection.EnlistTransaction(Transaction transaction)
   at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
   at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
   at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
   at System.Data.Linq.Table`1.GetEnumerator()
   at System.Data.Linq.Table`1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

解决方案

Hi MD123456,

Which line is causing this exception as you posted? Have you tried setting a breakpoint and stepping through each line in the debugger?

In addition, you should note this, I suspect you haven't install the .Net3.5 correctly.

SQL Server 2012 Setup doesn't believe that .NET Framework 3.5 SP1 is already installed

While it is well know the .Net is a feature that must be installed separately, what is not obvious is that .Net 3.5 is not actually installed at all on Windows 2012. 

I got it from blog: Windows 2012 and .Net 3.5 Feature Install

And I've searched the error log, please also refer to some similar threads that they discussed.

https://social.msdn.microsoft.com/Forums/en-US/09b48db1-7778-45b2-94b1-a6ca68d8cd79/connection-has-been-broken?forum=linqprojectgeneral

https://support.microsoft.com/en-us/kb/973256

If you still have any concerns, you can elaborate more details about your scenario with some code. Thanks for your understanding.

Best regards,

Kristin


这篇关于System.InvalidOperationException'发生并被捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆