When I try to host a WCF service, that works perfectly in Windows, in a mono console application I get the following error (*):
An element with the same key already exists in the dictionary.
I don't get at all why this is happening or where I need to look to fix this. Anyone who has experienced this or can point me in the right direction?
I am using Mono 2.10.8 on a Mac running Os X 10.6.8.
*Stacktrace:
at System.Collections.ObjectModel.KeyedCollection`2[System.Type,System.ServiceModel.Description.IOperationBehavior].InsertItem (Int32 index, IOperationBehavior item) [0x0003a] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/corlib/System.Collections.ObjectModel/KeyedCollection.cs:168
at System.Collections.Generic.KeyedByTypeCollection`1[System.ServiceModel.Description.IOperationBehavior].InsertItem (Int32 index, IOperationBehavior kind) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.Collections.Generic/KeyedByTypeCollection.cs:70
at System.Collections.ObjectModel.Collection`1[System.ServiceModel.Description.IOperationBehavior].Add (IOperationBehavior item) [0x0000c] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/corlib/System.Collections.ObjectModel/Collection.cs:74
at System.ServiceModel.Description.ContractDescriptionGenerator.GetOrCreateOperation (System.ServiceModel.Description.ContractDescription cd, System.Reflection.MethodInfo mi, System.Reflection.MethodInfo serviceMethod, System.ServiceModel.OperationContractAttribute oca, System.Type asyncReturnType, Boolean isCallback, System.Type givenServiceType) [0x00511] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs:350
at System.ServiceModel.Description.ContractDescriptionGenerator.FillOperationsForInterface (System.ServiceModel.Description.ContractDescription cd, System.Type exactContractType, System.Type givenServiceType, Boolean isCallback) [0x00131] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs:240
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContractInternal (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x001ed] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs:190
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs:136
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs:131
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type contractType) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs:101
at System.ServiceModel.Description.ContractDescription.GetContract (System.Type contractType) [0x00017] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs:66
at System.ServiceModel.ServiceHost.AddServiceEndpoint (System.Type implementedContract, System.ServiceModel.Channels.Binding binding, System.Uri address, System.Uri listenUri) [0x00022] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs:96
at System.ServiceModel.ServiceHost.AddServiceEndpoint (System.Type implementedContract, System.ServiceModel.Channels.Binding binding, System.Uri address) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs:85
at ConsoleApplication3.Program.Main (System.String[] args) [0x0002b] in /Users/steven/Software/ABC Cloud/NooSphere/Mono.Host/Main.cs:16
This was a bug in Mono and has been fixed in mono-2.10.9 (Mac only updated) and Mono for Android 4.2.7
Related
I have an application that is made by .NET and i use mono 6.4.0.198 (i use the newest mono so the app is compatible with Catalina MacOS) to run it on the Mac machine, on my machine the mono is installed so the app works fine, but when i run the app on other Macs it return the following exception
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Diagnostics.SystemDiagnosticsSection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Diagnostics.AssertSection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ComponentModel.TypeDescriptor' threw an exception. ---> System.DllNotFoundException: /libmono-native-compat.dylib assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Interop+Sys.GetNonCryptographicallySecureRandomBytes(byte*,int)
at Interop.GetRandomBytes (System.Byte* buffer, System.Int32 length) [0x00000] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.Guid.NewGuid () [0x00000] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.ComponentModel.TypeDescriptor..cctor () [0x00034] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationProperty..ctor (System.String name, System.Type type, System.Object defaultValue, System.Configuration.ConfigurationPropertyOptions options) [0x00000] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Diagnostics.AssertSection..cctor () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
at System.Diagnostics.SystemDiagnosticsSection..cctor () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <b814b509d4ad406fb40c6c93e38929e7>:0
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001a] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic, System.Boolean wrapExceptions) [0x00095] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean wrapExceptions, System.Boolean skipCheckThis, System.Boolean fillCache) [0x00009] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Boolean wrapExceptions, System.Threading.StackCrawlMark& stackMark) [0x00027] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic, System.Boolean wrapExceptions) [0x00020] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <b814b509d4ad406fb40c6c93e38929e7>:0
at System.Configuration.ConfigInfo.CreateInstance () [0x00026] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Configuration.SectionInfo.CreateInstance () [0x00000] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, System.Boolean createDefaultInstance) [0x0001c] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x0002c] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Configuration.Configuration.GetSection (System.String sectionName) [0x00016] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00006] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00005] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0
at System.Configuration.PrivilegedConfigurationManager.GetSection (System.String sectionName) [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
at System.Diagnostics.DiagnosticsConfiguration.Initialize () [0x0002a] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
at System.Diagnostics.TraceInternal.InitializeSettings () [0x0004e] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
at System.Diagnostics.TraceInternal.get_Listeners () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
at System.Diagnostics.Trace.get_Listeners () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0
at Zoolz.Program.Main (System.String[] args) [0x00040] in <d6a87962027b42c6878475ce75623731>:0
clearly its a missing dll libmono-native-compat.dylib i added this dll at the application resources alongside other dlls but the app still returning the same missing dll exception, how i can direct mono to dll so i would fix this problem
I had many errors when I installed the macOS Catalina until I decide to give permission to my /private/tmp folder. It seems all apps work now. I don't know if it's your case but just in case try this:
sudo chmod 777 /private/tmp
I solved this issue by
creating a file called fix.config and it contains the following XML
<configuration>
<dllmap dll="System.Native" target="libmono-native-compat.dylib" os="!windows" />
<dllmap dll="System.Net.Security.Native" target="libmono-native-compat.dylib" os="!windows" />
<dllmap dll="System.Security.Cryptography.Native.Apple" target="libmono-native-compat.dylib" os="osx" />
</configuration>
the i copied the three dylibs that are mentioned in the XML to the path Application/MyApp.app/Contents/lib
then in the in the building script i added to the tool mkbundle the following command
--config $SETUP_DIR/fix.config and setup path is the path where im creating my .pkg file
NOTE: im using mono version 6.4.0.198
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.
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
}
}
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.
I'm attempting to get my first NHibernate project up and running in Mono/openSUSE 11.4. My unit tests are working successfully under Windows but when I attempt to run the same tests on Mono I'm getting an exception when I try to get back the Query object from my NHibernate session.
Saving data through NHibernate seems to be working correctly.
I'm using Mono 2.10.2 and NUnit version 2.4.8 with Fluent NHibernate 1.2 for NHibernate 3.1.
I've included the full output from nunit-console just in case:
>NUnit version 2.4.8
>Copyright (C) 2002-2007 Charlie Poole.
>Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
>Copyright (C) 2000-2002 Philip Craig.
>All Rights Reserved.
>
>Runtime Environment -
>OS Version: Unix 2.6.37.1
>CLR Version: 4.0.30319.1 ( 2.10.2 (tarball Mon Apr 18 15:12:52 UTC 2011) )
>
>.F
>Tests run: 1, Failures: 1, Not run: 0, Time: 1.563 seconds
>
>Test Case Failures:
>1) MyTests.MyTest : System.TypeInitializationException : An exception was thrown by the type initializer for NHibernate.Linq.NhRelinqQueryParser
>----> System.Reflection.ReflectionTypeLoadException : The classes in the module cannot be loaded.
>at NHibernate.Linq.NhLinqExpression.Translate (ISessionFactoryImplementor sessionFactory) [0x00000] in <filename unknown>:0
>at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators (System.String queryIdentifier, IQueryExpression queryExpression, System.String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) [0x00000] in <filename unknown>:0
>at NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators (System.String expressionStr, IQueryExpression queryExpression, System.String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) [0x00000] in <filename unknown>:0
>at NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor (System.String expressionStr, IQueryExpression queryExpression, System.String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) [0x00000] in <filename unknown>:0
>at NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor (System.String expressionStr, IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) [0x00000] in <filename unknown>:0
>at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan (IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters) [0x00000] in <filename unknown>:0
>at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan (IQueryExpression queryExpression, Boolean shallow) [0x00000] in <filename unknown>:0
>at NHibernate.Impl.AbstractSessionImpl.CreateQuery (IQueryExpression queryExpression) [0x00000] in <filename unknown>:0
>at NHibernate.Linq.NhQueryProvider.PrepareQuery (System.Linq.Expressions.Expression expression, IQuery& query, NHibernate.Linq.NhLinqExpression& nhQuery) [0x00000] in <filename unknown>:0
>at NHibernate.Linq.NhQueryProvider.Execute (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0
>at NHibernate.Linq.NhQueryProvider.Execute[IEnumerable`1] (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0
>at Remotion.Data.Linq.QueryableBase`1[MyProject.Entities.Email].GetEnumerator () [0x00000] in <filename unknown>:0
>at System.Collections.Generic.List`1[MyProject.Entities.Email].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/corlib/System.Collections.Generic/List.cs:126
>at System.Collections.Generic.List`1[MyProject.Entities.Email]..ctor (IEnumerable`1 collection) [0x0002f] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/corlib/System.Collections.Generic/List.cs:63
>at System.Linq.Enumerable.ToList[Email] (IEnumerable`1 source) [0x00006] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/System.Core/System.Linq/Enumerable.cs:2847
>at MyTests.MyTest () [0x0000c] in /tmp/source/MyTests/MyTest.cs:125
>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) [0x000d5] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/corlib/System.Reflection/MonoMethod.cs:226
>--ReflectionTypeLoadException
>at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
>at System.Reflection.Assembly.GetTypes () [0x00000] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/corlib/System.Reflection/Assembly.cs:346
>at Remotion.Data.Linq.Parsing.Structure.ExpressionTreeParser.CreateDefaultNodeTypeProvider () [0x00000] in <filename unknown>:0
>at NHibernate.Linq.NHibernateNodeTypeProvider..ctor () [0x00000] in <filename unknown>:0
>at NHibernate.Linq.NhRelinqQueryParser..cctor () [0x00000] in <filename unknown>:0
Following AlexCuse's advice I ran monodis against the DLLs. All of the NHibernate dlls are set to CopyLocal. They seem to be happy with monodis. NHibernate.dll doesn't however. Here is the end of the output:
class NHibernate.Context.WcfStateExtension V_0)
IL_0000: call Missing method get_Current in assembly
/tmp/source/MyTests/NHibernate.dll, type
System.ServiceModel.OperationContext
[System.ServiceModel]System.ServiceModel.OperationContext::get_Current()
IL_0005: callvirt Missing method get_Extensions in assembly
/tmp/source/MyTests/NHibernate.dll, type
System.ServiceModel.OperationContext instance <>
[System.ServiceModel]System.ServiceModel.OperationContext::get_Extensions()
IL_000a: callvirt Missing method Find in assembly
/tmp/source/MyTests/NHibernate.dll, type Typespec 0x1b00017e Missing
method Find in assembly /tmp/source/MyTests/NHibernate.dll, type
Typespec 0x1b00017e
* Assertion at get.c:2097, condition `mh' not met
Aborted
mono -v
Mono JIT compiler version 2.10.2 (tarball Mon Apr 18 15:12:52 UTC 2011)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: debugger softdebug
LLVM: yes(2.9svn-mono)
GC: Included Boehm (with typed GC and Parallel Mark)
I gave up and installed Fluent NHibernate 1.1 with NHibernate.Linq-2.1.2-GA. All seems to be happy in the world of my unit tests but I'm still trying to figure out what is going so wrong with the current version.
I rolled back to use NHibernate 2.1.2 with the additional Linq library which worked fine but then I revisited this the other day I found the fix was ridiculously simple.
The mono-wcf package was not installed on my system. NHibernate 3.2 requires WCF. Now I've installed it, it is all working perfectly!
Are all of your libraries referenced with "CopyLocal" set to true? If so, running
/path/to/mono/monodis <DLLNAME>
on your bin directory may help to determine if they are valid assemblies: (http://comments.gmane.org/gmane.comp.gnome.mono.aspnet/1106)
I've seen this (on older versions of mono AND fluent NHibernate) when dealing with classes that were not CLS-compliant, but in that case it was able to load the assembly to use other classes (I was not loading with reflection though).