Sal
Sal
CC#
Created by Sal on 4/12/2024 in #help
Maui issues after changing namespace
yesterday I had the briliant idea of changing the name of my app because i made it open source and previously was just a "personal" name, but anyway the issue is that visual studio now says that doesnt recognise "Maui" "Application" "MainPage" etc this part mostly started to appear when i changed the namespace on the xaml files "x:Class" but before there were issues mainly this
Error NU1105 Unable to read project information for 'Invasion1DGame': Sequence contains more than one element Invasion1DGame
Error NU1105 Unable to read project information for 'Invasion1DGame': Sequence contains more than one element Invasion1DGame
I currently reversed the project to a commit ago but the issue persists, I am not sure why because i just changed the name after committing. I tried AI to help but it repeats itself and nothing worked, i search for all instances of the previous name and and i had changed all, i cant clean and rebuild because it fails, i deleted .vs folder but i couldnt open the solution after had to open the project, but nothing made a difference. another error i got was regarding the manifest for android but i dont really know what to do in there. any help would be appreciated for reference https://github.com/Saleca/Invasion1DGame I didnt clone from the site so i hope the main branch is working fine, but that main should be the one i am currently having issues after reversing the commit, the problem with the new name is on the branch "ChangeRootNamespace" thanks either way
54 replies
CC#
Created by Sal on 11/26/2022 in #help
✅ What is better, in this case, Replace() or Substring()
In Unity it seems that text input comes with a 'Zero Width Space Character' at the end, and that messes with the following logic since a word with 5 characters has 6 characters and this ZWS character ain't accepted everywhere. Both of this solutions work fine to remove the character, but I am here asking if there is good reasons to use one or another? or even other way maybe even in unity settings to avoid that behavior.
string zeroWidthSpace = new(new char[] { (char)8203 });
name = name.Replace(zeroWidthSpace, "");
string zeroWidthSpace = new(new char[] { (char)8203 });
name = name.Replace(zeroWidthSpace, "");
or
name = name.Substring(0, name.Length-1);
name = name.Substring(0, name.Length-1);
103 replies
CC#
Created by Sal on 11/23/2022 in #help
❔ Destroy objects in CSharp, IDisposable
Hi, I am trying to get an object destroyed but it doesn't seem to be working. I implemented IDisposable interface and started by just adding the Dispose() method, without any "destruction" I tried as they show on the documentation (simplified as far as I understand).
bool disposed
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

private void Dispose(bool disposing)
{
if (disposed)
return;
}
bool disposed
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

private void Dispose(bool disposing)
{
if (disposed)
return;
}
I also did use the
using (var obj = new MyObject())
{
//some code
}
//check for obj
using (var obj = new MyObject())
{
//some code
}
//check for obj
and when I checked for the object it was there still any help with this?
9 replies
CC#
Created by Sal on 11/20/2022 in #help
❔ empty string not being recognized
string name = nameHolder.text;
if (String.IsNullOrEmpty(name))
{
name = "New Save";
}
string name = nameHolder.text;
if (String.IsNullOrEmpty(name))
{
name = "New Save";
}
I started with if(name == "") tried string.Empty but when give it an empty name, and in debug I can see its an empty string, the statement is always false. I am using unity, am I missing something obvious?
51 replies
CC#
Created by Sal on 9/12/2022 in #help
Pass a value on a click event
hey, i am populating a stack panel with values from a data base, and i would like to have a button to select that value and at its right another to remove it from the database, but the button to remove doesnt have any context from the value i wanna remove, so how would i go about to using a single click event to all remove buttons but still know the Id related to the button i pressed?
16 replies
CC#
Created by Sal on 9/11/2022 in #help
EF Migration error
hi, I am getting an error message, and I am guessing comes from the connection string Initial catalog that I named after the name of the project from lack of info in all the sources I looked into. i followed the documentation and added App.config with a connection string and also read the page for ConfigurationManager but no one seems to tell how to name the "initial catalog" . i am following the dotNet tutorial on EF ,if anybody could help me out i really appreciate, thanks
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(
ConfigurationManager.ConnectionStrings["myappnameDatabase"].ConnectionString);//line 19
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(
ConfigurationManager.ConnectionStrings["myappnameDatabase"].ConnectionString);//line 19
}
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="myappnameDatabase"
connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=myappname;Integrated Security=True;" />
</connectionStrings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="myappnameDatabase"
connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=myappname;Integrated Security=True;" />
</connectionStrings>
</configuration>
on package console
PM> Add-Migration InitialCreate
Build started...
Build succeeded.
System.NullReferenceException: Object reference not set to an instance of an object.
at myappname.Data.myappnameContext.OnConfiguring(DbContextOptionsBuilder optionsBuilder) (...) :line 19
PM> Add-Migration InitialCreate
Build started...
Build succeeded.
System.NullReferenceException: Object reference not set to an instance of an object.
at myappname.Data.myappnameContext.OnConfiguring(DbContextOptionsBuilder optionsBuilder) (...) :line 19
35 replies