uselessxp
❔ Xamarin.Forms Android App problem using Application.Context.StartActivity(intent)
Hi, in short, I created a super small Xamarin.Forms Android App.
All I need is just to press a button, that will launch another application.
Then I immedaitely added the button in the myPage.xaml file in the shared Xamarin.Forms project.
About the myPage.xaml.cs file this is the code I binded to the button:
I defined the interface into App.xaml.cs (still shared project) using
Then I implmented it in the Android project by adding some code into MainActivity.cs
The problem is that every time I click the button, for some reason that I don't know, I always get error
System.NullReferenceException: 'Object reference not set to an instance of an object.'
4 replies
❔ Implement JWT to my WebAPI .NET 7.0 project - First time
guys I'd like to implement JWT into my WebAPI project, theory seems to be simple but I'm unable to implement it in my .NET 7.0 project, someone could help me or link me a reliable guide? I'm reading different but each of theme have differences in some points
10 replies
❔ WebAPI Cors problem when calling API from Frontend
Hi, I'm having the following code while trying calling my API from Frontend:
Access to XMLHttpRequest at 'http://localhost:5222/api/Users' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
For try to solve this I added a code in the Program.cs
with an exception, but I'm still having the same problem and I don't know in which other way could I solve.
I show you the code of Program.cs
I also tried to move the app.UseCors
between app.UseRouting()
and app.UseAuthorization()
with no results9 replies
❔ WebAPI .NET 7.0 - Encrypt connectionstring in appsettings.json
guys, I'm writing some WebAPI using .NET 7.0, and I'd like to secure the connectionstring with encryption, I found a guide that suggest to do it by using
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe
is it a good way or is something old?
currently the connectionstring is placed into appsettings.json
(not into web.config
) and this is its content:
4 replies
❔ C# WebAPI - how to make a field 'optional' ?
I'm creating some WebAPI, I'm starting from a get, for the retrieval of users from a DB.
I'm using .NET 7.0 and EntityFramework.
The form that make the search request can take in input those fields:
Database ID
User ID
FromDate
ToDate
Username
All fields must be optional, obviously at least 1 should be sent.
I wrote some code:
As I understood, in that way EF understand how should it works, and the statement should works without bugs.
I think I'll only have to add a check at the beginning, for make sure that at least 1 field is sent.
Anyway when I test the API and I put only 1 field, for example dbId
I get Error 400
as response, The username field is required
I suppose that's why I never declared anywhere when the parameter is optional, and when not, since I just defined the code that have to be executed after a correct request is sent.
Browsing on the web I found some guides that suggest to add [Required]
tag on mandatory fields, inside the model.cs making the rest being optional, but this seems not working.
Other guides suggest to set all parameters to null
by default, or at least setting the FrontEnd to work in this way.4 replies
❔ ✅ send notification on an iPhone
guys is there on C# to send somehow a notification on an iPhone?
I found pushbullet but it's not available on iOS :/
an alternative could be to make something with Telegram.
what do you think? is there an easier way?
24 replies
❔ embed and unity app/game and interact with it
guys someone know how could I implement an unity app in a C# app?
I mean, I'd like to login to an unity app/game and be able to interact with it through C# for create stats, calculations, and make some automations.
in this specific case, there's also a browser version, maybe it could simplify, but I don't have idea on how to make C# able to recognize objects, starting from read values.
maybe a bit of reverse engineering will be needed.
any hints?
15 replies
❔ best way to store and handle Settings/Config of an app
I realized a little tool and I'd like to create a Settings/Configuration system for store some info, example I have several
and I'd like to put them in a .ini or whatever file, so I can edit them without having to edit the source code
I found few packages I think could works for the purpose:
Serilog.Settings.Configuration
215.4M downloads
Microsoft.Extensions.Configuration.Ini
47.6M downloads
I don't know if they are good and if there exist better stuffs204 replies
❔ recommended FTP library/nuget?
Well, I need to to a task via FTP:
- if exist delete a folder with its content
- upload a folder with its files
I'm trying to to that using
FtpWebRequest Class
but it seems that's a bit limited, I'm still reading MSDocs and it seems that I can't delete a folder recursively, so I get the error "folder is not empty" when trying to delete143 replies
❔ Dapper - Call stored procedure error
I finished to write my first POST Api, but I get an error when I execute it and it call a stored procedure.
-$exception {"OUT or INOUT argument 1 for routine mydb.storedprocedure is not a variable or NEW pseudo-variable in BEFORE trigger"} MySqlConnector.MySqlException
ErrorCode StoredProcedureNotVariableArgument MySqlConnector.MySqlErrorCode
I checked all parameters, count and names, and they are ok, what am I forgetting?4 replies
✅ RestAPI getting an error while testing (TimeSpan related)
I thought to have solved this, but it's not.
As title, I'm testing some written RestAPI (still in development) for a service.
The project is in .NET 7.0
There are few fields to type plus a field that will put in a DB hours and minutes, example 10:00
Well, in the model definition I have this:
Well, when I launch the debug, and it open Swaggler, I type all fields, and finally I have to write this TestHour.
I tried with:
- 10:00
- 10:00:00
- 360000000000
- 360000000000, 0, 0
None of those worked, and I get the following error from Swaggler:
The JSON value could not be converted to System.TimeSpan
Someone knows what could be?
Am I doing something wrong, or maybe something doesn't works with this .NET ver?49 replies
❔ best way to include and works with images
I'm working on a project, and I'll have to work with several images.
Actually the project is working with:
Is there a way to improve this?
I'm not referring to the fact I'm using path of my PC, but I'd like to make it more elegant.
Regarding the path I could put images on a project subfolder, adding them as resources, changing the extension with a random one, so final users will not know they are simple .png
But are there other solutions?
I read about the ability to convert an image to a string, using bitmaptostring.
What do you think about?
2 replies
✅ WPF - Detect if screen resolution is resized (ex. 125% or more)
I'm writing a tool in which I need to first set the screen resolution, I currently have a 1920 x 1080, but I noticed that if in Windows screen resolution I enable the automatic resizing to 125% (or more) the tool retrieve false values.
Ex. for 125% the software think that my resolution is: 1536 x 864.
Is there an easy way to detect if is this enabled, and maybe also detect the % value?
I'd like to make something like that.
Or better:
If it's possible it will be nice, if it's not possible or too hard to make I'll go to ask to the user those data.
5 replies
✅ ConsoleApp - run the .exe by cmd and catch given parameters
Well, as a little task I'm trying to code a ConsoleApp that should base64 encrypt an input string and automatically copy it to the clipboard.
The ideal result is the following, by cmd:
-
-base64.exe -e string (for encrypt)
- -base64.exe -d string (for decrypt)
First of all I played with encoding/decoding and I figured out that I have to convert the input string into a byte (array?), then after I can apply the method that convert to base64.
I succesfully "wrote" the encrypt method, now something I don't know how to do, it to catch one or more parameter, I don't know how is technically called this, I'd have googled it.
But what I finally understood, is the meaning of:
I always wondered which is the sense to write string[] args
if the program works perfectly without arguments, and now I know that the meaning of this is somehow to accept and handle cmd.exe parameters as arguments.48 replies
❔ which is the key for write a good code? my 1st exercise of advent of calendar
Problem: https://adventofcode.com/2015/day/1
My code:
Do you think I wrote a good code?
I could reduce code row number by deleting some var declarations like floorUp and floorDown but maybe it's not the right way.
10 replies