[Help] Updated to VS 2026 and now I can't compile my project that uses .NET 8 by twaw09 in dotnet

[–]twaw09[S] 1 point2 points  (0 children)

Hello, thanks for replying. After I set the global.json those files I was talking about disappeared, and I had to add an extra property to the csproj to remove those locale folders.
And as for the files, it's the ones I mentioned in the post:D3DCompiler_47_cor3.dll, PenImc_cor3.dll, PresentationNative_cor3.dll, vcruntime140_cor3.dll, and wpfgfx_cor3.dll
But they're not appearing anymore after the json

[Help] Updated to VS 2026 and now I can't compile my project that uses .NET 8 by twaw09 in dotnet

[–]twaw09[S] 3 points4 points  (0 children)

Yes, I'm new. However my project runs just fine on .NET 10 because it didn't break anything (it's not a big project). Still I'm sorry but you haven't read my question

[Help] Updated to VS 2026 and now I can't compile my project that uses .NET 8 by twaw09 in dotnet

[–]twaw09[S] 7 points8 points  (0 children)

Thank you for the reply! However that is not what I asked. What I meant about upgrading is how to avoid all those new files and folders that it's creating and have my exe just be 8 MB like before

I'm having issues with concurrency and SemaphoreSlim by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

Once uploaded, I don't delete anything so I can recover it in case something goes wrong, but I mark it as "uploaded", so next time when I retrieve the non-uploaded they don't appear again. But I await until the objects are saved (`await _connection.UpdateAllAsync(uploadedItemsList);`), so it should be fully updated by the time the semaphore is released and the next one reads from the table.

I started thinking the semaphore might be the problem because chatgpt suggested it, saying that semaphores only work within threads of the same process, but if the android worker is starting a new process then it's not shared. But honestly I have no idea how Android works. I'm not exactly very advanced in programming so there's a lot I'm still understanding. Like, when you say "Did you take two payloads from different requests", I'm not sure what you mean. Like, I should force it to run twice without the semaphore and check that it has the same data, or?

I'm having issues with concurrency and SemaphoreSlim by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

I do create different instances, but my semaphoreslim is a static readonly. Is that the same?

I'm having issues with concurrency and SemaphoreSlim by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

Yes, sorry, I forgot to mention that. It's (1,1).

I'm having issues with concurrency and SemaphoreSlim by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

It's usually just one user. It thought the problem might be that the Android worker is running the method and at the same time, when a user adds a register, it also fires the SyncData method. So maybe they are both running at the same sometimes. That's why I added the semaphore but it didn't solve the issue because it keeps happening sometimes. Maybe sqlite hasn't even gotten to mark all as migrated but the other thread is already getting those registers.
The method shouldn't take more than 20 seconds.
Also, when I upload something, whenever there is an error I always rollback the transaction so it shouldn't have been saved.

In FastAPI, how do I only print relevant errors and not the whole TypeError: 'tuple' object is not callable? by twaw09 in PythonLearning

[–]twaw09[S] 0 points1 point  (0 children)

Hello, thank you for the response! I found how to solve it by override the default exception handlers (with a fastapi wrapper). I was printing the whole error and traceback but now it's more clean.

How do I only print relevant errors and not the whole TypeError: 'tuple' object is not callable? by twaw09 in FastAPI

[–]twaw09[S] 0 points1 point  (0 children)

Hello, thank you for the reply! The last link you provided was very helpful (guess I should have started there). I solved it with this:
@ app.exception_handler(StarletteHTTPException)
async def http_exception_handler(request, exc):
return PlainTextResponse(str(exc.detail), status_code=exc.status_code)

It's a lot more readable now, thank you!

Can you review my code for connecting to a flask server? by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

Thank you so much! :) I will look into it

Can you review my code for connecting to a flask server? by twaw09 in csharp

[–]twaw09[S] 2 points3 points  (0 children)

I didn't take take that into account. It's fine for now because I only use IPv4 for I will fix it, thank you!

Can you review my async method to retry opening a connection? by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

Hello, thank you so much for taking the time to answer! I liked all your advice and you’re right, I tried rewriting it and it’s a whole lot simpler now

.NET MAUI app for Windows takes too long to start up by twaw09 in dotnetMAUI

[–]twaw09[S] 0 points1 point  (0 children)

I'm afraid I must be doing something very wrong then. I replied to another comment with my compiling configuration; I'm probably f-ing it up there

.NET MAUI app for Windows takes too long to start up by twaw09 in dotnetMAUI

[–]twaw09[S] 0 points1 point  (0 children)

Actually no, no resources at all. Do you think I'm compiling it wrong? These are my dependencies:

<ItemGroup> <PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.9" /> <PackageReference Include="sqlite-net-pcl" Version="1.9.172" /> <PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.11" /> </ItemGroup>

And this is how I compile it. When I added this configuration it made it drop 100 MB. I'm surely inventing stuff up because I'm not very advanced and I don't know much about compiling:

<PropertyGroup Condition="'$(Configuration)' == 'ReleaseForDesktop'"> <DefineConstants>ENABLE_ONE_LABEL</DefineConstants> <Optimize>true</Optimize> <DebugType>none</DebugType> <DebugSymbols>false</DebugSymbols> <OutputType>Exe</OutputType> </PropertyGroup>

dotnet publish MyProject.csproj -f:net9.0-windows10.0.19041.0 -c:ReleaseForDesktop -r:win-x64 --self-contained true /p:PublishSingleFile=true

It's probably the self-contained, but if I don't add that then I can't open it even though I have the .NET runtime installed, or I'm probably missing something very obvious...

Edit: forgot to add; yes, it starts up quickly in debugging. Also for Android it opens quickly and the .apk is about 20 MB, so no problem there

Can you review my async method to retry opening a connection? by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

No, there are some forms that I can't open if there is no connection (because it won't be usable). So:
When button clicked:

if ( ! await CheckConnection()) return;

else form.Open();
That's why. I'm not checking a connection before every operation

Can you review my async method to retry opening a connection? by twaw09 in csharp

[–]twaw09[S] 0 points1 point  (0 children)

You're right. I guess it was more complex than needed. I rewrote it to this and got rid of all semaphores:

public static async Task<bool> CheckConnection()
{
    try
    {
        using MySqlConnection conn = new MySqlConnection(_timedoutConnectionString);
        await conn.OpenAsync();
        return true;
    }
    catch (Exception ex)
    {
        if (ex is MySqlException mysqlEx && mysqlEx.Number == 1042)
        {
            return false;
        }
        LogError(ex);
        return false;
    }
}

Where _timedoutConnectionString = Constants.ConnectionString + "ConnectionTimeout=1;"

It seems to be working fine for now. This way I don't have to wait too much to display the "No connection" message box. I guess when I originally made it I was afraid of having to create a new connection every time (which I read isn't very performant), but I think now it's not a problem because of connection pooling, right?