.Net 6 WebApplicationBuilder.WebHost.CaptureStartupErrors not working - .net-6.0

I'm trying to migrate from Startup model to the minimal .NET 6 WebApplication method of running a web application, and I'm specifically interested in keeping the CaptureStartupErrors functionality working.
I am calling the following line on my WebApplicationBuilder, but it makes no difference:
webApplicationBuilder.WebHost.CaptureStartupErrors(true);
Since the code is now simply all laid out flat in the Program.cs' Main method, I actually don't know how this would actually work. If I throw an exception there, it will just exist the program. Am I missing something?

Related

How do I debug work of 2sxc if Visual Query works perfectly during debug, but cshtml code can't access data?

I've edited some existing visual queries of Blog 4.0 application and when I was debugging it - it worked perfectly. But then on page it stopped working. Any attempt to use key with Data like Data["Posts"] raises System.Collections.Generic.KeyNotFoundException. App.Query["Blog Posts List"]["Posts"] returns something, but any attempt to access its fields raises another exception (don't remember the name, but it said that there's no such member inside that object).
I didn't rename queries, I didn't change application settings. I just edited logic of 2 queries. I renamed 1 wiring endpoint name across 3 queries in whole chain.
How do I debug it? How can I see what does cshtml receive from database so I don't guess and put my crystal ball away?
In general, App.Query["Name of Query"] will get you the streams of data. You usually need to convert it using AsDynamic() or AsList() to something you can work with.
This should help some; What is Data?
If you're just running into problems with field names, you probably forgot the AsList or AsDynamic, just like #accuraty-jeremy mentioned.
For real debugging, go to insights, you'll see what happens - but in your case it probably won't help, because your working with an object that's not dynamic (so doesn't support .FirstName) until you AsList/AsDynamic it.
My bad: I confused two different files - _List.cshtml and _List Paging.cshtml. So I was searching for an error in the code of wrong file.

Testing ViewModels in MVVMCorss

I have just started working with MVVMCross for a cross platform app and I am having a hard time figuring out how to test my ViewModels. I tried following the testing done in TwitterSearch and ran into problems. Specifically in the MockSetup.cs I found that in the latest version of MvvmCross there no longer seems to be a IMvxViewDispatcherProvider but that is ok because I think its functionality has been rolled up into the IMvxViewDispatcher. However, when actually setting up the dipatcher for my test cases there is no RequestNavigate method for the dispatcher anymore and I can not find an implementation of MvxShowViewModelRequest. So I can not actually get any tests for my ViewModels to work.
I also tried to follow the testing here http://slodge.blogspot.com/2012/10/testing-viewmodels-in-mvvmcross.html but again ran into issues with missing MvxOpenNetCfServiceProviderSetup.
So in summary, my issue has been getting a MockSetup working so that I can test my ViewModels. If I could just be pointed in the right direction on the dispatcher, I think that would help.
It looks like you are trying to test an mvvmcross v3 application using mvvmcross vnext objects.
The updated twitter search test for v3 is at https://github.com/slodge/MvvmCross-Tutorials/tree/master/Sample%20-%20TwitterSearch/TwitterSearch.Test
This test uses a single special mock object: https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20TwitterSearch/TwitterSearch.Test/Mocks/MockMvxViewDispatcher.cs
The role of this mock is just currently:
to provide a very simple main thread (it uses the current thread)
to provide simple storage for any navigation requests.
You can see it used in:
https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20TwitterSearch/TwitterSearch.Test/HomeViewModelTest.cs

What is the standard approach for setting up a Visual Studio 2010 solution for ASP.NET MVC 3 project

