Exception on Fetch/Clone/Pull with custom transport - libgit2sharp

I wrote a custom smarttransport. After fetch, pull or clone I get valid data but the method throws LibGit2Sharp Exception with "error reading from the zlib stream".
Transport with upload-pack read->write->read->write works.
READ:
00fc5daa747d4ca7905ff8996f770ef74d1b894be3d2 HEAD multi_ack thin-pack
side-band side-band-64k ofs-delta shallow deepen-since deepen-not
deepen-relative no-progress include-tag multi_ack_detailed
symref=HEAD:refs/heads/master agent=git/2.18.0.windows.1
003f5daa747d4ca7905ff8996f770ef74d1b894be3d2 refs/heads/master
003e5daa747d4ca7905ff8996f770ef74d1b894be3d2 refs/heads/test2 0000
WRITE:
0074want 5daa747d4ca7905ff8996f770ef74d1b894be3d2
multi_ack_detailed side-band-64k include-tag thin-pack ofs-delta
0032want 5daa747d4ca7905ff8996f770ef74d1b894be3d2 00000009done
READ:
0008NAK 0023Enumerating objects: 9, done. Counting objects: 100%
(9/9), done. Compressing objects: 100% (6/6), done. 002bTotal 9
(delta 0), reused 0 (delta 0) 02e7PACK òx£ì-1-0
+=»+ÄälºNc !6Ìß$NAé+­x-m763[AÁ+sª$C+!7eì[å$í¦Àn÷^A&ã:Cÿ+-T#&Ö+BfàªäëKê+Úg_·µ»}+²i¨yi·¦Ò+ï«gÅÉä+Ç
\Ú¤þ}¹©]ks_.k8¬òx£ì-=-0#ß=º+ÄäþºÄäþpº
ZéZszûÀ}z¦ëÏ\KpêÈUqòÉk+=-Ç U8O
àú¨­&oÁëÿ=óª=d+AÊ4qóÏÇ:+ã-áß»>ãf´cÌÝe>zٳƾ2*/WÙó?«ô-hOÇ
ªÄu}¬- -¿ýj~Ç#9[ÿ
x£ì-1-0#Ð=º­ÄäLLöTBê¡þpmÀDñDj-²¦#¦³7}¯¦#°nël8eÔR-ª¿ëSûY'UM%IÓƒ+¹c_vx,g_3ý+¦p{--ûé4d©DÊÎÁ¦¦ G¿¯Ûò[8
Ë-õ¿x£343
¢Éd¸¦åîUFzÜ--£+²Ê½2.Þr³ê]ÙdhfbóPöÜÿÆø¬WRQ-ã»Ã¤J¦_Ðß¾ØKMº¥à
3Sã¦x£-¦-,+L¦QH+¤--,I,NIa.-à-3©îí+ §Ó-¿x£343
¢Éd¸¦åîUFzÜ--£+²Ê½2.Þr³ê]ÙdhfbóPöÜÿÆø¬WRQ-­=âìBnï§+=ƒ º=¦|[c
N+ô¦x£-¦-,+L¦QH+¤--,I,NIa.-ò
+®*ªx£340031Q(JML+Mi+®(a+§u¦sQ?-§î¦O´¢¹¦,²Û+. H>x£-¦-,+L¦QH+¤--, )-öP¸ãyô
WRITE:
0000
Exception:
An unhandled exception of type 'LibGit2Sharp.LibGit2SharpException'
occurred in LibGit2Sharp.dll
Additional information: error reading from the zlib stream
Callstack:
bei LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in
C:\projects\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:Zeile 136. bei
LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote,
IEnumerable1 refSpecs, GitFetchOptions fetchOptions, String
logMessage) in
C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:Zeile 2268. bei
LibGit2Sharp.Commands.Fetch(Repository repository, String remote,
IEnumerable1 refspecs, FetchOptions options, String logMessage) in
C:\projects\libgit2sharp\LibGit2Sharp\Commands\Fetch.cs:Zeile 76.
bei GitFunction.Test.Beta2.button1_Click(Object sender, EventArgs e)
in
C:\TFS\DS\ThomasZ\BeckhoffGitAdsService\GitAdsServicePackage\GitFunction.Test\Beta2.cs:Zeile
62. bei System.Windows.Forms.Control.OnClick(EventArgs e) bei System.Windows.Forms.Button.OnClick(EventArgs e) bei
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) bei
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks) bei
System.Windows.Forms.Control.WndProc(Message& m) bei
System.Windows.Forms.ButtonBase.WndProc(Message& m) bei
System.Windows.Forms.Button.WndProc(Message& m) bei
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData) bei
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) bei
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context) bei
System.Windows.Forms.Application.Run(Form mainForm) bei
GitFunction.Test.Program.Main() in
C:\TFS\DS\ThomasZ\BeckhoffGitAdsService\GitAdsServicePackage\GitFunction.Test\Program.cs:Zeile
19. bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) bei
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args) bei
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) bei
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) bei
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state) bei
System.Threading.ThreadHelper.ThreadStart()
Versions:
git version 2.18.0.windows.1
Win 10 x64
LibGit2Sharp 0.24.0.0
LibGit2Sharp 0.25.0.0

