Environment
Xamarin Forms: 5.0.0.1709-pre4 (but also fails with 4.8.0.1687)
VS2019 16.8.3
XCode: 12.2
Prism NuGets
Prism.DryIoc.Extensions 8.0.48
Prism.Forms 8.0.0.1909
Prism.PluginPopups 8.0.31-beta
Shiny.Prism 8.0.48
Inner Exception from INavigationResult: DryIoc.ContainerException -> InvalidOperationException
code: Error.UnableToResolveFromRegisteredServices;
message: Unable to resolve Resolution root IRMobile.PageModels.LandingPageModel with passed arguments
[Constant(Prism.Navigation.ErrorReportingNavigationService,
typeof(Prism.Navigation.ErrorReportingNavigationService))]
from container with scope {Name=null}
with Rules with {TrackingDisposableTransients, UseDynamicRegistrationsAsFallbackOnly,
FuncAndLazyWithoutRegistration, SelectLastRegisteredFactory} and without
{ThrowOnRegisteringDisposableTransient, UseFastExpressionCompilerIfPlatformSupported}
with FactorySelector=SelectLastRegisteredFactory
with Made={FactoryMethod=ConstructorWithResolvableArguments}
with normal and dynamic registrations:
(DefaultDynamicKey(0), {FactoryID=317, ImplType=IRMobile.PageModels.LandingPageModel,
Reuse=TransientReuse, HasCondition})
Stack Trace from InnerException:
at DryIoc.Container.TryThrowUnableToResolve (DryIoc.Request request) [0x00058] in /_/src/DryIoc/Container.cs:1077
at DryIoc.Container.DryIoc.IContainer.ResolveFactory (DryIoc.Request request) [0x00072] in /_/src/DryIoc/Container.cs:1059
at DryIoc.Container.ResolveAndCacheKeyed (System.Int32 serviceTypeHash, System.Type serviceType, System.Object serviceKey, DryIoc.IfUnresolved ifUnresolved, System.Object scopeName, System.Type requiredServiceType, DryIoc.Request preResolveParent, System.Object[] args) [0x000c5] in /_/src/DryIoc/Container.cs:471
at DryIoc.Container.DryIoc.IResolver.Resolve (System.Type serviceType, System.Object serviceKey, DryIoc.IfUnresolved ifUnresolved, System.Type requiredServiceType, DryIoc.Request preResolveParent, System.Object[] args) [0x00042] in /_/src/DryIoc/Container.cs:430
at DryIoc.Resolver.Resolve (DryIoc.IResolver resolver, System.Type serviceType, System.Object[] args, DryIoc.IfUnresolved ifUnresolved, System.Type requiredServiceType, System.Object serviceKey) [0x00000] in /_/src/DryIoc/Container.cs:7809
at Prism.DryIoc.DryIocContainerExtension.Resolve (System.Type type, System.ValueTuple`2[System.Type,System.Object][] parameters) [0x0001c] in /_/external/Prism/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs:294
App.xaml.cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// for RgPopups
containerRegistry.RegisterPopupNavigationService();
containerRegistry.RegisterPopupDialogService();
// Essentials
containerRegistry.Register<ISecureStorage, SecureStorageImplementation>();
containerRegistry.RegisterSingleton<IAppInfo, AppInfoImplementation>();
// page stuff
containerRegistry.RegisterForNavigation<NavigationPage>();
containerRegistry.RegisterForNavigation<IconNavigationPage>();
containerRegistry.RegisterSingleton<IPageBehaviorFactory, CustomPageBehaviorFactory>();
...
// Page and model registrations
containerRegistry.RegisterForNavigation<LoginPage, LoginPageModel>();
containerRegistry.RegisterForNavigation<LandingPage, LandingPageModel>();
}
I get this exeption when trying to navigate to a root master/detail page from a LoginPage
await NavigationService.NavigateAsync("/MainPage/NavigationPage/LandingPage")
and the constructor for the LandingPage is
public LandingPageModel(INavigationService navigationService, IMapper mapper, IDialogs dialogs, IPushManager pushManager) : base(navigationService, mapper)
I am fairly new to Prism so I'm sure I am missing something, a registration or maybe a NuGet package, but I'm not sure what it would be. I commented out the Registrations for Popup as I was getting the same error, but referring to Prism.Plugin.Popups.PopupPageNavigationService
As always, thanks for any help!
It looks like you are attempting to navigate to a page called LandingPage, but you haven't told the container what LandingPage is.
Every time you want to create a new view and navigate to it, you need to register it for Navigation inside your App.Xaml.cs file;
containerRegistry.RegisterForNavigation<LandingPage, LandingPageViewModel>();
This line registers the view and its corresponding ViewModel inside the container. Once the container knows about the view, the NavigationService can resolve the view you wish to navigate to using the literal name of the view LandingPage.
Now you can call
await NavigationService.NavigateAsync("LandingPage");
//or
await NavigationService.NavigateAsync("/MainPage/NavigationPage/LandingPage")
NOTE
Prism navigation has a couple of neat tricks built into it. It is Uri based, so every time you navigate to another view, passing the name of the view in the NavigateAsync method will stack the view on top of the others. This means that if you start at the URI NavigationPage/PageA, if you then say NavigateAsync("PageB") you will end up at NavigationPage/PageA/PageB.
Additionally, including the / character at the very beginning of the NavigateAsync argument completely resets the stack. So if you navigate to /PageC from NavigationPage/PageA/PageB, this resets the stack to just PageC
Related
I have a Razor Class Library (RCL) that contains both Razor components and pages. This RCL has a folder named "Pages" which contains an Index.razor page and one named Details.razor. I have added the RCL to a Blazor Server project, referenced it, and am trying to let the router in the host project know where to find the Details.razor page (the host project already contains an Index page and will not use the RCL version). Here is my router code from App.razor:
<Router AppAssembly="#typeof(App).Assembly"
AdditionalAssemblies="new[] {
typeof(MyRcl.Pages.Details).Assembly
}">
<Found Context="routeData">
<RouteView RouteData="#routeData" DefaultLayout="#typeof(MainLayout)" />
<FocusOnNavigate RouteData="#routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="#typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Building the project throws the following exception from the last line of the _Host.cshtml file:
#page "/"
#namespace MyProject.Pages
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
#{
Layout = "_Layout";
}
<component type="typeof(App)" render-mode="ServerPrerendered" />
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Call stack:
>
MyProject.dll!MyProject.Pages.Pages__Host.ExecuteAsync() Line 8 C#
Microsoft.AspNetCore.Mvc.RazorPages.dll!Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAdapter.ExecuteAsync() Unknown
Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(Microsoft.AspNetCore.Mvc.Razor.IRazorPage page, Microsoft.AspNetCore.Mvc.Rendering.ViewContext context) Unknown
Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(Microsoft.AspNetCore.Mvc.Razor.IRazorPage page, Microsoft.AspNetCore.Mvc.Rendering.ViewContext context, bool invokeViewStarts) Unknown
Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(Microsoft.AspNetCore.Mvc.Rendering.ViewContext context) Unknown
Microsoft.AspNetCore.Mvc.ViewFeatures.dll!Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, string contentType, int? statusCode) Unknown
Microsoft.AspNetCore.Mvc.RazorPages.dll!Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageResultExecutor.ExecuteAsync(Microsoft.AspNetCore.Mvc.RazorPages.PageContext pageContext, Microsoft.AspNetCore.Mvc.RazorPages.PageResult result) Unknown
Microsoft.AspNetCore.Mvc.RazorPages.dll!Microsoft.AspNetCore.Mvc.RazorPages.PageResult.ExecuteResultAsync(Microsoft.AspNetCore.Mvc.ActionContext context) Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultAsync(Microsoft.AspNetCore.Mvc.IActionResult result) Unknown
Microsoft.AspNetCore.Mvc.RazorPages.dll!Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeResultAsync(Microsoft.AspNetCore.Mvc.IActionResult result) Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<Microsoft.AspNetCore.Mvc.Filters.IResultFilter, Microsoft.AspNetCore.Mvc.Filters.IAsyncResultFilter>(ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.State next, ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Scope scope, ref object state, ref bool isCompleted) Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResultFilterAsync<Microsoft.AspNetCore.Mvc.Filters.IResultFilter, Microsoft.AspNetCore.Mvc.Filters.IAsyncResultFilter>() Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<Microsoft.AspNetCore.Mvc.Filters.IResultFilter, Microsoft.AspNetCore.Mvc.Filters.IAsyncResultFilter>(ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.State next, ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Scope scope, ref object state, ref bool isCompleted) Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.State next, ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Scope scope, ref object state, ref bool isCompleted) Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter() Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.State next, ref Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Scope scope, ref object state, ref bool isCompleted) Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() Unknown
Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeAsync() Unknown
Microsoft.AspNetCore.Mvc.RazorPages.dll!Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageRequestDelegateFactory.CreateRequestDelegate.AnonymousMethod__0(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.Routing.dll!Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext httpContext) Unknown
Microsoft.AspNetCore.Routing.dll!Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext httpContext) Unknown
Microsoft.AspNetCore.StaticFiles.dll!Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.HttpsPolicy.dll!Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.HttpsPolicy.dll!Microsoft.AspNetCore.HttpsPolicy.HstsMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.Diagnostics.dll!Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.Diagnostics.dll!Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.HostFiltering.dll!Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.WebTools.BrowserLink.Net.dll!Microsoft.WebTools.BrowserLink.Net.BrowserLinkMiddleware.ExecuteWithFilterAsync(Microsoft.WebTools.BrowserLink.Net.IHttpSocketAdapter injectScriptSocket, string requestId, Microsoft.AspNetCore.Http.HttpContext httpContext) Unknown
Microsoft.WebTools.BrowserLink.Net.dll!Microsoft.WebTools.BrowserLink.Net.BrowserLinkMiddleware.InvokeAsync(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.Watch.BrowserRefresh.dll!Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware.InvokeAsync(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.Http.Abstractions.dll!Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext context) Unknown
Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.HostingApplication.ProcessRequestAsync(Microsoft.AspNetCore.Hosting.HostingApplication.Context context) Unknown
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests<Microsoft.AspNetCore.Hosting.HostingApplication.Context>(Microsoft.AspNetCore.Hosting.Server.IHttpApplication<Microsoft.AspNetCore.Hosting.HostingApplication.Context> application) Unknown
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync<Microsoft.AspNetCore.Hosting.HostingApplication.Context>(Microsoft.AspNetCore.Hosting.Server.IHttpApplication<Microsoft.AspNetCore.Hosting.HostingApplication.Context> application) Unknown
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Stream<Microsoft.AspNetCore.Hosting.HostingApplication.Context>.Execute() Unknown
System.Private.CoreLib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown
System.Private.CoreLib.dll!System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() Unknown
System.Private.CoreLib.dll!System.Threading.Thread.StartCallback() Unknown
If I remove the "AdditionalAssemblies" statement from the router configuration the app builds and runs fine, so I am pretty sure that is triggering the error but am unsure on what is causing it (I have double-checked the syntax and compared it with other apps where I have consumed Razor pages from RCLs and the code seems correct). Any help or ideas for further clarifying what the underlying problem might be is appreciated.
Found the issue - will post here in case someone else encounters the same problem as is difficult to identify. It is a variation of a .NET 6 issue described here and here which is slotted for consideration in .NET 7. In my case the issue was the duplicate Index.razor files in the host project and RCL (not the Details.razor file I was trying to consume from the RCL). The duplicate files should not be an issue per MS documentation as the file in the hosting app should take precedence. This was indeed the case until I tried to modify App.razor to consume the Details page from the RCL, at which point the exception occurs (even though I am only referencing the unduplicated Details page and not the Index page in the router code). I can resolve the exception by removing the unused Index page in the RCL (but this is not a permanent solution as it is used in other projects). My workaround for now is to override both of the RCL pages and remove the AdditionalAssemblies statement from App.razor.
I have seen all of the following questions:
NUnit .NET Core running through Resharper
Running NUnit Tests in .NET Core with ReSharper
NUnit TestCaseSource
Despite following all of their advice and having the following lines in all of my
test projects:
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
I am still getting the following errors in the Unit Test Explorer window of ReSharper (version 2018.1.2):
2018.06.23 11:22:21.292 ERROR Transition failed: Transition from state <HandShake> on event <remote::.ProtocolVersion>. Cause: System.InvalidOperationException: Test-cases are missing for the selected tests. Rebuild the project and try again. at JetBrains.ReSharper.UnitTestFramework.DotNetCore.DotNetVsTest.DotNetVsTestExecution.SendGetProcessStartInfo() at Appccelerate.StateMachine.Machine.ActionHolders.ArgumentLessActionHolder.Execute(Object argument) at Appccelerate.StateMachine.Machine.States.State`2.ExecuteEntryAction(IActionHolder actionHolder, ITransitionContext`2 context)
--- EXCEPTION #1/1 [LoggerException]
Message = “
Transition failed: Transition from state <HandShake> on event <remote::.ProtocolVersion>.
Cause: System.InvalidOperationException: Test-cases are missing for the selected tests. Rebuild the project and try again.
at JetBrains.ReSharper.UnitTestFramework.DotNetCore.DotNetVsTest.DotNetVsTestExecution.SendGetProcessStartInfo()
at Appccelerate.StateMachine.Machine.ActionHolders.ArgumentLessActionHolder.Execute(Object argument)
at Appccelerate.StateMachine.Machine.States.State`2.ExecuteEntryAction(IActionHolder actionHolder, ITransitionContext`2 context)
”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
at JetBrains.ReSharper.UnitTestFramework.DotNetCore.DotNetVsTest.DotNetVsTestProtocol.<.ctor>b__22_14(Object sender, TransitionExceptionEventArgs`2 args)
at Appccelerate.StateMachine.Machine.StateMachine`2.RaiseEvent[T](EventHandler`1 eventHandler, T arguments, ITransitionContext`2 context, Boolean raiseEventOnException)
at Appccelerate.StateMachine.Machine.StateMachine`2.OnExceptionThrown(ITransitionContext`2 context, Exception exception)
at Appccelerate.StateMachine.Machine.Contexts.TransitionContext`2.OnExceptionThrown(Exception exception)
at Appccelerate.StateMachine.Machine.States.State`2.HandleException(Exception exception, ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.States.State`2.HandleEntryActionException(ITransitionContext`2 context, Exception exception)
at Appccelerate.StateMachine.Machine.States.State`2.ExecuteEntryAction(IActionHolder actionHolder, ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.States.State`2.ExecuteEntryActions(ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.States.State`2.Entry(ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.States.State`2.EnterShallow(ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.States.State`2.EnterHistoryNone(ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.States.State`2.EnterByHistory(ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.Transitions.Transition`2.Fire(ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.States.State`2.Fire(ITransitionContext`2 context)
at Appccelerate.StateMachine.Machine.StateMachine`2.Fire(TEvent eventId, Object eventArgument)
at Appccelerate.StateMachine.ActiveStateMachine`2.ProcessEventQueue(CancellationToken cancellationToken)
at Appccelerate.StateMachine.ActiveStateMachine`2.<Start>b__32_0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
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.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.Tasks.ThreadPoolTaskScheduler.LongRunningThreadWork(Object obj)
at System.Threading.ThreadHelper.ThreadStart_Context(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.Threading.ThreadHelper.ThreadStart(Object obj)
”
2018.06.23 11:22:21.315 ERROR System.InvalidOperationException: Test-cases are missing for the selected tests. Rebuild the project and try again.
at JetBrains.ReSharper.UnitTestFramework.DotNetCore.DotNetVsTest.DotNetVsTestExecution.SendGetProcessStartInfo()
at Appccelerate.StateMachine.Machine.ActionHolders.ArgumentLessActionHolder.Execute(Object argument)
at Appccelerate.StateMachine.Machine.States.State`2.ExecuteEntryAction(IActionHolder actionHolder, ITransitionContext`2 context)
2018.06.23 11:22:21.316 WARN Element UnitTests.Tests.RegressionTests was left pending after its run completion.
2018.06.23 11:22:21.316 WARN Element UnitTests.Tests.RegressionTests.TestAllRegressions was left pending after its run completion.
These are the newest versions of each of these packages, but I have also tried matching NUnit's version to the TestAdapter's version (3.10.0). The most baffling part of this is that Visual Studio's Test Explorer has no problem running the tests! I would very much like to use ReSharper's explorer to easily run their profiling and coverage tools on my tests.
Moreover, at some point in time ReSharper's test explorer used to work, but I'm not aware of the particular version combination that led to it. This setup still works for basic [Test] style tests and only fails for [TestCaseSource] tests.
ETA: ReSharper is also not running namespace-level setup and tear-down fixtures. Maybe this is part of the problem?
How do I fix this?
This was a bug. JetBrains fixed it in ReSharper 2018.2 EAP 5. It's still finicky, but when it works, it works.
I am almost completely new to Sitecore and I was about to try out adding a controller rendering to a demo page I am creating.
I have a main page, with a placeholder for the controller rendering. Placeholder is added to the presentation details of my main page item and accepts the rendering.
When I now go to the experience editor and try to add the controller rendering to the page I get this
Error Rendering Controller: SitecoreDemo.Controllers.FoodFinder.PlacesToEatListController, SitecoreDemo. Action: Index: An unhandled exception occurred.
at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)
at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)
at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at Sitecore.Mvc.Controllers.ControllerRunner.ExecuteController(Controller controller)
at Sitecore.Mvc.Controllers.ControllerRunner.Execute()
at Sitecore.Mvc.Presentation.ControllerRenderer.Render(TextWriter writer)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)
I think this isn't even the full stacktrace but I only see this little box on the page and I don't know how I could even get to the full exception message...
The issue Might be because of the dll referencing the Controller was not in the bin folder. So, please make sure that the assembly referencing the Controller is in the bin folder.
Also, even if the dll is in the bin folder, it may be that it is not being overwritten with the new one. You may try to copy and paste the dll into the bin folder.
Problem was caused by putting the view in the wrong place. If returning a view by convention it's always Views\\.cshtml no matter where the controller is located.
My views were mirroring the namespace structure of the controller which caused ASP.NET MVC to fail finding it by convention (return View(model))
I'm trying to setup Ninject on my new project and I want to scan assembilies using convetions so that
IFoo
will automatically resolve to
IBar
All the samples and documentation describes using this approach
kernel.Scan(...)
while the Ninject 3 Kernel seems to use .Load instead. If I'm using Load for scanning then how do I configure scanning with conventions?
Edit
I was able to get it working using: https://github.com/ninject/ninject.extensions.conventions/wiki/What-is-configuration-by-convention
However, now I can't get my modules to load. I'm using the code below and getting the error below.
IKernel kernel = new StandardKernel();
kernel.Bind(x => x
.FromAssembliesMatching("Crt.*.dll")
.SelectAllTypes()
.BindAllInterfaces()
);
kernel.Load("*.dll");
return kernel;
Error:
Ninject.ActivationException was unhandled
Message=Error activating ITrainingEngine
More than one matching bindings are available.
Activation path:
1) Request for ITrainingEngine
Suggestions:
1) Ensure that you have defined a binding for ITrainingEngine only once.
Source=Ninject
StackTrace:
at Ninject.KernelBase.Resolve(IRequest request) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 380
at Ninject.ResolutionExtensions.GetResolutionIterator(IResolutionRoot root, Type service, Func`2 constraint, IEnumerable`1 parameters, Boolean isOptional, Boolean isUnique) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 263
at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 37
at Crt.BlackBox.Train.Program.Run() in C:\code\Crimson\CRT\readmission\src\Crt.BlackBox\Crt.BlackBox.Train\Program.cs:line 54
at Crt.BlackBox.Train.Program.Main(String[] args) in C:\code\Crimson\CRT\readmission\src\Crt.BlackBox\Crt.BlackBox.Train\Program.cs:line 24
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
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.Threading.ThreadHelper.ThreadStart()
InnerException:
Use SelectAllClasses instead of SelectAllTypes
I'm playing around with MonoDev on my mac and wanting to see how well it can run basic ASP.NET applications which I've worked on.
I chose a very basic site, it's got a handful of ASP.NET pages, all of which inherit nested master pages and some ASP.NET AJAX stuff. The project is .NET 2.0 and I have the web.config set appropriately for ASP.NET AJAX 1.0.
Under windows this runs without any dramas and because it's so simple I expected it to "just work" in MonoDev too. The problem is that when I run using the built-in web server for MonoDev I get the following exception:
Server Error in '/' Application
Object reference not set to an instance of an object
Description: HTTP 500. Error processing request.
Stack Trace:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Web.Handlers.ScriptResourceHandler.EncryptString (System.String s) [0x00000] in :0
at System.Web.Handlers.ScriptResourceHandler+RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl (System.Reflection.Assembly assembly, System.String resourceName, System.Globalization.CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) [0x00000] in :0
at System.Web.Handlers.ScriptResourceHandler.GetScriptResourceUrl (System.Reflection.Assembly assembly, System.String resourceName, System.Globalization.CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) [0x00000] in :0
at System.Web.UI.ScriptReference.GetUrlFromName (System.Web.UI.ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) [0x00000] in :0
at System.Web.UI.ScriptReference.GetUrl (System.Web.UI.ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) [0x00000] in :0
at System.Web.UI.ScriptManager.RegisterScripts () [0x00000] in :0
at System.Web.UI.ScriptManager.OnPagePreRenderComplete (System.Object sender, System.EventArgs e) [0x00000] in :0
at System.Web.UI.Page.OnPreRenderComplete (System.EventArgs e) [0x0002a] in /private/tmp/monobuild/build/BUILD/mono-2.6.1/mcs/class/System.Web/System.Web.UI/Page.cs:2157
at System.Web.UI.Page.ProcessLoadComplete () [0x000bf] in /private/tmp/monobuild/build/BUILD/mono-2.6.1/mcs/class/System.Web/System.Web.UI/Page.cs:1654
at System.Web.UI.Page.InternalProcessRequest () [0x001cb] in /private/tmp/monobuild/build/BUILD/mono-2.6.1/mcs/class/System.Web/System.Web.UI/Page.cs:1536
at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x0005b] in /private/tmp/monobuild/build/BUILD/mono-2.6.1/mcs/class/System.Web/System.Web.UI/Page.cs:1353
Version information: Mono Runtime Version: 2.6.1 (tarball Thu Dec 17 10:19:23 MST 2009); ASP.NET Version: 2.0.50727.1433
It seems though that when I remove my ScriptManager from my root master page everything runs fine (well except for the JavaScript which expects it to be there).
Being completely new to Mono & MonoDev I don't really know where to start with debugging other than getting to the point I'm currently at.
I had the same problem when doing some Mono testing and the problem was the scriptmanager was not inside the form runat="server" id="form1" /form tags. Once that was added the NULL exception went away.