FluentNHibernate exception - Could not compile the mapping document - c#

Before posting this question I reviewed:
Runtime error when trying to run Fluent NHibernate tutorial example
Fluent nHibernate error - Could not compile the mapping document: (XmlDocument)
and many more similar questions which I was hoping could shed some light on my issue. No luck so far:
I was working a solution for some time now and everything was going fine until my most recent change. The solution still compiles but fails on startup with this exception:
An unhandled exception of type
'FluentNHibernate.Cfg.FluentConfigurationException' occurred in
xx.Initialization.dll
in View Details it says:
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail."
PotentialReasons: Count = 0
InnerException: Could not compile the mapping document: xx.Website.Persistence.Repository.Mappings.UI.yyDataDto.hbm.xml
Inner exception: JIT Compiler encountered an internal limitation.
The .hbm.xml file that the exception is referring to is intact and there were no changed made to it. All of my code changes are covered by tests and whatever I changed doesn't seem to involve the exception directly.
To troubleshoot this, I committed and pushed all of my changes (feature branch) and asked my co-worker to get latest version. He was able to run the solution without any exceptions. I tried restarting my VS2013, my workstation, deleting my repository and getting the solution from scratch through source control as well as by a direct copy of my co-worker's solution folder (latest version) and still receiving the same error.
Not sure what else to try. Any tips/suggestions would be greatly appreciated. Thanks!
edit/update:
Today I attempted to repair my VS2013 installation, that didn't help. I then updated to latest service pack 4. Also no results.
I'm guessing at this point that something may be wrong with my debugger/settings because if I build the project and launch it (without debugging or by navigating to Bin folder and executing directly) it runs without exceptions. If I debug, I get the exception.
Here's the stacktrace:
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.ConfigureSessionFactory[TFluentMapping](String defaultSchema, String connectionStringKey)
at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.<>c__DisplayClassa`1.<RegisterNHibernate>b__5()
at Castle.MicroKernel.Registration.ComponentRegistration`1.<>c__DisplayClassf`1.<UsingFactoryMethod>b__e(IKernel k, ComponentModel m, CreationContext c)
at Castle.MicroKernel.ComponentActivator.FactoryMethodActivator`1.Instantiate(CreationContext context)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context)
at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context)
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired)
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context, Boolean instanceRequired)
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service)
at Castle.MicroKernel.DefaultKernel.Resolve(String key, Type service)
at Castle.MicroKernel.DefaultKernel.Resolve[T](String key)
at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.<>c__DisplayClassa`1.<RegisterNHibernate>b__7(IKernel kernel)
at Castle.MicroKernel.Registration.ComponentRegistration`1.<>c__DisplayClass12`1.<UsingFactoryMethod>b__11(IKernel k, ComponentModel m, CreationContext c)
at Castle.MicroKernel.ComponentActivator.FactoryMethodActivator`1.Instantiate(CreationContext context)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context)
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired)
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context, Boolean instanceRequired)
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service)
at Castle.MicroKernel.DefaultKernel.Resolve(String key, Type service)
at Castle.Windsor.WindsorContainer.Resolve[T](String key)
at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.RegisterNHibernate[TFluentMapping](String factoryName, String sessionName, String defaultSchema, String connectionStringKey)
at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.Start()
at Company.Framework.Startup.Behaviour.BehaviourManager.AddAndInitialize[T](Action`1 initialize)
at Company.Framework.Startup.Behaviour.BehaviourManager.Add[T](Action`1 initialize)
at Company.Project.Initialization.ServiceInitializator.ConfigureBehaviours() in c:\Path\Project.Initialization\ServiceInitializator.cs:line 99

The solution was to uninstall VS2013 completely and re-install it from scratch. After I did that, the exception went away.
I tried to remember what could've caused this and so far my only suspicion is that maybe when I ran CCleaner (prior to this issue appearing), it removed files or registry entries which made VS behave in such a way.

Related

Unable to load shared library 'python37' or one of its dependencies