FYI:
UTF8Encoding and Encoding.Utf8 are not equal. Encoding.Utf8 adds UTF8 BOM (Byte-order Mark). This leads to this error. Setting all encodings to UTF8Encoding in my code fixed my problem.

Related

odata.track-changes leads to error 500 'Window end time must be greater than start time'

I would like to use the Outlook REST API to read calendar items from an Exchange Server 2019 CU2.
But as soon as I'm adding the
Prefer: odata.track-changes HTML-Header for getting a deltaToken, the server answers:
Error 500
{"error":{"code":"ErrorInternalServerError","message":"Window end time must be greater than start time REST APIs for this mailbox are currently in preview. You can find more information about the preview REST APIs at https://dev.outlook.com/."}}
I can reproduce the error with this code snippet under any account on this exchange server instance.
$url = "https://myexchangeserver/api/v2.0/me/calendarview?startDateTime=2004-08-21T22:00:00Z&endDateTime=2034-08-21T21:59:59Z&$expand=singleValueExtendedProperties($filter%3DPropertyId%20eq%20%27Binary%200x0FFF%27)"
$output = "C:\temp\1.json"
$wc = New-Object System.Net.WebClient
$wc.Credentials = new-object System.Net.NetworkCredential("myusername", "mypassword", "mydomain")
$wc.Headers.Clear();
$wc.Headers.Add("Prefer: odata.track-changes")
$wc.DownloadFile($url, $output)
I checked the startDateTime and endDateTime many times, but the start is smaller than the end.
I have searched the Exchange Server logs and found this error stack:
DispatchException=System.ArgumentException: Window end time must be greater than start time
bei Microsoft.Exchange.Data.ApplicationLogic.SyncCalendar.SyncCalendar..ctor(CalendarSyncState syncState IStoreSession session StoreObjectId folderId GetPropertiesToFetchDelegate getPropertiesToFetchDelegate ExDateTime windowStart ExDateTime windowEnd Boolean includeAdditionalDataInResponse Int32 maxChangesReturned Boolean adjustStartAndEndForAllDayEvents)
bei Microsoft.Exchange.Services.Wcf.SyncCalendar.InternalExecute()
bei Microsoft.Exchange.Services.Wcf.ServiceCommand`1.DetectDuplicatedCallOrExecute()
bei Microsoft.Exchange.Services.Wcf.ServiceCommand`1.Execute()
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceBase.<>c__DisplayClass338_0`1.<InvokeOwsServiceCommand>b__0()
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceBase.CallWithExceptionHandling(ExecutionOption executionOption Action action)
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceBase.InvokeOwsServiceCommand[TResponse](Func`1 commandCreator ExecutionOption executionOption Boolean throwOnNullResponse)
bei Microsoft.Exchange.Diagnostics.RequestDetailsLoggerBase`1.TrackLatency[TResult](Enum latencyMetadata Func`1 method)
bei Microsoft.Exchange.Services.OData.Model.CalendarViewSyncCommand`1.<>c__DisplayClass5_0.<SyncCalendar>b__1()
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceHelper.HandleResponseCode(ResponseCodeType responseCodeType Action delegateAction Action`1 handlerAction)
bei Microsoft.Exchange.Services.OData.Model.CalendarViewSyncCommand`1.SyncCalendar(IExchangeService exchangeService PagingTokenFlags flags String& skipToken String& deltaToken)
bei Microsoft.Exchange.Services.OData.Model.CalendarViewTrackChangesCommand.InternalExecute(IExchangeService exchangeService)
bei Microsoft.Exchange.Services.OData.ExchangeServiceCommand`2.InternalExecute()
bei Microsoft.Exchange.Services.OData.ODataCommand`2.<Execute>b__9_0()
bei Microsoft.Exchange.Diagnostics.RequestDetailsLoggerBase`1.TrackLatency[TResult](Enum latencyMetadata Func`1 method)
bei Microsoft.Exchange.Services.OData.EntityContainersCommand`2.Execute()
bei Microsoft.Exchange.Services.OData.Web.RequestBroker.<>c__DisplayClass2_0.<Execute>b__0()
bei Microsoft.Exchange.Services.Diagnostics.ServicesPerformanceTracker.RunOperationWithTrackingADAndRpcPerformance(Action method Enum adCount Enum adLatency Enum rpcCount Enum rpcLatency)
bei Microsoft.Exchange.Services.OData.Web.RequestBroker.Execute(ODataRequest request)
bei Microsoft.Exchange.Services.OData.Web.RequestBroker.Dispatch(HttpContextBase httpContext AsyncCallback asyncCallback CheckpointTracker checkpointTracker ServiceModel serviceModel IComponentConfiguration`1 configuration);ServiceDiagnostics_ReportException=System.ArgumentException: Window end time must be greater than start time
bei Microsoft.Exchange.Data.ApplicationLogic.SyncCalendar.SyncCalendar..ctor(CalendarSyncState syncState IStoreSession session StoreObjectId folderId GetPropertiesToFetchDelegate getPropertiesToFetchDelegate ExDateTime windowStart ExDateTime windowEnd Boolean includeAdditionalDataInResponse Int32 maxChangesReturned Boolean adjustStartAndEndForAllDayEvents)
bei Microsoft.Exchange.Services.Wcf.SyncCalendar.InternalExecute()
bei Microsoft.Exchange.Services.Wcf.ServiceCommand`1.DetectDuplicatedCallOrExecute()
bei Microsoft.Exchange.Services.Wcf.ServiceCommand`1.Execute()
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceBase.<>c__DisplayClass338_0`1.<InvokeOwsServiceCommand>b__0()
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceBase.CallWithExceptionHandling(ExecutionOption executionOption Action action)
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceBase.InvokeOwsServiceCommand[TResponse](Func`1 commandCreator ExecutionOption executionOption Boolean throwOnNullResponse)
bei Microsoft.Exchange.Diagnostics.RequestDetailsLoggerBase`1.TrackLatency[TResult](Enum latencyMetadata Func`1 method)
bei Microsoft.Exchange.Services.OData.Model.CalendarViewSyncCommand`1.<>c__DisplayClass5_0.<SyncCalendar>b__1()
bei Microsoft.Exchange.Services.ExchangeService.ExchangeServiceHelper.HandleResponseCode(ResponseCodeType responseCodeType Action delegateAction Action`1 handlerAction)
bei Microsoft.Exchange.Services.OData.Model.CalendarViewSyncCommand`1.SyncCalendar(IExchangeService exchangeService PagingTokenFlags flags String& skipToken String& deltaToken)
bei Microsoft.Exchange.Services.OData.Model.CalendarViewTrackChangesCommand.InternalExecute(IExchangeService exchangeService)
bei Microsoft.Exchange.Services.OData.ExchangeServiceCommand`2.InternalExecute()
bei Microsoft.Exchange.Services.OData.ODataCommand`2.<Execute>b__9_0()
bei Microsoft.Exchange.Diagnostics.RequestDetailsLoggerBase`1.TrackLatency[TResult](Enum latencyMetadata Func`1 method)
bei Microsoft.Exchange.Services.OData.EntityContainersCommand`2.Execute()
bei Microsoft.Exchange.Services.OData.Web.RequestBroker.<>c__DisplayClass2_0.<Execute>b__0()
bei Microsoft.Exchange.Services.Diagnostics.ServicesPerformanceTracker.RunOperationWithTrackingADAndRpcPerformance(Action method Enum adCount Enum adLatency Enum rpcCount Enum rpcLatency)
bei Microsoft.Exchange.Services.OData.Web.RequestBroker.Execute(ODataRequest request)
bei Microsoft.Exchange.Services.OData.Web.RequestBroker.Dispatch(HttpContextBase httpContext AsyncCallback asyncCallback CheckpointTracker checkpointTracker ServiceModel serviceModel IComponentConfiguration`1 configuration);
How can I get rid of this error 500?

Catel UIVisualizerService issue with Syncfusion sfDatagrid

I have created a project that makes use of Catel, Entity Framework 6 and Syncfusion Community Edition. Specifically I am using the sfDataGrid from Syncfusion.
I have come across an issue that has me completely stumped, maybe someone out there could point me in the right direction.
I have a Catel UserControl with a sfDataGrid in it. The ViewModel has an ObservableCollection (Catel Property) of the data I am using as the ItemsSource for the sfDataGrid. I have filtering enabled on the sfDataGrid. Here is the code for the sfDataGrid:
<sync:SfDataGrid
x:Name="ItemsDataGrid"
ItemsSource="{Binding MyItems, Mode=OneWay}"
SelectedItem="{Binding MyItem, Mode=TwoWay}"
AutoGenerateColumns="False"
AllowFiltering="True"
AllowResizingColumns="True"
GridCopyOption="IncludeHeaders"
GridPasteOption="None"
ShowGroupDropArea="True"
ShowRowHeader="True"
DataFetchSize="50">
<!-- Columns -->
</sync:SfDataGrid>
I add a new Item to the collection on a different view and then I save it to the datacontext and refresh the list:
private async void OnNewMyItemExecute()
{
MyItem= new MyItem();
MyItemsRepository.Add(MyItem);
var myItemsViewModel = TypeFactory
.Default
.CreateInstanceWithParametersAndAutoCompletion<myItemsViewModel >(MyItem); //the construction has parameters for IUIVisualizerService, IPleaseWaitService, etc.
if (await _UIVisualizerService.ShowDialogAsync(myItemsViewModel) ?? true)
{
var myItem= myItemsViewModel.MyItem;
await InitializeAsync();
MyItem = myItem;
}
else
{
_UnitOfWorkService.Rollback(); //just undo some changes
MyItem = null;
}
UnitOfWork.SaveChanges();
}
Creating a new Item is not a problem at all, the thing that is weird is that after I created a new Item and then attempt to filter grid on any column of the sfDataGrid (click the filter button in the column header, a filter popup opens, enter a value in the criteria textbox and click 'OK'), I get this:
MyProject.vshost.exe Warning: 0 : 17:57:49:075 => [WARNING]
[Catel.Services.UIVisualizerService] [8] An error occurred, returning
null since we don't know the result | [TargetInvocationException]
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.InvalidCastException:
Unable to cast object of type 'MyProject.Domain.MyItem' to type
'System.Data.Entity.DynamicProxies.MyItem_4CA6F59AB53174892ED9EFBC1D3CC07B862579FC3C5733C6CF4DE857907CFF9C'.
at lambda_method(Closure , MyItem ) --- End of inner exception
stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object
target, Object[] arguments, Signature sig, Boolean constructor) at
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments) at
System.Delegate.DynamicInvokeImpl(Object[] args) at
System.Delegate.DynamicInvoke(Object[] args) at
Syncfusion.Data.QueryableCollectionView.<>c__DisplayClass3.b__1(Object
o) at Syncfusion.Data.QueryableCollectionView.FilterRecord(Object
record) at
Syncfusion.Data.EnumerableRecordsWrapper..ctor(IEnumerable source,
CollectionViewAdv view) at
Syncfusion.Data.EnumerableRecordsWrapper.CreateNew(IEnumerable source,
CollectionViewAdv view) at
Syncfusion.Data.QueryableCollectionView.CreateRecords() at
Syncfusion.Data.CollectionViewAdv.EnsureInitialized() at
Syncfusion.Data.CollectionViewAdv.get_Records() at
Syncfusion.Data.CollectionViewAdv.EnsureRecordsInitialized() at
Syncfusion.Data.CollectionViewAdv.Refresh() at
Syncfusion.Data.QueryableCollectionView.RefreshFilter() at
Syncfusion.Data.CollectionViewAdv.ApplyFilters() at
Syncfusion.Data.CollectionViewAdv.set_FilterPredicates(ObservableCollection1
value) at Syncfusion.UI.Xaml.Grid.GridModel.FilterColumn(GridColumn
column, List1 filterPredicates) at
Syncfusion.UI.Xaml.Grid.GridFilterControl.RefreshFilter() at
Syncfusion.UI.Xaml.Grid.GridFilterControl.b__10(Object
s, RunWorkerCompletedEventArgs e) at
System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs
e) at
System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object
arg) at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Int32 numArgs) at
System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,
Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl() at
System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object
state) at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state) at
System.Windows.Threading.DispatcherOperation.Invoke() at
System.Windows.Threading.Dispatcher.ProcessQueue() at
System.Windows.Threading.Dispatcher.WndProcHook(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
System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,
Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at
System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Int32
numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam) at
MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at
System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame
frame) at
System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Window.ShowHelper(Object booleanBox) at
System.Windows.Window.Show() at System.Windows.Window.ShowDialog()
--- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor) at
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters) at
Catel.Services.UIVisualizerService.<>c__DisplayClass23_0.b__0()
in
C:\CI_WS\Ws\86058\Source\Catel\src\Catel.MVVM\Catel.MVVM.Shared\Services\UIVisualizerService.cs:line
499
This is the method of UIVisualizerService with Line 499:
protected virtual bool? ShowWindow(FrameworkElement window, bool showModal)
{
if (showModal)
{
var showDialogMethodInfo = window.GetType().GetMethodEx("ShowDialog");
if (showDialogMethodInfo != null)
{
// Child window does not have a ShowDialog, so not null is allowed
bool? result = null;
window.Dispatcher.InvokeIfRequired(() =>
{
// Safety net to prevent crashes when this is the main window
try
{
result = showDialogMethodInfo.Invoke(window, null) as bool?; //Line 499
}
catch (Exception ex)
{
Log.Warning(ex, "An error occurred, returning null since we don't know the result");
}
});
return result;
}
Log.Warning("Method 'ShowDialog' not found on '{0}', falling back to 'Show'", window.GetType().Name);
}
I have tried opening MyItemsView with .ShowAsync(), .ShowDialogAsync() and before I upgraded to Catel 4.4 I also used .ShowDialog(), but it made no difference. I could turn Proxy Creation off in EF, but that would cause a lot of changes I have to make in my project (no more lazy loading for me, and that is not an option). I do believe the problem being the new Item I add not being a Dynamic Proxy, and getting it to be a Dynamic Proxy would probably solve the issue, but I have tried loading all the data from the DbContext again, but it also does not solve the problem.
Any advice would be appreciated.
The issue is this:
System.InvalidCastException: Unable to cast object of type 'MyProject.Domain.MyItem' to type 'System.Data.Entity.DynamicProxies.MyItem_4CA6F59AB53174892ED9EFBC1D3CC07B862579FC3C5733C6CF4DE857907CFF9C'.
The reason is, of course, that you are trying to cast a base type to a derived type (which it simply isn't). That this eventually results in the window closing is because an exception happens, but that isn't the real problem.
This exception occurs in the FilterRecord method of the grid. I am not sure if that is something you have written yourself or something that is inside syncfusion, but that is the place to look.
The reason you have generated proxies is because you enabled (or it's enabled by default) the proxy generation of the Entity Framework DbContext.

automapper error collection was modified when multiple users are creating a user

I am receiving following error and this error only comes up when multiple users are hitting the same button. Any help/ideas will be really appreciated:
System.InvalidOperationException: Collection was modified; enumeration
operation may not execute. Generated: Wed, 10 Jun 2015 07:29:06 GMT
AutoMapper.AutoMapperMappingException:
Mapping types: User -> User ApplicationSecurityManager.Service.User ->
ApplicationSecurityManager.Models.User
Destination path: User
Source value: ApplicationSecurityManager.Service.User --->
System.InvalidOperationException: Collection was modified; enumeration
operation may not execute. at
System.Collections.Generic.List1.Enumerator.MoveNextRare() at
AutoMapper.TypeMap.<get_AfterMap>b__1(Object src, Object dest) at
AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.Map(ResolutionContext
context, IMappingEngineRunner mapper) at
AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext context,
IMappingEngineRunner mapper) at
AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext
context) --- End of inner exception stack trace --- at
AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext
context) at AutoMapper.MappingEngine.Map[TDestination](Object
source, Action1 opts) at
ApplicationSecurityManager.UserManager.LoadUser(String username) at
ApplicationSecurityManager.UserManager.get_AuthenticatedUser() at
ApplicationSecurityManager.UserManager.IsAuthenticated() at
ApplicationSecurityManager.Infrastructure.ApplicationSecurityAttribute.OnAuthorization(AuthorizationContext
filterContext) at
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext
controllerContext, IList1 filters, ActionDescriptor actionDescriptor)
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__1e(AsyncCallback
asyncCallback, Object asyncState) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.Begin(AsyncCallback
callback, Object state, Int32 timeout) at
System.Web.Mvc.Async.AsyncResultWrapper.Begin[TResult](AsyncCallback
callback, Object state, BeginInvokeDelegate beginDelegate,
EndInvokeDelegate1 endDelegate, Object tag, Int32 timeout) at
System.Web.Mvc.Async.AsyncResultWrapper.Begin[TResult](AsyncCallback
callback, Object state, BeginInvokeDelegate beginDelegate,
EndInvokeDelegate1 endDelegate, Object tag) at
System.Web.Mvc.Controller.<>c__DisplayClass1d.b__17(AsyncCallback
asyncCallback, Object asyncState) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.Begin(AsyncCallback
callback, Object state, Int32 timeout) at
System.Web.Mvc.Async.AsyncResultWrapper.Begin[TResult](AsyncCallback
callback, Object state, BeginInvokeDelegate beginDelegate,
EndInvokeDelegate1 endDelegate, Object tag, Int32 timeout) at
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback,
Object state) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.Begin(AsyncCallback
callback, Object state, Int32 timeout) at
System.Web.Mvc.Async.AsyncResultWrapper.Begin[TResult](AsyncCallback
callback, Object state, BeginInvokeDelegate beginDelegate,
EndInvokeDelegate1 endDelegate, Object tag, Int32 timeout) at
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback,
Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate
endDelegate, Object tag) at
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext,
AsyncCallback callback, Object state) at
System.Web.Mvc.MvcHandler.<>c__DisplayClass8.b__2(AsyncCallback
asyncCallback, Object asyncState) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.Begin(AsyncCallback
callback, Object state, Int32 timeout) at
System.Web.Mvc.Async.AsyncResultWrapper.Begin[TResult](AsyncCallback
callback, Object state, BeginInvokeDelegate beginDelegate,
EndInvokeDelegate1 endDelegate, Object tag, Int32 timeout) at
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback,
Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate
endDelegate, Object tag) at
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase
httpContext, AsyncCallback callback, Object state) at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
This is the constructor where i think the aftermap is the problem but when debugging i don't receive the error.
Public Sub New(environmentCode As String, applicationCode As String)
MyBase.New(environmentCode, applicationCode)
SOBaseUrl = System.Configuration.ConfigurationManager.AppSettings(Enums.AppSettingKeys.SOBaseUrl.ToString())
If Not String.IsNullOrEmpty(SOBaseUrl) Then
SOBaseUrl = SOBaseUrl.TrimEnd("/")
End If
'Setup mapping.
Mapper.CreateMap(Of Service.User, Models.User)() _
.ForMember(Function(dest As Models.User) dest.ENumber, Sub(opt) opt.MapFrom(Function(src As Service.User) src.INumber)) _
.AfterMap(Sub(src As Service.User, dest As Models.User)
dest.Groups = New List(Of String)
Using service = ApplicationSecurityManager.Service.Factory.GetService()
Dim applicationPermissions = service.LoadPermissionsForUser(dest.Username, MyBase.EnvironmentCode)
If (Not applicationPermissions Is Nothing AndAlso applicationPermissions.Any(Function(x) x.Code = MyBase.ApplicationCode)) Then
dest.Groups = applicationPermissions.Single(Function(x) x.Code = MyBase.ApplicationCode).GroupNames.ToList()
End If
End Using
End Sub)
Depenendency Injection Mapping:
container.RegisterType(Of IUserManager, UserManager)(New PerThreadLifetimeManager(),
New InjectionConstructor(
ConfigurationManager.AppSettings(Common.Enums.AppSettingKeys.Environment.ToString()),
ConfigurationManager.AppSettings(Common.Enums.AppSettingKeys.ApplicationCode.ToString()))
)
In the saveUserResponse, the error is getting thrown.
Public Function Create(user As Common.Models.User, approve As Boolean) As SO.Common.Models.User Implements IUserProvider.Save
Dim saveUserResponse = UserManager.SaveUser(Mapper.Map(Of ApplicationSecurityManager.Service.User)(user))
If Not String.IsNullOrEmpty(saveUserResponse.ErrorMessage) Then
'The Security system returned an error.
Throw New Exception("Security Service returned error: " & saveUserResponse.ErrorMessage)
End If
'Return the username.
Return Mapper.Map(Of Common.Models.User)(saveUserResponse.User)
End Function
This is caused when multiple users modify the same user.Groups collection in the AfterMap() method of your mapping. To avoid this, lock the code that is processing the collection. For example:
'class level object
private object _myLock = New object()
'Setup mapping.
Mapper.CreateMap(Of Service.User, Models.User)() _
.ForMember(Function(dest As Models.User) dest.ENumber, Sub(opt) opt.MapFrom(Function(src As Service.User) src.INumber)) _
.AfterMap(Sub(src As Service.User, dest As Models.User)
SyncLock _myLock
dest.Groups = New List(Of String)
Using service = ApplicationSecurityManager.Service.Factory.GetService()
Dim applicationPermissions = service.LoadPermissionsForUser(dest.Username, MyBase.EnvironmentCode)
If (Not applicationPermissions Is Nothing AndAlso applicationPermissions.Any(Function(x) x.Code = MyBase.ApplicationCode)) Then
dest.Groups = applicationPermissions.Single(Function(x) x.Code = MyBase.ApplicationCode).GroupNames.ToList()
End If
End Using
End SyncLock
End Sub)
This is pretty common mistake modifying a collection while iterating it. Is it possible you are leaving something out here we can't see? Anyway's in the code that you have provided there is not any such scenario from what I can see. This means that you might be calling this in a multi-threaded environment and the collection is being modified in some other thread.
What can you try?
Look into locking your enumeration so only one thread at a time can be accessed. It's possible that it's being accessed multiple time's when user's are clicking on the button.
Here's a good link to help you out: http://weblogs.asp.net/leftslipper/mvc-locking-the-routecollection

