I have an ASP.Net MVC 3 app that I've developed which uses RavenDB Embedded as an integrated backing store for data, I used this tutorial as a basis for getting started creating an MVC app with RavenDB Embedded. I've been able to run it fine on my development PC, but when it came time to deploy it on our Windows Server 2003 web server running IIS6 it threw the following error:
Cannot access file, the file is locked or in use 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:
Microsoft.Isam.Esent.Interop.EsentFileAccessDeniedException: Cannot
access file, the file is locked or in use
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:
[EsentFileAccessDeniedException: Cannot access file, the file is
locked or in use] Microsoft.Isam.Esent.Interop.Api.Check(Int32 err)
in
C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:2736
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator
uuidGenerator) in
c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:207
[InvalidOperationException: Could not open transactional storage:
C:\inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator
uuidGenerator) in
c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:222
Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration
configuration) in
c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:185
Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() in
c:\Builds\RavenDB-Stable\Raven.Client.Embedded\EmbeddableDocumentStore.cs:143
Raven.Client.Document.DocumentStore.Initialize() in
c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentStore.cs:496
MyApp.CompositionRoot.CreateControllerFactory() in
...\MyApp\CompositionRoot.cs:36 MyApp.CompositionRoot..ctor() in
..\MyApp\CompositionRoot.cs:17
MyApp.MvcApplication.Application_Start() in ...MyApp\Global.asax.cs:38
[HttpException (0x80004005): Could not open transactional storage:
C:\inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +3985477
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +375
[HttpException (0x80004005): Could not open transactional storage:
C:\inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +4782309
The source of the error in the referenced CompositionRoot.cs class is when the initialization of the Embeddable Document Store.
private static IControllerFactory CreateControllerFactory()
{
var cacheRepository = new EmbeddableDocumentStore();
cacheRepository.ConnectionStringName = "RavenDB";
#if DEBUG
cacheRepository.UseEmbeddedHttpServer = true;
#endif
Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
cacheRepository.Initialize(); //Source of Error
var controllerFactory = new TDRControllerFactory(cacheRepository);
return controllerFactory;
}
Why is this only happening on the web server and not on my development PC? I'm not sure what the exact cause might be. Any help is appreciated.
This turned out to be a permissions issue, I gave the IIS_IUSRS group modify and write permissions on the root of my application's folder and that gave it the permissions it needed to initialize the database properly. There's probably a specific folder within the root that it needs modify/write access to (in my case, probably the App_Data folder, since that's where I'm instantiating my instance of RavenDB). I'll have to test as I wouldn't want any user to have modify/write rights to the entire application folder.
You need to make sure that your CreateControllerFactory will run only once, even in the face of concurrent requests at app startup.
Related
We just deployed a new v6 site to a host that has several v4 sites running on it no problem. On the front end, it looks fine, but in the Umbraco admin the Content and Media trees appear empty.
In the browser debugger I can see that there is an error in the TreeDataService.ashx.
The error is below and I'm not exactly sure what the issue is. Is it permissions? Database user permissions?
----------
You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' to use an sql syntax provider
Parameter name: SqlSyntaxProvider
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.ArgumentNullException: You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' to use an sql syntax provider
Parameter name: SqlSyntaxProvider
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:
[ArgumentNullException: You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' to use an sql syntax provider
Parameter name: SqlSyntaxProvider]
Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig.get_SqlSyntaxProvider() +89
Umbraco.Core.Persistence.Mappers.BaseMapper.GetColumnName(Type dtoType, PropertyInfo dtoProperty) +57
Umbraco.Core.Persistence.Mappers.ContentMapper.Map(String propertyName) +67
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.VisitMemberAccess(MemberExpression m) +112
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.Visit(Expression exp) +101
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.VisitBinary(BinaryExpression b) +258
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.Visit(Expression exp) +159
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.VisitLambda(LambdaExpression lambda) +120
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.Visit(Expression exp) +72
Umbraco.Core.Persistence.Querying.Query`1.Where(Expression`1 predicate) +20
Umbraco.Core.Services.ContentService.GetChildren(Int32 id) +312
umbraco.cms.businesslogic.web.Document.GetChildrenForTree(Int32 NodeId) +39
umbraco.cms.presentation.Trees.BaseContentTree.Render(XmlTree& Tree) +27
umbraco.loadContent.Render(XmlTree& tree) +19
umbraco.presentation.webservices.TreeDataService.LoadTree(TreeRequestParams treeParams) +79
umbraco.presentation.webservices.TreeDataService.GetXmlTree() +140
umbraco.presentation.webservices.TreeDataService.ProcessRequest(HttpContext context) +55
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
check you umbraco db connection string.
<add name="umbracoDbDSN".......
if it do contains
providerName="System.Data.SqlClient"
then Add it and check. the same. it might start working.
Problem is that SqlSyntaxProvider is null, my workaround is init it.
var service = new Umbraco.Core.Services.ContentService();
SqlSyntaxContext.SqlSyntaxProvider = new MySqlSyntaxProvider();
The connection string, add name="umbracoDbDSN" ... was missing the following providerName="System.Data.SqlClient"
Once I added that to the line things started working.
I'm using latest MVC4-RC (.net 4.0) with Microsoft ASP.NET Web Optimization Framework http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0-beta3 and I'm receiving this error.
Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.
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.MissingMethodException: Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.
[MissingMethodException: Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.]
App.MVC.BundleConfig.RegisterBundles(BundleCollection bundles) in C:...\App_Start\BundleConfig.cs:53
App.MVC.MvcApplication.Application_Start() in C:...\Global.asax.cs:47
[HttpException (0x80004005): Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +4057141
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
[HttpException (0x80004005): Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869125
This the code I'm using:
in global.asax.cs
protected void Application_Start()
{
...
BundleConfig.RegisterBundles(BundleTable.Bundles);
...
and then in App_Start/BundleConfig.cs
using System.Web.Optimization;
namespace App.MVC.App_Start
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new Bundle("~/scripts/packed.js", new JsMinify()).Include(
// jquery
"~/Scripts/jquery-1.7.1.js",
"~/Scripts/jquery-ui-1.8.17.js",
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery.unobtrusive-ajax.js"));
bundles.Add(new Bundle("~/content/css/packed.css", new CssMinify()).Include(
// reset
"~/Content/css/cssreset-min.css",
"~/Content/css/cssfonts-min.css",
// themes
"~/Content/themes/base/jquery-ui-1.8.16.custom.css",
// site
"~/Content/css/Site.css"));
}
}
}
I'm also using Azure with this project and funny this is, first time when I start Azure, I get this error. Then when I just rebuild MVC project and refresh page, it works.
How would I approach solving this?
I received the same error when I referenced the wrong package
via
Install-Package Microsoft.Web.Optimization -Version 1.0.0-beta -Pre
resolved by referencing correct newer package
Install-Package Microsoft.Web.Optimization -Pre
Before posting this I made sure to read all suggestion made from SO.
The application currently has two projects one for the web application and one for the Entity Frame work (version 4.0). We are trying a tool from RSSBus for the Quickbooks Provider description here
Setting it up was easy enough. I prefixed QB on all the entities and generated the QB.tt file, no issues. Both edmx files are housed in the same project using a shared namespace (SMR.Model)
When I rebuilt the project to run it the global.asax.cs file threw an error:
DefaultModel.RegisterContext(typeof(SMR.Model.SMREntities),
new ContextConfiguration() { ScaffoldAllTables = true });
The error given was:
The given key was not present in the dictionary.
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.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Source Error:
Line 36: public static void RegisterRoutes(RouteCollection routes)
Line 37: {
Line 38: DefaultModel.RegisterContext(typeof(SMR.Model.SMREntities),
Line 39: new ContextConfiguration() { ScaffoldAllTables = true });
Line 40:
Source File: C:\all\src\smr\smr.pl.Web\Global.asax.cs Line: 38
Stack Trace:
[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary2.get_Item(TKey key) +9624829
System.Web.DynamicData.ModelProviders.EFDataModelProvider..ctor(Object contextInstance, Func1 contextFactory) +800
System.Web.DynamicData.ModelProviders.SchemaCreator.CreateDataModel(Object contextInstance, Func1 contextFactory) +126
System.Web.DynamicData.MetaModel.RegisterContext(Func1 contextFactory, ContextConfiguration configuration) +378
System.Web.DynamicData.MetaModel.RegisterContext(Type contextType, ContextConfiguration configuration) +88
smr.pl.Web.Global.RegisterRoutes(RouteCollection routes) in C:\all\src\smr\smr.pl.Web\Global.asax.cs:38
smr.pl.Web.Global.Application_Start(Object sender, EventArgs e) in C:\all\src\smr\smr.pl.Web\Global.asax.cs:91
[HttpException (0x80004005): The given key was not present in the dictionary.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9170941
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +131
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): The given key was not present in the dictionary.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090044
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
With so little to go on as to what could eb the problem I looked at the .config files to see if they were wrong and all checked out as ok.
<add name="SMREntities" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SMR;Persist Security Info=True;User ID=sa;Password=XXX;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
<add name="RSSQBEntities" connectionString="metadata=res://*/Model.QBOE.csdl|res://*/Model.QBOE.ssdl|res://*/Model.QBOE.msl;provider=System.Data.RSSBus.QuickBooks;provider connection string="Offline=False;Application Id=987654321;Connection Ticket=TGT-000-T_xxxxxxxxxxxxxxxxxxxx;Online Login=ohno"" providerName="System.Data.EntityClient" />
Any thoughts as to what is causing the structure to fail like this?
I finally figured out the "real" problem. I first seperated the two models into separate projects. The problem I was facing was the metadata was being integrated into the same assembly namespace. I resolved my issue by updating the res://*/ section
<add name="SMREntities" connectionString="metadata=res://SMR.Model/;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SMR;Persist Security Info=True;User ID=sa;Password=XXX;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
<add name="RSSQBEntities" connectionString="metadata=res://SMR.QBOE/Model.RSSQBOE.csdl|res://SMR.QBOE/Model.RSSQBOE.ssdl|res://SMR.QBOE/Model.RSSQBOE.msl;provider=System.Data.RSSBus.QuickBooks;provider connection string="Offline=False;Application Id=987654321;Connection Ticket=TGT-000-T_xxxxxxxxxxxxxxxxxxxx;Online Login=ohno"" providerName="System.Data.EntityClient" />
A Classic "the issue is not the issue".
My ASP.NET MVC 3 web project was working fine, then I recompiled it and now I'm getting this error (some paths and namespaces changed to protect the innocent):
Object reference not set to an
instance of an object. 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.NullReferenceException: Object
reference not set to an instance of an
object.
Source Error:
Line 66:
RouteTable.Routes.MapRoute( Line 67:
"DefaultRoutes", // Route name Line
68:
"{module}/{controller}/{action}/{id}",
// URL with parameters
Source File: ....\Global.asax.cs
Line: 66
Stack Trace:
[NullReferenceException: Object
reference not set to an instance of an
object.]
Project.MvcApplication.RegisterRoutes(RouteCollection
routes) in D:.....\Global.asax.cs:66
Project.MvcApplication.Application_Start()
in D:.....\Global.asax.cs:139
[HttpException (0x80004005): Object
reference not set to an instance of an
object.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +4051717
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context,
MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState
state, MethodInfo[] handlers, IntPtr
appContext, HttpContext context) +352
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +375
[HttpException (0x80004005): Object
reference not set to an instance of an
object.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext
context) +11642112
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext
context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +4865877
I'm using IIS7.5 on Windows 7 x64, and the app pool is configured to run with .NET 4 and the 'Integrated' managed pipeline.
I've tried rebooting, and also cleaning out the bin and obj folders with no success.
Some extra information that turns out to be important - the line missing from the error page above:
RouteTable.Routes.MapRoute(
"DefaultRoutes", // Route name
"{module}/{controller}/{action}/{id}", // URL with parameters
new { module = _loadedModules.FirstOrDefault().Name, controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
In your global.asax.cs you can write like this
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(....);//you should use routes parameter rather than RouteTable.Routes
}
This project dynamically loads modules and what wasn't clear from the original ASP.NET error page was that the NullReferenceException was being caused by the final line of the MapRoute() method call.
It turns out that _loadedModules was empty, so FirstOrDefault() was returning null - hence the exception.
I'm following this blog post to create an azure storage table:
http://blogs.msdn.com/jnak/archive/2008/10/28/walkthrough-simple-table-storage.aspx
It works fine on an asp.net webform web_role.
I've re-created the same project using asp.net mvc as the web role, and it's always failing on application start. this line:
StorageAccountInfo account = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();
seem to always fail getting the account shared key.
If I move the line from global asax application start to default.aspx, it works perfectly fine.
Is there any difference in initializing a storage table in azure asp.net mvc compared to webform?
Why can't I get the azure appsettings on application start?
This is the error call stack from event viewer
Exception information:
Exception type: HttpException
Exception message: No account key specified!
Request information:
Request URL: http://127.0.0.1:5100/do.__rd_runtime_init__?shutdownEvent=1B671B93FD-4153-4834-9D5D-595EFC6C19EE1D
Request path: /do.__rd_runtime_init__
User host address: 127.0.0.1
User:
Is authenticated: False
Authentication Type:
Thread account name: *****
Thread information:
Thread ID: 6
Thread account name: *****
Is impersonating: False
Stack trace: at System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
Check out the "remarks" at http://msdn.microsoft.com/en-us/library/microsoft.servicehosting.serviceruntime.rolemanager.aspx:
The Windows Azure fabric runs IIS 7.0
in integrated mode. In integrated
mode, the Application_Start event does
not support access to the request
context or to the members of the
RoleManager class provided by the
Windows Azure SDK runtime API. If you
are writing an ASP.NET application
that accesses the request context or
calls methods of the RoleManager class
from the Application_Start event, you
should modify it to initialize in the
Application_BeginRequest event
instead.
For an example that shows how to use
the Application_BeginRequest event,
see the PersonalWebSite Sample that
ships with the Windows Azure SDK.
If you use:
StorageAccountInfo account = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();
Usually the account information is given in the Web.conf file.
<add key="TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1" />
<add key="AccountName" value="devstoreaccount1" />
<add key="AccountSharedKey" value="YOUR ACCOUNT KEY PROVIDED BY AZURE"/>