RavenDB client onlinux connecting to windows server using mono http - mono

I've just tried connecting to my RavenDB windows instance from linux using mono. I'm getting a bizarre error with it, that seems to be mono related rather than raven related.
Here is my recreate code (works on windows):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Raven.Client.Document;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
try
{
var store = new DocumentStore()
{
ConnectionStringName = "RavenDB",
EnlistInDistributedTransactions = false
};
store.Initialize();
using (var session = store.OpenSession("system-events"))
{
session.Store(new { Name = "Test" });
session.SaveChanges();
}
Console.WriteLine("done");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.ReadKey();
}
}
}
and my mono version:
chris#x-ngx4:~/click/beta/Debug$ mono --version
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
and the error:
chris#x-ngx4:~/click/beta/Debug$ mono ConsoleApplication2.exe
System.IO.IOException: Internal error (no progress possible) Flush
at System.IO.Compression.DeflateStream.CheckResult (Int32 result, System.String where) [0x00000] in <filename unknown>:0
at System.IO.Compression.DeflateStream.Flush () [0x00000] in <filename unknown>:0
at System.IO.Compression.GZipStream.Flush () [0x00000] in <filename unknown>:0
at Raven.Abstractions.Connection.HttpRequestHelper.WriteDataToRequest (System.Net.HttpWebRequest req, System.String data, Boolean disableCompression) [0x00000] in <filename unknown>:0
at Raven.Client.Connection.HttpJsonRequest.Write (System.String data) [0x00000] in <filename unknown>:0
at Raven.Client.Connection.ServerClient.DirectBatch (IEnumerable`1 commandDatas, System.String operationUrl) [0x00000] in <filename unknown>:0
at Raven.Client.Connection.ServerClient+<>c__DisplayClass68.<Batch>b__67 (System.String u) [0x00000] in <filename unknown>:0
at Raven.Client.Connection.ReplicationInformer.TryOperation[BatchResult[]] (System.Func`2 operation, System.String operationUrl, Boolean avoidThrowing, Raven.Abstractions.Data.BatchResult[]& result) [0x00000] in <filename unknown>:0

