I've started creating a Script Pack for RavenDB to fit into the ScriptCS ecosystem. It works pretty well, except the studio is giving me a weird exception. I wonder if somebody could help me diagnose what the heck the issue is. Oddly the Raven.Client inside of ScriptCS is completely fine calling out to the database and manipulating documents.
Here are the steps to get started.
1. Install ScriptCs through Chocolatey
3. Build the solution
4 In a console (after ScriptCs is in the Path), go to the sample folder and run "scriptcs sample.csx"
When you double click on the document to view it, you get a nasty message. The script isn't doing anything crazy as seen below.
var ravenDb = Require<RavenDB>();
ravenDb.CreateEmbeddableDocumentStore(runInMemory: true);
public class Entry {
public string Id { get;set; }
public string Description { get;set; }
public override string ToString() {
return Description;
}
}
var doc = new Entry {
Id = "scriptcs-ravendb",
Description = "scriptcs loves RavenDB"
};
using (var session = ravenDb.OpenSession()) {
session.Store(doc);
session.SaveChanges();
}
using (var session = ravenDb.OpenSession()) {
var loaded = session.Load<Entry>(doc.Id);
Console.WriteLine(loaded);
}
Console.ReadKey()
Server Error:
-----------------------------------------
/docs/scriptcs-ravendb?noCache=-1681451849
System.ArgumentException: Specified value has invalid Control characters.
Parameter name: value
at System.Net.WebHeaderCollection.CheckBadChars(String name, Boolean isHeaderValue)
at System.Net.WebHeaderCollection.SetInternal(String name, String value)
at Raven.Database.Extensions.HttpExtensions.WriteHeaders(IHttpContext context, RavenJObject headers, Guid etag) in c:\Builds\RavenDB-Stable\Raven.Database\Extensions\HttpExtensions.cs:line 223
at Raven.Database.Extensions.HttpExtensions.WriteData(IHttpContext context, Byte[] data, RavenJObject headers, Guid etag) in c:\Builds\RavenDB-Stable\Raven.Database\Extensions\HttpExtensions.cs:line 194
at Raven.Database.Extensions.HttpExtensions.WriteData(IHttpContext context, RavenJObject data, RavenJObject headers, Guid etag) in c:\Builds\RavenDB-Stable\Raven.Database\Extensions\HttpExtensions.cs:line 188
at Raven.Database.Server.Responders.Document.GetDocumentDirectly(IHttpContext context, String docId) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Document.cs:line 168
at Raven.Database.Server.Responders.Document.Respond(IHttpContext context) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Document.cs:line 43
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line 864
at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line 609
-----------------------------------------
at Raven.Studio.Infrastructure.InvocationExtensions.Catch(Task parent, Func`2 func)
at Raven.Studio.Models.EditableDocumentModel.LoadModelParameters(String parameters)
at Raven.Studio.Infrastructure.PageViewModel.LoadModel(String state)
at Raven.Studio.Infrastructure.PageView.OnNavigatedTo(NavigationEventArgs e)
at System.Windows.Navigation.NavigationService.RaiseNavigated(Object content, Uri uri, Page existingContentPage, Page newContentPage)
at System.Windows.Navigation.NavigationService.CompleteNavigation(DependencyObject content)
at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)
at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
Client side exception:
System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Func`2.Invoke(T arg)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise)