Visual Studio with React project keeps starting multiple copies of the development server - asp.net-core

I'm using Visual Studio 2022 with the React template on .NET (core) 6.
When I press f5 to start debugging, it starts a command prompt to start the development proxy server, fires up my deafult browser (chrome), and everything seems to work OK.
However, about every 2 minutes after, regardless of whether I have touched VS or the app, it then starts another copy of the development server, which then gets stuck with a prompt saying Something is already running on port 3000. Left to its own devices it just keeps starting more.
This doesn't stop the previous one working but it's frustrating to have all these windows appearing, especially as they steal focus when prompting with the "port in use".
Something that I suspect is related is a message appearing in the debug output around every 8 seconds saying "Microsoft.AspNetCore.SpaProxy.SpaProxyMiddleware: Information: SPA proxy is not ready. Returning temporary landing page." However as noted above the SPA proxy certainly seems to be running OK.
Has anyone got any ideas what might be happening or any workaround for this?

OK I managed to figure this out by creating another blank project and comparing them.
The port that the development server will listen on is stored in a file called ClientApp\.env.development; the port that visual studio expects it to listen on is in the .csproj file under PropertyGroup/SpaProxyServerUrl. If there is a mismatch you will get this behaviour because VS thinks the server isn't running and keeps on trying to start it.
In my case I had added the .env.development file to the version control ignore list thinking it wasn't important. This was causing the dev server to listen on the default port 3000.

Related

How to get hot reloading working with React.js project template in VS2022 Mac

I am using the React.js project template in VS2022 for Mac and the application starts up fine when run with “Start Debugging” or “Start Without Debugging”. When making changes to the React front end code, the page refreshes and the changes are instantly viewable. However, when making any changes to the backend API code, you have to stop and restart in Visual Studio before the changes are reflected in the API calls.
I have also tried running the application with “dotnet watch” from the terminal and in this case I can see the API being re-compiled in the output window when a change is made to the API code, but then it seems to kill the dev proxy server because I am not able to refresh the page as it just returns “The site can’t be reached” (I can see the bash process getting killed in activity monitor, which I think is hosting the dev proxy server). I have to restart the application again in Visual Studio to get it working and see the changes to the API code.
Is there a way when using the SPA proxy in VS 2022 so that you can make changes to either the front end or back end code and have those changes hot reloaded?

MysqlDataAdapter.Update not throwing exception

In my application I have drag and drop functionality for a TreeView and for a DataGridView.
It works great and I have no issues with the code.
I use Visual Basic - Visual Studio 2017 Community on Windows 10 Home Single Language 64-bit. After Building Release it also works fine on Windows 10 when running release.
I then copy it to a Windows 2008 R2 Virtual server where it is run by each user through Remote Desktop.
The strange issue I have is that the TreeView drag and drop functionality works 100%, but the DataGridView seems to ignore my drop - only on the Server.
I can't find anything on the net that relate to this.
Any ideas how I can troubleshoot this issue?
======================================================================
After tediously adding messages between lines I came to the conclusion that it is the MySqlDataAdapter.Update() line that is not executing.
No exception, just stops at this line and throws me out of the DataGridView.DragDrop Sub.
So the new question is, how do I catch that error after compile?
I think I probably asked the question too quickly, apologies.
For anyone that does not get an exception from MySqlDataAdapter, check permission on triggers.
In this case on my development computer root user can access from %.
On the server root is configured for access from localhost only.
One of the triggers was defined "CREATE DEFINER=root#% TRIGGER..." and after changing it to root#localhost it worked.

Windows Server 2008 R2 error 1053 apache

I have a simple PHP application running on this server which allows other people to verify some information on-line. The apache was running OK until a few days back.
The application uses Postgrees and the apache service was configured by an add-on "Enterprise Db Apache", it was not configured by me and is connected to a portal to be shown on-line. This was kinda dropped on me and I had no prior knowledge or experience with databases nor servers and need to put it back on-line. How can I start to find out what made it stop?
Here's a link to the error I'm receiving when trying to start it back again:
https://dl.dropboxusercontent.com/u/12837412/Erro%201053.png
Tried updating .NET to no success,
I've searched around SO and all the threads I found were based on custom services people wrote, and found out that this error code is very generic, I'm very lost and have my neck on the chopping block.
EDIT: Tried some fixes suggested here but had no success. I'm thinking about reinstalling the service, is it a really bad idea? Is there a safe way of doing this without loss of data in the Database? Is there a tutorial on this here already?
The problem was with compatibility of the versions of C/C++ libraries in the server which lead to the programs related to the service not being able to start properly. A simple reinstalation of the compatible version of the libraries made the service able to be started again.
Maybe your service is taking longer time than 30 seconds (Windows default timeout) to start and report ready to the Service Control Manager. Usually this happens because of performance issues.
A possible solution for this is to extend it through the Registry.
Go to Start > Run > and type regedit
Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
With the control folder selected, right click in the pane on the right and select new DWORD Value
Name the new DWORD: ServicesPipeTimeout
Right-click ServicesPipeTimeout, and then click Modify
Click Decimal, type '180000', and then click OK
Restart the computer

Web server for ASP.NET 5 that works without debugging active

sorry if this is a stupid question but I don't get it.
So I've created an ASP.NET 5 page using Visual Studio 2015 and DNX.
Out of the box I have these two dependencies in my project.json:
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4"
Under "commands" in project.json I have the following:
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
In the project properties I can change profiles between "IIS Express" and "web" as deployment options. Both are working fine, when I start debug it starts the web server (either IIS Express or the WebListener) and the site is working. If I stop debugging the server stops. The WebListener opens a "dnx.exe" in a command prompt.
This pluggable server layer is really nice, I get the point. But how do I, as a developer setup an easy server where I can make a change to my site and quickly see the changes?
I can of course install IIS and create a site that is pointing to my wwwroot but is that my only option in the ASP.NET world? Can I have the WebListener "started in the background" (without showing me a command prompt with dnx.exe)? I can also start a node server but yet again - it's great that i can but why do I have to when I have the full ASP.NET toolbelt?
ASP.NET 5 has dynamic compilation but I'm not sure how to even test it since my web server is only started when I'm in debug mode.
I know that this is a pre-release but any help would be greatly appreciated.
But how do I, as a developer setup an easy server where I can make a
change to my site and quickly see the changes.
Regardless of the server used, you can use dynamic compilation by Starting the project without debugging (Shift + F5).
Due to architectural reasons, dynamic compilation does not work when starting with debugging (F5) in Visual Studio. This is due the fact that the difference between Shift + F5 and F5 is that in the latter, VS attaches the debugger to the process.
Will this every be supported in the future? That is unclear but right now because VS isn't "smart" enough to handle detaching from process, waiting for dnx to dynamically recompile, and then reattaching to the process. However until now it never had a reason to support such a scenario, so it is unclear if it is just a "it doesn't know how to do it yet" or a "it is impossible to do."
I can of course install IIS and create a site that is pointing to my
wwwroot but is that my only option in the ASP.NET world?
No. You can use any webserver which supports Microsoft.AspNet.Hosting. Today your choices are limited to IIS, IIS Express, and the two experimental servers you linked to but the goal is to enable third parties to develop alternatives by providing an interface that can be programmed against (Microsoft.AspNet.Hosting).
ASP.NET 5 has dynamic compilation but I'm not sure how to even test it
since my web server is only started when I'm in debug mode.
If the web application is running then the server is started. No webserver = no ASP.NET application. I assume by "debug mode" you mean "Start with Debug (F5)". If so then "Start without Debug (Shift + F5)" to fix the problem you're experiencing.
Here is an excercise:
Close Visual Studio (not a requirement but useful to show none of this is VS specific).
Start the web server. The easiest way would be dnx . web run from command line in the project root folder. You could however start IIS Express (should already be configured) or even configure the IIS and start it.
Verify the web server and web application is running by opening it in a browser.
Using notepad or some other text editor, edit a file in the project that would have a visible change or just force an error "throw new NullReferenceException()".
Save the file.
Refresh the browser.
The web application will reflect the change. You may notice a slight delay if you refresh quickly. That is the dynamic compilation to memory occurring.

Visual Studio .vshost causing exception

I'm making a chat program in Visual Basic. It's supposed to be for LAN, and it's called LANChat.
It starts a listener on port 65535 (just for now) and continues to listen on that port. However, if you tried to open two instances of it at once, there'd be a runtime error. I've handled that, and it shows a MessageBox and closes the program if it detects that the port is currently being used. However, in Visual Studio, when attempting to test the program, it runs the program as if it's already being run. I looked in task manager and I see "LANChat.vshost" is running at the time. Any ideas? The only idea I have is to comment out the exception handling code while testing.
Under your project properties > Debug you can deselect the 'Enable the Visual Studio hosting process'. This will take the hosting process out of the question, if it works then then hosting process was interfering somehow, if not then the problem lies elsewhere.
It would be better to create your progra as a single Instance program. Than you should avoid the vshost probme.
I've done it for myself and it works fine.
Sorry i cannot provide code, I am at home :(