I think I found it. DeflateStream has extern references to zlib. If you look at the zlib header file, you will find some comments:
deflate() returns Z_OK if some progress has been made (more input
processed or more output produced), Z_STREAM_END if all input has been
consumed and all output has been produced (only when flush is set to
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for
example if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress
is possible (for example avail_in or avail_out was zero). Note that
Z_BUF_ERROR is not fatal, and deflate() can be called again with more
input and more output space to continue compressing.
The message Internal error (no progress possible) is what DeflateStream returns when getting a Z_BUF_ERROR - but it doesn't continue, it treats it as a hard stop. It should treat it as a warning and continue. At least, that's my interpretation.
Can you raise this with the mono support team? I'm not active in that group. Thanks.

Related

Getting "Can't find custom atter constructor image" from a .dll after upgrading to Unity5

I've just upgraded to Unity5 and a small .dll I've made started to give the following error:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
Missing method .ctor in assembly [myproj... .dll], type System.Runtime.Versioning.TargetFrameworkAttribute
The class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in Logger
Can't find custom attr constructor image: [myproj... .dll]
mtoken: 0x0a00000e
​
The .dll worked perfectly before updating to Unity 5, and I did recompile the .dll with the unity5 version UnityEngine.dll (needed by my library), but that didn't help. Any ideas how to fix this?

EF 7 Beta 8 -> EF7 RC1 - No longer can create migrations

After attempting to change my existing project from beta 8 to RC1 I get the following after running dnx ef migrations add Init
System.TypeLoadException: Could not load type 'Microsoft.Data.Entity.Scaffolding.SqliteDesignTimeServices, EntityFramework.Sqlite.Design'.
at Microsoft.Data.Entity.Design.Internal.DesignTimeServicesBuilder.ConfigureProviderServices (System.String provider, IServiceCollection services, Boolean throwOnError) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Design.Internal.DesignTimeServicesBuilder.Build (Microsoft.Data.Entity.DbContext context) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Design.MigrationsOperations.AddMigration (System.String name, System.String outputDir, System.String contextType) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program+Executor+<>c__DisplayClass6_0.<AddMigration>b__0 () [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program+Executor.Execute (System.Action action) [0x00000] in <filename unknown>:0
Could not load type 'Microsoft.Data.Entity.Scaffolding.SqliteDesignTimeServices, EntityFramework.Sqlite.Design'.
My project.json file contains along with others the following
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.SQLite": "7.0.0-rc1-final"
},
"commands": {
"ef": "EntityFramework.Commands"
},
What do I need to do to resolve this error?
Package names are case-sensitive on Linux and OS X due to the case-sensitive filesystem. Make sure to use EntityFramework.Sqlite not EntityFramework.SQLite in your project.json file. (See GitHub Issue dotnet/cli#236)
First resolve your references / dependencies. All reference warnings must be solved and must be "7.0.0-rc1-final".
If there is no "7.0.0-rc1-final" version then probably something is renamed to a different name. See the annoncement repro for breaking changes
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.SQLite": "7.0.0-rc1-final"
},

Creating Roslyn MetadataFileReference bombs on mono/Linux

I'm doing on some basic Roslyn stuff, and have run into what appears to be a mono compatibility issue. Wanted to make sure I'm not doing something wrong and hear other people's experience. Am using Roslyn from the Microsoft.CodeAnalysis nuget, version 0.7.4091001-beta (latest).
var mscorlib = new MetadataFileReference(typeof(object).Assembly.Location);
var compilation = CSharpCompilation.Create("Temp", new SyntaxTree[0], new[] { mscorlib });
compilation.GetAssemblyOrModuleSymbol(mscorlib);
While this works on Microsoft .NET, on mono on Linux the last line produces the following exception:
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Absolute path expected.
Parameter name: fullPath
at Microsoft.CodeAnalysis.CommonReferenceManager`2[Microsoft.CodeAnalysis.CSharp.CSharpCompilation,Microsoft.CodeAnalysis.CSharp.Symbols.AssemblySymbol].ResolveMetadataReferences (Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation, System.Collections.Immutable.ImmutableArray`1& references, IDictionary`2& boundReferenceDirectiveMap, System.Collections.Immutable.ImmutableArray`1& boundReferenceDirectives, System.Collections.Immutable.ImmutableArray`1& assemblies, System.Collections.Immutable.ImmutableArray`1& modules, Microsoft.CodeAnalysis.DiagnosticBag diagnostics) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation+ReferenceManager.CreateAndSetSourceAssemblyFullBind (Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation+ReferenceManager.CreateSourceAssemblyForCompilation (Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetBoundReferenceManager () [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetAssemblyOrModuleSymbol (Microsoft.CodeAnalysis.MetadataReference reference) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonGetAssemblyOrModuleSymbol (Microsoft.CodeAnalysis.MetadataReference reference) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.Compilation.GetAssemblyOrModuleSymbol (Microsoft.CodeAnalysis.MetadataReference reference) [0x00000] in <filename unknown>:0
at playground2.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
There's obviously some sort of path parsing Linux/Windows sadness going on here. My current workaround is to create the reference to corlib thus:
var mscorlibMetadata = AssemblyMetadata.CreateFromImageStream(new FileStream(typeof(object).Assembly.Location, FileMode.Open, FileAccess.Read));
var mscorlib = new MetadataImageReference (mscorlibMetadata);
Does anybody know anything about this?
This is a bug in Roslyn.
You can send them a pull request to fix PathUtilities.GetPathKind to be aware of Linux-style paths by checking Path.DirectorySeparatorChar.

Access to the path "/etc/mono/registry" is denied

When I run my ASP.NET MVC 4 website on my Fedora 20 workstation with xsp4 (from MonoDevelop or directly) I'm getting the following exception:
System.Web.HttpRuntime.FinishWithException (wr={Mono.WebServer.XSPWorkerRequest}, e={System.Web.HttpException: ---> System.Web.HttpException: The pre-application start initialization method Start on type System.Web.WebPages.PreApplicationStartCode threw an exception with the following error message: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for <Module> ---> System.Security.SecurityException: No access to the given key ---> System.UnauthorizedAccessException: Access to the path "/etc/mono/registry" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00064] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.IO/Directory.cs:113
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.IO/Directory.cs:80
at System.IO.DirectoryInfo.Create () [0x00000] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.IO/DirectoryInfo.cs:141
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00039] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.IO/Directory.cs:98
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.IO/Directory.cs:80
at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir, Boolean is_volatile) [0x0004a] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs:136
--- End of inner exception stack trace ---
at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir, Boolean is_volatile) [0x00057] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs:138
at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir) [0x00000] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs:116
at Microsoft.Win32.KeyHandler.Lookup (Microsoft.Win32.RegistryKey rkey, Boolean createNonExisting) [0x000cc] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs:412
at Microsoft.Win32.UnixRegistryApi.OpenSubKey (Microsoft.Win32.RegistryKey rkey, System.String keyname, Boolean writable) [0x00000] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs:836
at Microsoft.Win32.RegistryKey.OpenSubKey (System.String name, Boolean writable) [0x0001e] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs:278
at Microsoft.Win32.RegistryKey.OpenSubKey (System.String name) [0x00000] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs:262
at (wrapper remoting-invoke-with-check) Microsoft.Win32.RegistryKey:OpenSubKey (string)
at Microsoft.Web.Infrastructure.RegistryKeyWrapper.OpenSubKey (System.String name) [0x00000] in <filename unknown>:0
at Microsoft.Web.Infrastructure.KillBitHelper.GetKillBittedVersions () [0x00000] in <filename unknown>:0
at Microsoft.Web.Infrastructure.KillBitHelper.IsThisAssemblyKillBitted () [0x00000] in <filename unknown>:0
at Microsoft.Web.Infrastructure.KillBitHelper.ThrowIfKillBitIsSet () [0x00000] in <filename unknown>:0
at Microsoft.Web.Infrastructure.ModuleInitializer+CriticalInitializer.CheckKillBit () [0x00000] in <filename unknown>:0
at Microsoft.Web.Infrastructure.ModuleInitializer+CriticalInitializer.Initialize () [0x00000] in <filename unknown>:0
at Microsoft.Web.Infrastructure.ModuleInitializer.Initialize () [0x00000] in <filename unknown>:0
at <Module>..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Web.WebPages.PreApplicationStartCode.Start () [0x0002b] in /builddir/build/BUILD/mono-3.4.0/external/aspnetwebstack/src/System.Web.WebPages/PreApplicationStartCode.cs:40
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00069] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.Reflection/MonoMethod.cs:238
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /builddir/build/BUILD/mono-3.4.0/mcs/class/corlib/System.Reflection/MethodBase.cs:114
at System.Web.Compilation.BuildManager.CallPreStartMethods () [0x0004f] in /builddir/build/BUILD/mono-3.4.0/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:561
--- End of inner exception stack trace ---
at System.Web.Compilation.BuildManager.CallPreStartMethods () [0x0007e] in /builddir/build/BUILD/mono-3.4.0/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:564
at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00059] in /builddir/build/BUILD/mono-3.4.0/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs:408
--- End of inner exception stack trace ---}) in /builddir/build/BUILD/mono-3.4.0/mcs/class/System.Web/System.Web/HttpRuntime.cs:674
I've checked it and there is no registry file or folder in /etc/mono/. I also can't find it in any subfolder, how can I resolve this question?
I'm running Fedora 20 with the latest 3.15.6 kernel
$ mono --version
Mono JIT compiler version 3.4.0 (tarball Fri Jun 27 17:26:36 UTC 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
$ xsp4 --version
xsp4.exe 3.0.0.0
Copyright (C) 2002-2011 Novell, Inc.
Minimalistic web server for testing System.Web
I have another setup in Ubuntu 14.04 LTS and that one works, so it might be something with the mono version, or maybe I'm missing some library?
Turns out simply creating the folder using mkdir
sudo mkdir /etc/mono/registry
and setting the right permissions using chmod
sudo chmod uog+rw /etc/mono/registry
does the trick.
However I still don't understand where such a folder is hidden in Ubuntu and why it doesn't need to be created there, as well as why it isn't created automatically during the installation.
You can set MONO_REGISTRY_PATH to point to a directory that you control:
bash
mkdir my-registry
MONO_REGISTRY_PATH=`pwd`/my-registry
xsp4

Embedded mono + app.config

I have embedded mono in a c++ program and loaded a dll which requires an app.config. I am getting this kind of error, does someone have an idea on how to ship *.config with an embedded mono ?
The stack trace :
System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.ArgumentException: The 'ExeConfigFilename' argument cannot be null.
at System.Configuration.ExeConfigurationHost.CheckFileMap (ConfigurationUserLevel level, System.Configuration.ExeConfigurationFileMap map) [0x00000] in <filename unknown>:0
at System.Configuration.ExeConfigurationHost.InitForConfiguration (System.String& locationSubPath, System.String& configPath, System.String& locationConfigPath, IInternalConfigRoot root, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.C[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0 onfiguration.InternalConfigurationSystem.InitForConfiguration (System.String& locationConfigPath, System.String& parentConfigPath, System.String& parentLocationConfigPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object
Self answer : you can't (as of 2013-04-30). To enable this behaviour, I had to change mono's framework sources mono/mcs/class/corlib/system/appdomain.cs :
public AppDomainSetup SetupInformation {
get {
return SetupInformationNoCopy; // newline
// AppDomainSetup setup = getSetup (); //old
// return new AppDomainSetup (setup); //old
}
}