Content Part doesn't show in Add/Edit Page. Says it needs to be Upgraded but Upgrade Fails

Jan 14, 2011 at 5:28 AM
Edited Jan 15, 2011 at 4:01 AM

I'm running 1.0.20 on SQL Server.

I created and uploaded my module, content part.
I went to Features and enabled it. 
It has a red box with message, "some features need to be upgraded."
I click "upgrade" and get this error page.

 

Server Error in '/' Application.

The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.

Description: An unhandled exception occurred during the execution of the current web request. 
Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: The COMMIT TRANSACTION request has no corresponding 
BEGIN TRANSACTION. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding
the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SqlException (0x80131904): The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2030802 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
+5009584 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader
dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275 System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer,
TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel,
Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean
isDelegateControlRequest) +716 System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest
transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction,
Boolean isDelegateControlRequest) +347 System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest,
String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean
isDelegateControlRequest) +154 System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment enlistment) +366 [TransactionAbortedException: The transaction has aborted.] System.Transactions.TransactionStateAborted.EndCommit(InternalTransaction tx) +11 System.Transactions.CommittableTransaction.Commit() +239 System.Transactions.TransactionScope.InternalDispose() +402 System.Transactions.TransactionScope.Dispose() +1450 Orchard.Data.TransactionManager.System.IDisposable.Dispose() in
d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Data\TransactionManager.cs:43 Autofac.Core.Disposer.Dispose(Boolean disposing) +79 Autofac.Util.Disposable.Dispose() +46 Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) +21 Autofac.Util.Disposable.Dispose() +46 Orchard.Environment.<>c__DisplayClass2.<.ctor>b__0() in
d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Environment\WorkContextAccessor.cs:75 Orchard.Environment.HttpContextScopeImplementation.System.IDisposable.Dispose() in
d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Environment\WorkContextAccessor.cs:80 Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in
d:\TeamCity\Projects\Orchard-1.x\src\Orchard\Mvc\Routes\ShellRoute.cs:158 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

 

 

On my local machine I have set it up with SQL Compact. 
On here, I don't get the upgrade message, but still it doesn't show up after adding the content part in Content Type Edit section...

I basically followed instructions here, http://orchardproject.net/docs/Writing-a-content-part.ashx. Simple one string field content part.

Help!

Jan 14, 2011 at 6:07 PM

Anybody having same issue?

Coordinator
Jan 14, 2011 at 8:10 PM

You probably have an exception in your migration code. Attach a debugger and put a breakpoint in there to figure out what's going on.

Jan 15, 2011 at 3:54 AM
Edited Jan 15, 2011 at 3:59 AM

I don't think that is the case... Table is created and I see some records inserted with NULL field. I added some pages. My added new field didn't show up but it seems that record was inserted with NULL values.

What else would cause it to say that it needs to be upgraded?

Also, any idea why it is not showing in Edit Page?

Coordinator
Jan 15, 2011 at 4:07 AM

That just means that the exceptions happened after the table was created.

Jan 15, 2011 at 4:32 AM
Edited Jan 15, 2011 at 4:35 AM

I just noticed that I'm missing placement.info file... Maybe that caused an exception after creating table? Is that file used when Module is first enabled and stored in db somewhere?

How would I go about fixing this? How to reinstall my module...?

I don't see an uninstall option in modules. Would I just disable it, delete associated table from database and enable it back?

 

I found this article, http://www.orchardproject.net/docs/Installing-and-upgrading-modules.ashx, but I don't see the "Install a module" button on my Modules section..

Jan 15, 2011 at 5:10 AM

I zapped my AppData folder and started fresh.

Module was enabled without errors. I'm now seeing the install button on Modules section. Seems like my module was installed correctly.

But... my new field still isn't showing up on the Create Page... Hmm...

Coordinator
Jan 15, 2011 at 5:15 AM

Placement had nothing to do with it. Uninstalling a module is done by simply removing it from the site, but some config info may remain in the database so zapping the database is the only foolproof way to completely restart from scratch.

Did you enable the feature?

Jan 15, 2011 at 5:18 AM
Edited Jan 15, 2011 at 5:18 AM

Yes, I enabled it. It no longer says it needs to be upgraded. Seems like it's good there.

I went and added my new content part to content type, Page, but the field still doesn't show up on Create Page page.

Coordinator
Jan 15, 2011 at 5:24 AM

That it doesn't display could be due to placement.info. Check that it's there and that it has the right info. If you have VS, you can also attach the debugger to the web server and put a breakpoint in the driver to check whether the code is being called.

Jan 15, 2011 at 6:26 AM

That was it! 

I followed the placement.info in Orchard.Tags module and it is showing up now.

Thanks!

Jul 23, 2011 at 4:01 AM

Hello Brian,

This is late to be adding to the discussion but I too ran into this similar issue and wanted to document (for other who may read this) what caused this problem. In short, what was happening is that the "Create" method (step 0) to be initiated a second time.  This then caused the contents of this method, the "Creating table ProductPartRecord" section using the SchemaBuilder.CreateTable method, to be called a second time.  Of course, the database table already exists so this throws an error that, unfortunately, does not get conveyed back to the user interface inside of Orchard. 

I do not have a permanent code solution for this as of yet but the quick hack was to just comment out the SchemaBuilder.CreateTable section.  A more permanent solution will be to first check to see if the table exists prior to trying to build it.  Of course, this is unlikely to happen if the versioning process is working but I wonder what would happen if you remove the module and then later download it.  It seems like this too would cause this problem.  If so, it seems that the only great way to manage this is that the developer setting up the module needs to be careful that the update steps can be operated from beginning to end, instead of just assuming it will always be the last step that is being implemented.

Final note, to remove the module (which I too could not find out how to do in the interface and don't think you can) I used the following Orchard Script:

package uninstall Orchard.Module.SimpleCommerce

Hopefully this helps someone.

Jun 20, 2012 at 12:32 PM

I am getting a similar exception when I attempt to upgrade my Email module, tells me I need to upgrade, when I try it fails and there is nothing in the log to indicate what the issue is...

[SqlException (0x80131904): The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2073486
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5064444
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
   System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest) +770
   System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest) +347
   System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest) +154
   System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment enlistment) +386

[TransactionAbortedException: The transaction has aborted.]
   System.Transactions.TransactionStateAborted.EndCommit(InternalTransaction tx) +11
   System.Transactions.CommittableTransaction.Commit() +239
   System.Transactions.TransactionScope.InternalDispose() +402
   System.Transactions.TransactionScope.Dispose() +1450
   Orchard.Data.TransactionManager.System.IDisposable.Dispose() in TransactionManager.cs:47
   Autofac.Core.Disposer.Dispose(Boolean disposing) +79
   Autofac.Util.Disposable.Dispose() +46
   Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) +21
   Autofac.Util.Disposable.Dispose() +46
   Orchard.Environment.<>c__DisplayClass2.<.ctor>b__0() in WorkContextAccessor.cs:75
   Orchard.Environment.HttpContextScopeImplementation.System.IDisposable.Dispose() in WorkContextAccessor.cs:80
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in ShellRoute.cs:151
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

 

 

Coordinator
Jun 21, 2012 at 5:27 AM

Put a breakpoint in your migration code and debug it.