Turwaith
Error MSB4018: The "Message" task failed unexpectedly
When building my asp.net app via a gitlab runner, I get the error
error MSB4018: The "Message" task failed unexpectedly.
This seems to be connected to some nuget packages, but I disabled every package except Microsoft.AspNetCore.OpenApi
and Swashbuckle.AspNetCore
. What else do I need to change that this error stops popping up? It seems to happen during the restore process.1 replies
Very weird params passing error to main Method
I have a tool to which I pass arguments via the command line. It is three arguments, the first one is a name, the second and third ones are paths. Now these paths can be such with spaces in them. So I pass them using double-quotes. Let's say I pass the following:
.\myprogram.exe SomeName "C:\Projects\My Project\src" "C:\Projects\My Project\src\bin\x64\SomeProgram.exe"
Now I would expect to receive
But what I get instead is
So the third argument does not get recognized correctly and is split at the space for some reason. I have tried everything. Using double quotes for all three arguments, using no quotes at all, escaping all possible characters... I just don't understand that behaviour.7 replies
ObjectDisposedException: Cannot access a closed Stream. I don't understand why it doesn't work.
I am receiving a pdf document via a http get request and I need to rescale the actual document size. For this, I have written the following method, using the itext7 nuget package:
With this code, I get a
ObjectDisposedException
with the message Cannot access a closed Stream
. The exception is thrown at the line
I don't understand why I get this exception. In an earlier version, I was using using
for both the PdfReader and the PdfWriter. But even after removing that, I still get this error.10 replies
Launching WPF Windows via code when wpf is not startup project
My solution consists of two project. One is a console application and is the startup project, the other one is a wpf project. The two projects communicate with each other using an interface. Now one method that is called via the interface launches the MainWindow of the wpf project. I know that wpf gui applications need to run on the [STAThread] and I know how to declare that, but it does not seem possible in my case. I have added the flag to literally every single method in the call stack that opens the MainWindow and it still threw me an exception saying it was not run on the STAThread. So that doesn't seem to work out. I then have tried calling it in a specifically declared thread, as you can see in the code block below. But then, as soon as I close the window and reopen it, it says
Cannot create more than one System.Windows.Application instance in the same AppDomain
. Don't I dispose the Application object correctly?
2 replies
Preventing SQL Injections with string based queries
I'm working with an SDK to execute queries in a mssql database. This SDK offers a method that is required to execute those queries, but this method only takes a string. And string based queries are damn prone to sql injection attacks. So I want to write a middle piece method that takes in a SqlCommand object in which I can set parameters and returns the assembled query as string. Please give me feedback on it:
30 replies
Nuget restore (via gitlab runner) fails at a specific package
I am trying to set up a windows gitlab runner to build and publish my WPF .NET Framework 4.8 project. My
gitlab-ci.yml
file looks as follows:
Now my project contains the following external packages:
- Microsoft.Toolkit.Uwp.Notifications/7.1.3
- PDFtoPrinter/1.5.0
- Serilog.Sinks.File
- Serilog
Now the runner can successfully restore all the package EXCEPT the first one (Notifications). I have even, as you can see, specifically added the package through the script. It definitely is available on the nuget source. On my local machine (Windows 11, Rider) there is not a single problem with restore and build.
Does anyone have any idea why my windows runner fails at restoring this specific package?8 replies
HttpClient does not return anything
I am currently writing a method that makes a GET request to a server. The code I'm using for that is
For the endpoint, I'm currently using Mockoon until the actual server is ready. Now my call does not return. It neither comes back with an actual response nor does it throw the TaskCanceledException which it should after timing out. I've let it run for over 2 minutes now and it never reaches the exception nor the if statement right below the call. How can that happen?
Mockoon logs the call and also seems to send something back, but this never arrives apparently.
I can use call the endpoint successfully using postman, so that can't be it...
28 replies
❔ AWS DDB and Lambda integration doesn't work
As mentioned in the title, I have created a DDB - Lambda - API gateway construct according to this tutorial:
https://hevodata.com/learn/lambda-dynamodb/
Now I have done everything according to the tutorial, except the name of the DB table and the fields inside this table. The API does not seem to work though when I test it from Insomnia.
Could somebody take a few minutes and look over the tutorial if something looks strange to you? Or build it yourself according to the tutorial to check if it works for you? I am just getting a 500 Internal Server Error back which could be literally anything. I wouldn't even have a clue what to google for...
It would really help me if someone who knows their shit around AWS could help me real quick here :)
2 replies
❔ Porting a mvvm based WPF application to WinUI 3
I am trying to rewrite a WPF application that is based on the mvvm pattern into WinUI 3. Now I already fail at the MainWindow.
In WPF, I usually don't have any content in the MainWindow, I only use it to fill in the views I then fill with content. I use
Window.DataContext
and Window.Resources
for that, as follows:
Now this seems not to work anymore in WinUI 3, as VS keeps telling me that Window
doesn't have these properties. How would I do that same thing in WinUI 3?7 replies
✅ WPF Window is too big when Height and Width are bound to a property
I have a simple WPF MVVM application where I want the code to be able to response to window size changes, so I bound Height and Width of the window to respective C# properties.
Now the designer shows the window in the correct size, but when I run the app, the window becomes a lot wider. The properties are never set except at their declaration. When I replace the height and width bindings with fixed values in the xaml, it works. How do I get this working using those bindings?
43 replies
❔ Deploying a Blazor WebAssambly app.... but how??
I'm about to finish a front end that I have written in Blazor Wasm. Now I want to deploy it, so that I have a neat little folder with index.html in it as well as css, js, and pages folder. Just like if I'd built in in HTML and JS from scratch. Like your standard folder and file structure to host it on any simple webserver. Now I have tried using the Publish tab and published it to a folder. I've also tried using the console. But I only get some css and an index.html in that resulting folder that does nothing.
None of my created pages are there.
What am I doing wrong? I have not changed any project structure since creating the project from a wasm template
99 replies
FizzBuzz as short as possible
With a little help from StackOverflow I came up with this:
Now it adds only one element though, which is
"System.Linq.Enumerable+SelectRangeIterator'1[System.String]"
. How do I get this expression to have one list object for each number?4 replies
WPF - Canvas does not respond to key press anymore
I have an application where I can click on a canvas and when I hit the Enter key, a polygon is drawn with my clicked locations as corners. I do work with MVVM, so everything is using
{Binding ...}
. I catch both the mouse click and the key press via Interaction.Triggers
. Now, next to my canvas are a few buttons. They do not have any functionality yet, there is no command binding so far on those buttons. Now everything works fine, until I click one of those buttons. Let's say I draw a few polygons on my canvas, then I start drawing a new one (by clicking on the canvas). When I now click on one of those yet-functionless buttons and then want to hit enter to draw the polygon on the canvas, the key pressed is no longer recognized.
I can keep clicking on the canvas and it does recognize the mouse clicks, but the enter key just won't work anymore. It doesn't call the command that was bound to the key press.
Why is that and how do I solve that? I'm losing my mind.3 replies