1

Why can't I make an embedded RavenDB work in a fresh asp.net MVC website?

I have successfully tried and tested the following code in a simple .net console application. It works just fine, until I try and use it in an MVC website.

It doesn't throw any error, it just hangs after attempting to Initialize()

In my bug-finding process, I installed a RavenDB server on localhost, which I can connect to in my MVC application - that is not a problem. But the initialize error was there before I installed the localhost RavenDB as well as after.

I hope you can help sort this out!

public static class Store {
  private static IDocumentStore store = createStore();

  private static EmbeddableDocumentStore createStore() {
    var returnStore = new EmbeddableDocumentStore();
    returnStore.DataDirectory = @"./PersistedData";
    returnStore.Initialize(); // It never gets past this in any MVC website
    return returnStore;
  }

  public static myDocument Read(string key) {
    using (var session = store.OpenSession()) {
      var anEntity = session.Query<myDocument>().Where(item => item.key == key).Single();
      return anEntity;
    }
  }

  public static void Write(myDocument d) {
    using (var session = store.OpenSession()) {
      session.Store(d);
      session.SaveChanges();
    }
  }
}

public class myDocument {
  public string key { get; set; }
  public string description { get; set; }
}

UPDATE

The following errors are logged and show up in the Event Viewer:

INFORMATION: Raven (11096) 1-RT4um-C:\Users\***\RavenEmbed\./PersistedData\Data: 
The database engine attached a database (1, C:\Users\***\RavenEmbed\PersistedData\Data).
(Time=0 seconds) 

ERROR: Windows cannot open the 64-bit extensible counter DLL ASP.NET_64_2.0.50727 in a 
32-bit environment. Contact the file vendor to obtain a 32-bit version. Alternatively if 
you are running a 64-bit native environment, you can open the 64-bit extensible counter 
DLL by using the 64-bit version of Performance Monitor. To use this tool, open the 
Windows folder, open the System32 folder, and then start Perfmon.exe.

ERROR: Disabled performance counter data collection for this session from the 
"ASP.NET_64_2.0.50727" service because the performance counter library for that service 
has generated one or more errors. The errors that forced this action have been written 
to the application event log.

ERROR: The Open Procedure for service "BITS" in DLL "C:\Windows\System32\bitsperf.dll" 
failed. Performance data for this service will not be available. The first four bytes 
(DWORD) of the Data section contains the error code.

ERROR: The Open Procedure for service "Lsa" in DLL "C:\Windows\System32\Secur32.dll" 
failed. Performance data for this service will not be available. The first four bytes 
(DWORD) of the Data section contains the error code.

ERROR: The Open Procedure for service "MSDTC" in DLL "C:\Windows\system32\msdtcuiu.DLL" 
failed. Performance data for this service will not be available. The first four bytes 
(DWORD) of the Data section contains the error code.

ERROR: The configuration information of the performance library "perf-MSSQL$SQLEXPRESS-
sqlctr11.1.3000.0.dll" for the "MSSQL$SQLEXPRESS" service does not match the trusted 
performance library information stored in the registry. The functions in this library 
will not be treated as trusted.

UPDATE 2

I can download an MVC 3 project from this link, which works. But I still can't the MVC 4 embedded RavenDB to work.

http://archive.msdn.microsoft.com/mag201111NoSQL/Release/ProjectReleases.aspx?ReleaseId=5778

Joel Hansen
  • 198
  • 1
  • 12
  • What is the actual error you got? – Ayende Rahien Jan 21 '14 at 13:41
  • I've just realized that the event viewer logs something which might provide a clue. Please check the updated description. Thank you! – Joel Hansen Jan 21 '14 at 14:37
  • I have this problem as well, @AyendeRahien, there are no errors given from the code, if you break on `Initialize()` you hit that, then press F10, it'll never hit the next line. I can switch the `DocumentStore` to `RunInMemory` and the project will start. Without the `RunInMemory` switch, I can see the files all created in the right location, but the DB never initializes. (I'm on MVC5, brand new, nuget import Embedded etc) – Charlotte Skardon Aug 14 '14 at 09:56

0 Answers0