I am currently working on a ASP.NET MVC 3 project and I am setting up the solution file on VS2010.
I am not sure of what is the standard approach. I am using the following approach
Company.Dept.Data (contains the dbml file - Data Model)
Company.Dept.Business (Business logics)
Company.Dept.Web (contains ASP.NET MVC3 webapplication)
The first two are class libraries and the last one is MVC3 web application.
Anyother recommendations?
There is no single "standard" approach. It all depends on your project and what problems you are trying to solve with the software. Your proposed structure of having 2 class libraries and 1 web project is one way to go for sure.
If you are going to do any kind of Dependency Injection using an Inversion of Control container, you might also want to consider having an "API" project for interfaces and an "Impl(ementation)" project for concrete classes that fulfill the interface contracts.
To echo danludwig, there really is no standard. I prefer breaking up libraries and namespaces according to functionality. Company.Db is my library for interacting with the database, Company.Mail are my wrappers around the Postmark mail service, etc.
I then tend to group like libraries into single repositories. So the 'storage' repository in source control holds Company.Db, Company.Caching, Company.FileStorage, etc. I have another repository 'messaging' that holds Company.Mail and Company.SMS (for interacting with Twilio to send text messages). When I branch out with new apps or new services (maybe a WCF endpoint for mobile clients), I can just pull down the 'messaging' repository, and I have all my class libraries for communicating with the user.
An application then looks like
Company.Application.Webite
\Libraries\Messaging
\Libraries\Messaging\Company.Mail
\Libraries\Storage
\Libraries\Messaging\Company.Db
\Libraries\Messaging\Company.Caching
\Libraries\Web
...
Company.Application.Wcf
\Libraries\Messaging
\Libraries\Storage
\Libraries\Messaging\Company.Db
\Libraries\Messaging\Company.Caching
...
This way, whether someone registers via the site, or via the mobile app, Company.Mail.MailServices.SendWelcomeEmail() sends the exact same welcome email, and there's no code duplication.
Whether this works for you, or even makes sense, who knows. I've also changed this scheme a hundred times, trying to find a layout that works with my development style/workflow. I wouldn't worry or stress too much about it, because whatever you pick, you're going to find things you like about it, and you'll find things you hate about it. I sometimes fall into the trap of spending more time trying to make everything "perfect", than to just code and change things I don't like.

When does OnEndPage method run for object created indirectly by ASP (classic) page

I'm trying to debug an issue which may be due to a delay in running some cleaup code that's in an OnEndPage method.
I have a LoginPage class (in VB6) which is normally created directly by an ASP page. But in another case, an ASP page creates another VB object, which then does approximately this
Set oLoginPage = Server.CreateObject("LoginPage")
Call oLoginPage.DoLogout;
Set oLoginPage = Nothing
Some crucial cleanup is done in the OnEndPage method of LoginPage class, and it looks like this happens asynchronously, and with enough of a lag to cause problems.
Can anyone confirm that OnEndPage runs asynchronously, and might lag a bit? I've not been able to find any mention of this in documentation, just that objects are garbage collected "as soon as the reference count goes to zero." But that doesn't seem to be what's happening in my code.
This is a VB6 application called by an ASP page. It needs to run on multiple versions of IIS from 5.0 upwards.
Thanks.
O.K., it's simpler than I thought. Apparently the OnEndPage method is run by ASP after all the rest of the stuff on the page is finished. This applies even to VB objects created indirectly (that is, created by VB objects that were created by the ASP page), as long as they are created using Server.CreateObject().

Is there a way to add global error handler in a visual basic 6.0 application?

VB 6.0 does not have any global handler.To catch runtime errors,we need to add a handler in each method where we feel an error can occur.But, still some places might be left out.So,we end up getting runtime errors.Adding error handler in all the methods of an application,the only way?
No there is no way to add a global error handler in VB6. However, you do not need to add an error handler in every method. You only really need to add an error handler in every event handler. E.g. Every click event,load event, etc
While errors do propogate upwards, VB6 has no way to do a stack trace, so you never know which method raised the error. Unfortunately, if you need this information, you have to add a handler to each method just to log where you were.
Also: errors do propagate upwards: if method X calls methods Y and Z, a single error handler in method X will cover all three methods.
I discovered this tool yesterday:
http://www.everythingaccess.com/simplyvba-global-error-handler.htm
It is a commercial product that enables global error handling in VB6 and VBA applications.
It has its cost but does its job perfectly. I have seen other tools (free though) helping in this VB6 mangle, but none can cover a true real global error handling like "SimplyVB6 Global Error Handler for VB6" does.
With "SimplyVB6 Global Error Handler for VB6", there is no need to change any line of existing code, and no need to number the lines of code (via a plug-in or something).
Just enable Global error handling (one line of code in the main module) and you are all set.
"SimplyVB6 Global Error Handler for VB6":
can show the call stack with real module and function names, as well as display the source code line.
Works only with P-Code compiled VB6 programs.
can work via early or late binding (no DLL Hell).
I am not in any way affiliated to www.everythingaccess.com, just happy to have found it yesterday afternoon, was kind of looking at this problem again as one of my customers was having bugs in our VB6 application. I was able to test the tool yesterday afternoon, exchanging emails with the www.everythingaccess.com support and getting the evaluation product per mail.
Their web side does not allow yet to download the evaluation version of the VB6 product, you have to email them but they are answering in less than an hour.
on error resume next - is kinda close but its been a while.
you might want to look up any caveats

Resources