Setup And Getting Started Forum


Error for the first time run CMS

 
Pls help me to solve this error:
There is already an open DataReader associated with this Command which must be closed first.
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.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
Source Error:
Line 46:                 string url = HttpContext.Current.Request.Url.Authority.ToLower();
Line 47:                 IEnumerable<Portal> portals = _inmemorycacheService.Get(PortalsHolder, () => _portalRepository.ListPortals());
Line 48:                 return portals.Where(portal => portal.URLAuthority.Equals(url)).FirstOrDefault();
Line 49:             }
Line 50: 
Source File: C:\Users\xxx\Desktop\MvcCms\MvcCms.Core\Cache\CacheService.cs    Line: 48



2 years 2 months 20 days ago by phuonglewis

Replies

Reply posted by phuonglewis 2 years 2 months 19 days ago View Branch And Reply
after querying "select URLAuthority from Portals", the results are:
localhost:4342z
localhost:4342
And the url in browser when I get the error msg is "http://localhost:4342/"
Reply posted by jon 2 years 2 months 19 days ago View Branch And Reply
OK, so the URLAuthority is set correctly. Let's try this, go to  C:\Users\xxx\Desktop\MvcCms\MvcCms.Core\Cache\CacheService.cs and replace the code inside the first else satement in GetCurrentPortal() with the code below. Basically comment out the try catch so we can find out what error is happening first.
 
                //try
                //{
                    string url = HttpContext.Current.Request.Url.Authority.ToLower();
                    IEnumerable<Portal> portals = _inmemorycacheService.Get(PortalsHolder, () => _portalRepository.ListPortals());
                    return portals.Where(portal => portal.URLAuthority.Equals(url)).FirstOrDefault();
                //}
                //catch
                //{
                //    IEntitiesProvider entityprovider = new EntitiesProvider();
                //    entityprovider.ReopenConnection();

                //    var context = entityprovider.GetEntityContext();
                //    using (context)
                //    {
                //        string url = HttpContext.Current.Request.Url.Authority.ToLower();
                //        IEnumerable<Portal> portals = _inmemorycacheService.Get(PortalsHolder, () => _portalRepository.ListPortals());
                //        return portals.Where(portal => portal.URLAuthority.Equals(url)).FirstOrDefault();
                //    }
                //}
Reply posted by phuonglewis 2 years 2 months 18 days ago View Branch And Reply
I think my current version it not yours, b/c it's GetCurrentPortal() have no try catch block:

internal Portal GetCurrentPortal()
{
//if httpcontext is null this is a unit test so just pick the default portal
if (HttpContext.Current == null)
{
IEnumerable<Portal> portals = _inmemorycacheService.Get(PortalsHolder, () => _portalRepository.ListPortals());
return portals.Where(portal => portal.Name.Equals("Default")).FirstOrDefault();
}
else
{
string url = HttpContext.Current.Request.Url.Authority.ToLower();
IEnumerable<Portal> portals = _inmemorycacheService.Get(PortalsHolder, () => _portalRepository.ListPortals());
return portals.Where(portal => portal.URLAuthority.Equals(url)).FirstOrDefault();
}
}
Reply posted by jon 2 years 2 months 18 days ago View Branch And Reply
Ah, ok we are getting somewhere now. Got to this link
http://mvccms.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=31243
and download the full source version. You have an older version. Where did you download it from? I am guessing that must be the RC1 version because the try catch version has been around for at least two or three months.
Reply posted by phuonglewis 2 years 2 months 18 days ago View Branch And Reply
I've downloaded the new source code (follow your link), re-setup the db and run the project again from Visual Studio, and a brand new error appear:

A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
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: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

Source Error: 

Line 56: public IEnumerable<Portal> ListPortals() 
Line 57: { 
Line 58: return (from c in _entities.PortalSet 
Line 59: .Include("DefaultLanguage") 
Line 60: .Include("PortalResources")
Source File: C:\Users\phuonglewis\Desktop\MvcCms\MvcCms.Data\EntityPortalRepository.cs    Line: 58


 1 2 3 4