What is causing a SignalR FormatException Invalid Cursor?

I have written a simple SignalR hub:
public void PostUpdate(string message)
{
try
{
var update = URS.Tools.JsonSerializer.DeserializeFromJson<DataUpdate>(message);
switch (update.UpdateType)
{
case DataUpdateType.Opportunity:
Clients.All.UpdateOpportunity(update.DataUpdateId);
break;
case DataUpdateType.Contact:
Clients.All.UpdateContact(update.DataUpdateId);
break;
case DataUpdateType.Client:
Clients.All.UpdateClient(update.DataUpdateId);
break;
}
}
catch (Exception exception)
{
Logger.LogError(exception);
}
}
It is running with a Silverlight 5 client. For the most part it works, but after 5 - 30 minutes I get an error coming from withing the library:
Exception information:
Exception type: FormatException
Exception message: Invalid cursor.
at Microsoft.AspNet.SignalR.Messaging.Cursor.GetCursors(String cursor, Func`2 keyMaximizer)
at Microsoft.AspNet.SignalR.Messaging.DefaultSubscription..ctor(String identity, IEnumerable`1 eventKeys, TopicLookup topics, String cursor, Func`2 callback, Int32 maxMessages, IStringMinifier stringMinifier, IPerformanceCounterManager counters)
at Microsoft.AspNet.SignalR.Messaging.MessageBus.CreateSubscription(ISubscriber subscriber, String cursor, Func`2 callback, Int32 messageBufferSize)
at Microsoft.AspNet.SignalR.Messaging.MessageBus.Subscribe(ISubscriber subscriber, String cursor, Func`2 callback, Int32 maxMessages)
at Microsoft.AspNet.SignalR.Infrastructure.Connection.Receive(String messageId, Func`2 callback, Int32 maxMessages)
at Microsoft.AspNet.SignalR.Transports.ForeverTransport.ProcessMessages(ITransportConnection connection, Func`1 postReceive, Action`1 endRequest)
When I look at the packets, I cannot see a difference between the one just prior to the error that succeeds and the call that fails. It is running serverEvents transport, but I tried longPolling to no avail.
The exception is happening in the server.
Any ideas what could be causing the above error and/or how to resolve it?

