We just upgraded our 2sxc custom API to v14, and now we're having an issue in an API controller that's used for uploading files with converting from Base64 to a byte array. Here's the code:
public class IntegrationApiController : Custom.Hybrid.Api14
{
[HttpPost]
public string UploadPdf([FromBody] dynamic bodyJson)
{
var entity = new Dictionary<string, object>();
var guid = Guid.NewGuid();
entity.Add("EntityGuid", guid);
App.Data.Create("PDFForm", entity);
var data = Convert.FromBase64String(bodyJson.file.ToString());
var returnThing = SaveInAdam(stream: new MemoryStream(data), fileName: bodyJson.fileName.ToString(), contentType: "PDFForm", guid: guid, field: "File");
return returnThing.Url;
}
}
We're getting the following error now:
{
"Message": "2sxc Api Controller Finder Error: Error selecting / compiling an API controller. Check event-log, code and inner exception. ",
"ExceptionMessage": "c:\\Websites\\Mainstar\\Portals\\0\\2sxc\\DocusignForms\\api\\IntegrationApiController.cs(26): error CS1061: 'ToSic.Sxc.Services.IConvertService' does not contain a definition for 'FromBase64String' and no extension method 'FromBase64String' accepting a first argument of type 'ToSic.Sxc.Services.IConvertService' could be found (are you missing a using directive or an assembly reference?)",
"ExceptionType": "System.Web.HttpCompileException",
"StackTrace": " at System.Web.Compilation.AssemblyBuilder.Compile()\r\n at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()\r\n at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)\r\n at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)\r\n at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)\r\n at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)\r\n at System.Web.Compilation.BuildManager.GetCompiledAssembly(String virtualPath)\r\n at ToSic.Sxc.Dnn.WebApiRouting.AppApiControllerSelector.HttpControllerDescriptor(HttpRequestMessage request, String controllerFolder, String controllerPath, String controllerTypeName, LogCall`1 wrapLog) in C:\\Projects\\2sxc\\2sxc\\Src\\Dnn\\ToSic.Sxc.Dnn.WebApi\\Dnn\\WebApiRouting\\AppApiControllerSelector.cs:line 168\r\n at ToSic.Sxc.Dnn.WebApiRouting.AppApiControllerSelector.SelectController(HttpRequestMessage request) in C:\\Projects\\2sxc\\2sxc\\Src\\Dnn\\ToSic.Sxc.Dnn.WebApi\\Dnn\\WebApiRouting\\AppApiControllerSelector.cs:line 83"
}
Any ideas how to fix this? I did try changing "Convert.FromBase64String" to "System.Convert.FromBase64String" and that didn't solve the issue - I got a "Cannot perform runtime binding on a null reference" error instead.
Any help would be greatly appreciated!
System.Convert... sounds right. And IMHO should work.
My guess is that your bodyJson or bodyJson.file is null.
I am using Dapper to query a table that includes an XML field:
CREATE TABLE Workflow
(
Guid uniqueidentifier not null,
State xml not null
)
which is then mapped to a property of type XDocument:
public class Workflow
{
public Guid InstanceId { get;set; }
public XDocument State { get;set; }
}
but when I try to query the table, I get the following error:
Error parsing column 1 (State= - String)
at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value) in d:\\Dev\\dapper-dot-net\\Dapper NET40\\SqlMapper.cs:line 4045
at Deserialize038b29f4-d97d-4b62-b45b-786bd7d50e7a(IDataReader )
at Dapper.SqlMapper.<QueryImpl>d__11`1.MoveNext() in d:\\Dev\\dapper-dot-net\\Dapper NET40\\SqlMapper.cs:line 1572
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in d:\\Dev\\dapper-dot-net\\Dapper NET40\\SqlMapper.cs:line 1443
at MyProject.DapperBase.Query[TResult](String command, DynamicParameters parameters, IDbTransaction transaction, Boolean buffered, Int32 commandTimeout) in d:\\MyProject\\DapperBase.cs:line 122
at MyProject.WorkflowData.Get(Guid identifier) in d:\\MyProject\\WorkflowData.cs:line 41
at MyProject.WorkflowLogic.Save(Workflow workflow) in d:\\MyProject\\WorkflowLogic.cs:line 34
at MyProject.WorkflowsController.Save(Guid id, WorkflowRequest request) in d:\\MyProject\\WorkflowsController.cs:line 97
InnerException: Invalid cast from 'System.String' to 'System.Xml.Linq.XDocument'.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at Deserialize038b29f4-d97d-4b62-b45b-786bd7d50e7a(IDataReader )
Other than modifying my POCO to use a string datatype and then convert the string into an XDocument elsewhere, is there a way of getting Dapper to correctly deserialise the XML from the database?
In the end, I just brute-forced it:
public class Workflow
{
public Guid InstanceId { get;set; }
public XDocument StateIn { set { State = value.ToString(); } }
public string State { get;set; }
public XDocument StateOut { get { return XDocument.Parse(State); } }
}
Dapper plays with the State value, and I just set the value on StateIn and read it off StateOut. I feel a little bit dirty coming up with a solution like this, but hey, it works.
Perhaps creating a custom type handler can help? Something like:
public class XDocumentTypeHandler : SqlMapper.TypeHandler<XDocument>
{
public override void SetValue(IDbDataParameter parameter, XDocument value)
{
// set value in db parameter.
}
public XDocument Parse(object value)
{
// parse value from db to an XDocument.
}
}
You have to add the type handler with SqlMapper.AddTypeHandler().
See a sample implementation.
i have user control that contain grid and inside it there is expander the problem is when i try to open new window that uses this user control i get an exception " Specified element is already the logical child of another element. Disconnect it first"
here is my code and its work when first windows created
and the exception occur when show the second window
<UserControl x:Class="DiagramDesigner.WindowsUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="clr-namespace:DiagramDesigner"
xmlns:c="clr-namespace:DiagramDesigner.Controls"
mc:Ignorable="d"
d:DesignHeight="700" d:DesignWidth="1000">
<UserControl.Resources>
<ContextMenu x:Key="DesignerCanvasContextMenu">
<MenuItem Header="Paste" Command="{x:Static ApplicationCommands.Paste}">
<MenuItem.Icon>
<Image Source="Resources/Images/Paste.png" Width="16"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Select All" Command="{x:Static s:DesignerCanvas.SelectAll}"/>
</ContextMenu>
</UserControl.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!-- Toolbox -->
<StackPanel Grid.Column="0" Margin="0,0,5,0">
<Expander Header="Flow Chart" Content="{StaticResource FlowChartStencils}" IsExpanded="True" />
</StackPanel>
<!-- GridSplitter -->
<GridSplitter Focusable="False" Width="2" Background="LightGray"
VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
<!-- Designer -->
<GroupBox Header="Diagram" Grid.Column="1" Margin="3,0,0,0">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<s:DesignerCanvas Focusable="true" x:Name="MyDesigner"
Background="{StaticResource WindowBackgroundBrush}"
Margin="10" FocusVisualStyle="{x:Null}"
ContextMenu="{StaticResource DesignerCanvasContextMenu}"/>
</ScrollViewer>
</GroupBox>
</Grid>
</Grid>
</UserControl>
You cannot reuse the same UIElement instance for different parts of the UI. Either remove it from the first and add it to the second one (not recommended but there are some advanced scenarios were it makes sense) or simply create a new one. It's pretty cheap.
I had this error, and I managed to work out exactly why it was occurring using trial and error.
The problem? I was using the following line of XAML in both context menus for a master/detail grid, using the DXGrid from DevExpress.
<dxb:BarItemLinkSeparator />
Once I the issue was fixed, I noticed that the stack trace did actually give a small clue as to which XAML element was causing the error. The 4th line in the stack trace ends with this:
[snip]ILinksHolder.OnLinkAdded(BarItemLinkBase link)
BarItemLinkBase is the base class for BarItemLinkSeparator, which is our clue that removing said XAML will fix the error.
For context, here is the full stack trace:
System.InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.
at System.Windows.FrameworkContentElement.ChangeLogicalParent(DependencyObject newParent)
at System.Windows.FrameworkElement.AddLogicalChild(Object child)
at DevExpress.Xpf.Bars.PopupMenu.DevExpress.Xpf.Bars.ILinksHolder.OnLinkAdded(BarItemLinkBase link)
at DevExpress.Xpf.Bars.BarItemLinkCollection.UpdateItemLinkOnAddToCollection(BarItemLinkBase itemLink)
at DevExpress.Xpf.Bars.BarItemLinkCollection.InsertItem(Int32 index, BarItemLinkBase itemLink)
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.CustomizablePopupMenuItemLinkCollection.InsertItem(Int32 index, BarItemLinkBase itemLink)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at DevExpress.Xpf.Bars.BarItemLinkBase.DevExpress.Xpf.Bars.IBarManagerControllerAction.Execute()
at DevExpress.Xpf.Bars.BarManagerActionCollection.Execute()
at DevExpress.Xpf.Bars.BarManagerActionContainer.Execute()
at DevExpress.Xpf.Bars.BarManagerController.Execute()
at DevExpress.Xpf.Bars.BarManagerMenuController.Execute()
at DevExpress.Xpf.Grid.DataControlPopupMenu.ExecuteOriginationViewMenuController(Func`2 getMenuController)
at DevExpress.Xpf.Grid.GridCellMenuInfo.ExecuteMenuController()
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.CreateItems()
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.RaiseOpening()
at DevExpress.Xpf.Bars.BarPopupBase.OnIsOpenCoerce(Object value)
at DevExpress.Xpf.Bars.PopupMenuBase.OnIsOpenCoerce(Object value)
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.OnIsOpenCoerce(Object value)
at DevExpress.Xpf.Bars.BarPopupBase.OnIsOpenCoerce(DependencyObject d, Object value)
at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Controls.Primitives.Popup.set_IsOpen(Boolean value)
at DevExpress.Xpf.Bars.ContextMenuManager.ShowElementContextMenu(Object contextElement, Boolean openingFromKeyboard)
at DevExpress.Xpf.Bars.ContextMenuManager.OpenContextMenu(Object sender, Boolean openingFromKeyboard)
at DevExpress.Xpf.Bars.ContextMenuManager.OnContextMenuOpening(Object sender, ContextMenuEventArgs e)
at System.Windows.Controls.ContextMenuEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Controls.PopupControlService.RaiseContextMenuOpeningEvent(IInputElement source, Double x, Double y, Boolean userInitiated)
at System.Windows.Controls.PopupControlService.ProcessMouseUp(Object sender, MouseButtonEventArgs e)
at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e)
at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
System.InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.
at System.Windows.FrameworkContentElement.ChangeLogicalParent(DependencyObject newParent)
at System.Windows.FrameworkElement.AddLogicalChild(Object child)
at DevExpress.Xpf.Bars.PopupMenu.DevExpress.Xpf.Bars.ILinksHolder.OnLinkAdded(BarItemLinkBase link)
at DevExpress.Xpf.Bars.BarItemLinkCollection.UpdateItemLinkOnAddToCollection(BarItemLinkBase itemLink)
at DevExpress.Xpf.Bars.BarItemLinkCollection.InsertItem(Int32 index, BarItemLinkBase itemLink)
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.CustomizablePopupMenuItemLinkCollection.InsertItem(Int32 index, BarItemLinkBase itemLink)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at DevExpress.Xpf.Bars.BarItemLinkBase.DevExpress.Xpf.Bars.IBarManagerControllerAction.Execute()
at DevExpress.Xpf.Bars.BarManagerActionCollection.Execute()
at DevExpress.Xpf.Bars.BarManagerActionContainer.Execute()
at DevExpress.Xpf.Bars.BarManagerController.Execute()
at DevExpress.Xpf.Bars.BarManagerMenuController.Execute()
at DevExpress.Xpf.Grid.DataControlPopupMenu.ExecuteOriginationViewMenuController(Func`2 getMenuController)
at DevExpress.Xpf.Grid.GridCellMenuInfo.ExecuteMenuController()
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.CreateItems()
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.RaiseOpening()
at DevExpress.Xpf.Bars.BarPopupBase.OnIsOpenCoerce(Object value)
at DevExpress.Xpf.Bars.PopupMenuBase.OnIsOpenCoerce(Object value)
at DevExpress.Xpf.Bars.CustomizablePopupMenuBase.OnIsOpenCoerce(Object value)
at DevExpress.Xpf.Bars.BarPopupBase.OnIsOpenCoerce(DependencyObject d, Object value)
at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Controls.Primitives.Popup.set_IsOpen(Boolean value)
at DevExpress.Xpf.Bars.ContextMenuManager.ShowElementContextMenu(Object contextElement, Boolean openingFromKeyboard)
at DevExpress.Xpf.Bars.ContextMenuManager.OpenContextMenu(Object sender, Boolean openingFromKeyboard)
at DevExpress.Xpf.Bars.ContextMenuManager.OnContextMenuOpening(Object sender, ContextMenuEventArgs e)
at System.Windows.Controls.ContextMenuEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Controls.PopupControlService.RaiseContextMenuOpeningEvent(IInputElement source, Double x, Double y, Boolean userInitiated)
at System.Windows.Controls.PopupControlService.ProcessMouseUp(Object sender, MouseButtonEventArgs e)
at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e)
at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
I'm writing a Windows Forms application which needs to store some NHibernate's entities data in a persistent 2nd layer cache. As far as I know, the only 2nd level cache provider which satisfies my app's requirements is Prevalence, but I'm getting an awkward exception when I configure it:
System.ArgumentNullException was unhandled
Message=Value cannot be null.
Parameter name: key
Source=mscorlib
ParamName=key
StackTrace:
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at NHibernate.Impl.SessionFactoryObjectFactory.GetNamedInstance(String name)
at NHibernate.Impl.SessionFactoryImpl.GetRealObject(StreamingContext context)
at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at Bamboo.Prevalence.Implementation.PendingCommandsEnumerator.NextCommand()
at Bamboo.Prevalence.Implementation.PendingCommandsEnumerator.MoveNext()
at Bamboo.Prevalence.PrevalenceEngine.RecoverCommands(CommandLogReader reader, ExceptionDuringRecoveryHandler handler)
at Bamboo.Prevalence.PrevalenceEngine.RecoverSystem(Type systemType, CommandLogReader reader, ExceptionDuringRecoveryHandler handler)
at Bamboo.Prevalence.PrevalenceEngine..ctor(Type systemType, String prevalenceBase, BinaryFormatter formatter, ExceptionDuringRecoveryHandler handler)
at Bamboo.Prevalence.TransparentPrevalenceEngine..ctor(Type systemType, String prevalenceBase, BinaryFormatter formatter, ExceptionDuringRecoveryHandler handler)
at Bamboo.Prevalence.TransparentPrevalenceEngine..ctor(Type systemType, String prevalenceBase, BinaryFormatter formatter)
at Bamboo.Prevalence.PrevalenceActivator.CreateTransparentEngine(Type systemType, String prevalenceBase, BinaryFormatter formatter)
at Bamboo.Prevalence.PrevalenceActivator.CreateTransparentEngine(Type systemType, String prevalenceBase)
at NHibernate.Caches.Prevalence.PrevalenceCacheProvider.SetupEngine()
at NHibernate.Caches.Prevalence.PrevalenceCacheProvider.Start(IDictionary`2 properties)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at AcessoDados.DB.Configure() in C:\Users\Herberth\MyProject\DataAccess\DB.cs:line 78
This is only extra code I'm using:
configuration.SessionFactory().Caching.Through<NHibernate.Caches.Prevalence.PrevalenceCacheProvider>().PrefixingRegionsWith("MyRegion").WithDefaultExpiration(60);
It works fine when I comment out this line (without the cache, of course);
Here's the complete code I'm using:
configuration = new Configuration();
var mapper = new ModelMapper();
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
HbmMapping domainMapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
configuration.DataBaseIntegration(c =>
{
c.Dialect<MySQLDialect>();
c.ConnectionString = #"Server=localhost;Database=mydb;Uid=root;Pwd=mypwd";
c.ConnectionString = DBConnectionStrings.Principal;
c.LogFormattedSql = true;
c.LogSqlInConsole = true;
c.IsolationLevel = System.Data.IsolationLevel.ReadCommitted;
});
configuration.AddMapping(domainMapping);
configuration.Cache(c => { c.UseQueryCache = true; });
configuration.SessionFactory().Caching.Through<NHibernate.Caches.Prevalence.PrevalenceCacheProvider>().PrefixingRegionsWith("MyRegion").WithDefaultExpiration(60);
SessionFactory = configuration.BuildSessionFactory();
All dependencies are in their latest version.
Thanks in advance!
I had this issue because the directories NHibernate.Cache.StandardQueryCache and UpdateTimestampsCache in the executable directory got out of date.
However, that lead to the next issue -- I couldn't install under Program Files because NHibernate attempted to create these directories on first run.
What is the order in which attached properties are applied to an object ? I guess I should ignore this, but here my scenario:
I've got an attached property to stick the VM to the View, and then, another attached property that depend on the first one. I'm trying to see what happen if the second is set up before the first, but I can't manage to get the error! ie the first ( the model ) is always set up before the second, whatever is the order in xaml. Who is driving the order of assigment? Can I change it?
Now I'm dealing with the late assigmement by subscribing the proeprty change event:
DependencyPropertyDescriptor dd = DependencyPropertyDescriptor.FromProperty(FrameworkElement.DataContextProperty,depo.GetType());
dd.AddValueChanged(depo, (s, a) =>
{
ChangeDatacontext(s as DependencyObject);
}
and for simulate the problem I setup manually a new datacontext to the object.
Thanks,
Felix
I can't directly answer this question, because I never rely on which property is set before the other, but you can manage things with a method that both attached properties use.
here is an example from my current code:
public static readonly DependencyProperty RuleVMProperty =
DependencyProperty.RegisterAttached("RuleVM", typeof(DocumentRuleViewModel), typeof(DocumentRuleViewModel), new UIPropertyMetadata(null, RuleVMChanged));
public static void RuleVMChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
var el = GetRefid(sender);
var vm = args.NewValue as DocumentRuleViewModel;
if(vm==null)
return;
vm.SetDocumentFromRefid(sender, el);
}
public static readonly DependencyProperty RefidProperty =
DependencyProperty.RegisterAttached("Refid", typeof(XmlElement), typeof(DocumentRuleViewModel), new UIPropertyMetadata(RefidChanged));
public static void RefidChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
var el = args.NewValue as XmlElement;
var vm = GetRuleVM(sender);
if (vm == null)
return;
vm.SetDocumentFromRefid(sender, el);
}
private void SetDocumentFromRefid(DependencyObject sender, XmlElement element)
{
... // this is where the actual logic sits
}
so essentially you have two changed handlers and whichever triggers last executes the logic because it sees if the other property is null.