EPiStore - String[0]: the Size property has an invalid size of 0.
Vote:
Hi!
I am trying to use the EPiStore Sample, but when i try to send an order i get a "String[0]: the Size property has an invalid size of 0." exception.
This is the method used to save the ordre:
private void SaveCartForCurrentUser()
{
if(UnifiedPrincipal.Current == null || UnifiedPrincipal.Current.UserData == null)
throw new NullReferenceException("Cannot call SaveOrder when UnifiedPrincipal.Current or UnifiedPrincipal.Current.UserData is null");
if(Cart.Current == null)
throw new NullReferenceException("Cannot call SaveOrder when Cart.Current is null");
int storeID =((PageReference)CurrentPage["EPiStoreRootPage"]).ID
Order order = new Order();
order.ID = Cart.Current.OrderID;
order.StoreStartPageID = storeID;
order.Cart = Cart.Current;
order.Status = OrderStatus.Processing;
order.Comments = Comments.Text;
order.CreatedByID = UnifiedPrincipal.CurrentSid;
order.Address = UnifiedPrincipal.Current.UserData.Address;
order.Email = UnifiedPrincipal.Current.UserData.Email;
order.Firstname = UnifiedPrincipal.Current.UserData.FirstName;
order.Lastname = UnifiedPrincipal.Current.UserData.LastName;
//An example how to add additional settings for an order
//order.Property.Add("shippingamount", "205");
order.Save();
SendMail(order);
}
it is the order.Save() that throws the exception!
Stack trace looks like this:
[InvalidOperationException: String[0]: the Size property has an invalid size of 0.]
System.Data.SqlClient.SqlParameter.Validate(Int32 index) +717107
System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters) +97
System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc) +81
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
EPiServer.DataAccess.AbstractCommand.ExecuteNonQuery() +10
EPiStore.DataAccess.ShoppingDB.ᐁ(Cart , Boolean ) +674
EPiStore.DataAccess.ShoppingDB.SaveOrder(Order order) +917
EPiStore.DataAbstraction.Order.Save() +33
Any help will be appriciated!
Best Regards,
Christian Jørgensen, Denmark
I solved the problem!
Installed the EPiStore 2.1.1 Hotfix:
http://www.episerver.com/en/EPiServer_Knowledge_Center/Download2/Hotfixes/EPiStore-211-Hotfix-1/
/CJ
private void SaveCartForCurrentUser() { if(UnifiedPrincipal.Current == null || UnifiedPrincipal.Current.UserData == null) throw new NullReferenceException("Cannot call SaveOrder when UnifiedPrincipal.Current or UnifiedPrincipal.Current.UserData is null"); if(Cart.Current == null) throw new NullReferenceException("Cannot call SaveOrder when Cart.Current is null"); int storeID =((PageReference)CurrentPage["EPiStoreRootPage"]).ID Order order = new Order(); order.ID = Cart.Current.OrderID; order.StoreStartPageID = storeID; order.Cart = Cart.Current; order.Status = OrderStatus.Processing; order.Comments = Comments.Text; order.CreatedByID = UnifiedPrincipal.CurrentSid; order.Address = UnifiedPrincipal.Current.UserData.Address; order.Email = UnifiedPrincipal.Current.UserData.Email; order.Firstname = UnifiedPrincipal.Current.UserData.FirstName; order.Lastname = UnifiedPrincipal.Current.UserData.LastName; //An example how to add additional settings for an order //order.Property.Add("shippingamount", "205"); order.Save(); SendMail(order); }
it is theorder.Save()
that throws the exception! Stack trace looks like this:[InvalidOperationException: String[0]: the Size property has an invalid size of 0.] System.Data.SqlClient.SqlParameter.Validate(Int32 index) +717107 System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters) +97 System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc) +81 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 EPiServer.DataAccess.AbstractCommand.ExecuteNonQuery() +10 EPiStore.DataAccess.ShoppingDB.ᐁ(Cart , Boolean ) +674 EPiStore.DataAccess.ShoppingDB.SaveOrder(Order order) +917 EPiStore.DataAbstraction.Order.Save() +33
Any help will be appriciated! Best Regards, Christian Jørgensen, Denmark