I am quite new to dotnet and Keras.NET, and I was trying to set it up on a goorm.io container. After installing the prerequisites (adding $HOME/.keras/keras.json for Tensorflow backend and pip install numpy), and then adding Keras.NET, I tried to run the XOR sample code, but ran into an error.
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'python37' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libpython37: cannot open shared object file: No such file or directory
at Python.Runtime.Runtime.Py_IsInitialized()
at Python.Runtime.Runtime.Initialize(Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(IEnumerable1 args, Boolean setSysArgv, Boolean initSigs) at Python.Runtime.PythonEngine.Initialize(Boolean setSysArgv, Boolean initSigs) at Python.Runtime.PythonEngine.Initialize() at Numpy.np.InstallAndImport(Boolean force) at Numpy.np.<>c.<.cctor>b__599_0() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue()
at System.Lazy1.get_Value() at Numpy.np.get_self() at Numpy.np.get_float32() at Numpy.DtypeExtensions.GetDtype(Object obj) at Numpy.np.array[T](T[,] object, Dtype dtype, Nullable1 copy, String order, Nullable1 subok, Nullable1 ndmin)
at Proj.Program.Main(String[] args) in /workspace/XOR/Proj/Program.cs:line 14
I do not know how to share with the python37 directory. If someone could direct me in the right direction, it would be much appreciated. By the way, I am using Linux if that helps.
Thanks

Entity Framework 6.1.3 : InvalidOperationException after a few days of running

I have a strange problem. I have a Windows service. Service runs ok on over 100 computers. But on a few of them after a few (or even a month) days it starts to throw exceptions like this:
System.InvalidOperationException: The 'X' property on 'Y' could not be set to a 'System.String' value. You must set this property to a non-null value of type 'System.Int32'.
in System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
in System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)
in lambda_method(Closure , Shaper )
in System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
in lambda_method(Closure , Shaper )
in System.Data.Entity.Core.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
in System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
in System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
in System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
There weren't any modification in code on in database structure. Exception is thrown in a few places. Other applications (not windows services) runs properly with the same database. As I can check some queries runs ok, only a few of them throws this exception. Type are various. Sometimes it can't convert from string to int32 and sometimes (in other query) it can't convert from int32 to string.
To fix the problem we have to restart Windows service.
I don't have any problem with memory (my first suspect). Service use about 100-150MB of ram.
Environment: Framework 4.0, EF 6.1.3, 64bit, SQL Server 2012 Express.
It seems like to need to do alot of logging job here. What I recommend, is that first of all, debug the cases and write logs in each place your code throws exceptions.
As a matter of precaution, do try to check as best as possible if your properties in your object are convertible - using int.TryParse:
if(int.TryParse(X, out intVar)
{
}
else
{
//failed to convert
}
Use also try catch and issue a log error with the exact stack trace, this is preferable for string exceptions as you cannot do try parse on a string property.
There is no easy way here, you will have to dig this through piece by piece.

TFS Git build breaks after updating build definition

Our TFS build has broken following updating the XAML build definition. Changes included modifying the template and a few parameters. The trace is below
TF215097: An error occurred while initializing a build for build definition [REDACTED]:
Exception Message: Cannot set unknown member 'Microsoft.TeamFoundation.Build.Activities.Git.GitPull.CheckoutSubmodules'. (type XamlObjectWriterException)
Exception Stack Trace: at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
at System.Activities.XamlIntegration.FuncFactory`1.Evaluate()
at System.Activities.DynamicActivity.OnInternalCacheMetadata(Boolean createEmptyBindings)
at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList`1& validationErrors)
at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack`1& activitiesRemaining, ActivityCallStack parentChain, IList`1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
at System.Activities.Validation.ActivityValidationServices.InternalActivityValidationServices.InternalValidate()
at Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.ValidateWorkflow(Activity activity, ValidationSettings validationSettings)
at Microsoft.TeamFoundation.Build.Hosting.BuildProcessCache.LoadFromXaml(String workflowXaml, TextExpressionImports textExpressionImports)
at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager.PrepareRequestForBuild(WorkflowManagerActivity activity, IBuildDetail build, WorkflowRequest request, IDictionary`2 dataContext)
at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(WorkflowRequest request, WorkflowManagerActivity activity, BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)
The build fails in the first few seconds as this is the process that is trying to retrieve the source. However, I cannot come to any conclusions as to why this error is happening. A Google search doesn't bring up anything useful.
TFS version 2013
Has anyone encountered this error and if so how did you fix it?
If I need to provide more information please ask.
When you modify the Build process template and therefore it’s no longer in sync with the build definition you may get TF215097 error.
#jessehouwing's suspicion makes sense. I can't find too many articles to elaborate this issue, but in this MSND documentation mentions, if you want to edit a custom template, You must use only Visual Studio 2013 to edit your build process templates of TFS 2013.

Trouble with BreezeJS and Entity Framework 6

It appears that the Breeze EFContextProvider is trying to use System.Data.Objects.ObjectContext, which has apparently been moved (see EF 6 System.Data.Objects.ObjectContext Error).
Anyone know how to solve this problem?
This is the error I get returned to the browser from the Metadata action method.
{
*
$id: "1",
*
$type: "System.Web.Http.HttpError, System.Web.Http",
*
Message: "An error has occurred.",
*
ExceptionMessage: "Method not found: 'System.Data.Objects.ObjectContext System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.",
*
ExceptionType: "System.MissingMethodException",
*
StackTrace: " at Breeze.WebApi.EFContextProvider`1.GetCsdlFromDbContext(Object context) at Breeze.WebApi.EFContextProvider`1.BuildJsonMetadata() at Breeze.WebApi.ContextProvider.Metadata() at App.Spa.Controllers.BreezeController.Metadata() in ...filepath...\BreezeController.cs:line 23 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4() at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"
}
EF 6 is still in Alpha. We probably won't try to support it for Breeze until it at least makes Beta. But you have access to the source via Git, so this specific issue should be pretty easy to fix by changing the source per the post you mentioned.
this is what i tried:
download breeze-master from the github and extract it,
open the Breeze.*.sln with visual studio 2012, update EF6 (remove old EF if exists) using Nuget Manager Package,
you will see some EF namespace referred in breeze-master source were underlined as reference error, to correct them, follow the Update namespace instructions mentioned at
http://entityframework.codeplex.com/wikipage?title=Updating%20Applications%20to%20use%20EF6
rebuild the entire solution and new Breeze.WebApi.dll is created
open your project and add reference to that Breeze.WebApi.dll

MSB0001: Internal MSBuild Error: refCount should not be less than 1

Does anyone know what this means? I am getting this error in my CI build (CruiseControl.Net + NAnt + MSBuild), locally this project compiles just fine...
My.Web.csproj: Error MSB4014: The build was aborted because of an internal failure.
Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: refCount should not be less than 1.
at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Exception innerException, Object[] args)
at Microsoft.Build.Collections.CopyOnWriteDictionary\`2.CopyOnWriteBackingDictionary\`2.get_HasNoClones()
at Microsoft.Build.Collections.CopyOnWriteDictionary\`2.set_Item(K key, V value)
at Microsoft.Build.Collections.CopyOnWriteDictionary`2.System.Collections.IDictionary.set_Item(Object key, Object value)
at Microsoft.Build.BuildEngine.BuildItem..ctor(String itemName, ITaskItem taskItem)
at Microsoft.Build.BuildEngine.TaskEngine.GatherTaskItemOutputs(Lookup lookup, TaskOutput taskOutputSpecification, String itemName, String propertyName, Object outputs)
at Microsoft.Build.BuildEngine.TaskEngine.GatherGeneratedTaskOutputs(Lookup lookup, TaskOutput taskOutputSpecification, String taskParameterName, String itemName, String propertyName, ITask task)
at Microsoft.Build.BuildEngine.TaskEngine.GatherTaskOutputs(TaskExecutionMode howToExecuteTask, ITask task, ItemBucket bucket)
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteBucket(EngineProxy engineProxy, ItemBucket bucket, Int32 bucketNumber, TaskExecutionMode howToExecuteTask)
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(TaskExecutionMode howToExecuteTask, Lookup lookup)
at Microsoft.Build.BuildEngine.TaskExecutionState.TaskEngineExecuteTask(TaskEngine taskEngine, TaskExecutionMode howTaskShouldBeExecuted, Lookup lookup)
at Microsoft.Build.BuildEngine.TaskExecutionState.ExecuteTask()
at Microsoft.Build.BuildEngine.TaskExecutionModule.ExecuteTask(TaskExecutionState taskState)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.SubmitNonIntrinsicTask(XmlElement taskNode, ITaskHost hostObject, ProjectBuildState buildContext)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ExecuteCurrentTask(ProjectBuildState buildContext)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ContinueRunningTasks(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext, Boolean startingFirstTask)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ContinueBuild(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext)
at Microsoft.Build.BuildEngine.Project.ExecuteNextActionForProjectContext(ProjectBuildState buildContext, Boolean initialCall)
at Microsoft.Build.BuildEngine.Project.CalculateNextActionForProjectContext(ProjectBuildState buildContext)
at Microsoft.Build.BuildEngine.Project.ContinueBuild(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext)
at Microsoft.Build.BuildEngine.Project.BuildInternal(BuildRequest buildRequest)
at Microsoft.Build.BuildEngine.Engine.BuildProjectInternalInitial(BuildRequest buildRequest, Project project)
at Microsoft.Build.BuildEngine.Engine.BuildProjectInternal(BuildRequest buildRequest, ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext, Boolean initialCall)
at Microsoft.Build.BuildEngine.Engine.EngineBuildLoop(BuildRequest terminatingBuildRequest)
at Microsoft.Build.BuildEngine.Engine.PostProjectEvaluationRequests(Project project, String[] projectFiles, String[][] targetNames, BuildPropertyGroup[] globalPropertiesPerProject, IDictionary[] targetOutputsPerProject, BuildSettings buildFlags, String[] toolVersions)
Unexpected error while compiling project 'My.Web'
Exception has been thrown by the target of an invocation.
MSB0001: Internal MSBuild Error: refCount should not be less than 1.
I ran into the same problem in a similar environment. In my case, the project had a COM reference to the Active DS Type Library, which wasn't installed on the build server.
To fix the problem, I dropped the COM reference and added a reference to an interop assembly, which was then deployed to the build server.
Found the solution: instead of using <solution> in the build target I called msbuild directly with <exec>. Everything works now.
My problem it's similar with you, I'm have to eliminate two projects that relationship with my solution in mobil enviroment, that cause the conflict with the others projects in my solution.
My other projects are desktop, mvc, webapi enviroment.
I have to create a new solution for my others mobil projects

Categories

Resources