Microsoft not disposing of their own objects?

EDIT: Server is MOSS 2007 Enterprise, running SP1 and all patches up to, but not including, SP2. SP2 is coming soon.
In one of my SharePoint apps, I am getting this warning & stacktrace over and over (with different GUIDS): since it's only one of my apps, I assume there's something in my project's code, but SPDisposeCheck returns clean, and there's nothing in the logs that point to my code.
Any ideas on how I can track this down?
Error I'm getting:
Potentially excessive number of
SPRequest objects (9) currently
unreleased on thread 1. Ensure that
this object or its parent (such as an
SPWeb or SPSite) is being properly
disposed. Allocation Id for this
object:
{1DFFC1ED-E69E-4580-8D7B-45EDB5C49188}
Stack trace of current allocation:
at Microsoft.SharePoint.SPRequestManager.Add(SPRequest request, Boolean shareable)
at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)
at Microsoft.SharePoint.SPWeb.InitializeSPRequest()
at Microsoft.SharePoint.SPWeb.EnsureSPRequest()
at Microsoft.SharePoint.SPWeb.get_Request()
at Microsoft.SharePoint.SPWeb.GetFileOrFolderProperties(String strUrl, ListDocsFlags listDocsFlags, Boolean throwException)
at Microsoft.SharePoint.SPFile.PropertiesCore(Boolean throwException)
at Microsoft.SharePoint.SPFile.get_Properties()
at Microsoft.SharePoint.SPFile.get_Level()
at Microsoft.SharePoint.Publishing.WebControls.ConsoleXmlUtilities.configFile(String myUniqueId, SPFileLevel level)
at Microsoft.SharePoint.Publishing.WebControls.ConsoleXmlUtilities.ConfigurationXml(String configProvider, Boolean isBuiltInConfigFile)
at Microsoft.SharePoint.Publishing.WebControls.ConsoleXmlUtilities.GetConsoleNodeCollection(String configXml, ConsoleNode prePopulatedRootNode)
at Microsoft.SharePoint.Publishing.WebControls.ConsoleXmlUtilities.GetConsoleNodeCollection(String configXml)
at Microsoft.SharePoint.Publishing.WebControls.ConsoleXmlUtilities.GetConsoleNodeCollectionFromXmlFile(String configName, Boolean isBuiltInConfigFile)
at Microsoft.SharePoint.Publishing.WebControls.XmlConsoleDataSource.LoadTreeFromConfigXml()
at Microsoft.SharePoint.Publishing.WebControls.XmlConsoleDataSource.OnLoad(EventArgs e)
at Microsoft.SharePoint.Publishing.WebControls.ConsoleDataSource.ForceInitLoad(EventArgs e)
at Microsoft.SharePoint.Publishing.WebControls.PublishingSiteActionsMenuCustomizer.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
This is apparently expected behavior.

Resources