!Rushaan
!Rushaan
CC#
Created by !Rushaan on 6/5/2024 in #help
AspNetCore Null Exception
No description
7 replies
CC#
Created by !Rushaan on 4/30/2024 in #help
Unable to import models in service interface
Hi im learning Dependency Injection for the first time and making a micro-project to try it out. But I have a model class in my main project and a class from that model is needed in the service interface however im unable to import the model class in the interface.
namespace ASPNETCoreLearn2.Models
{
public class CityWeather
{
public string CityUniqueCode { get; set; }
public string CityName { get; set; }
public DateTime DateAndTime { get; set; }
public int TemperatureFahrenheit { get; set; }
}
}
namespace ASPNETCoreLearn2.Models
{
public class CityWeather
{
public string CityUniqueCode { get; set; }
public string CityName { get; set; }
public DateTime DateAndTime { get; set; }
public int TemperatureFahrenheit { get; set; }
}
}
using ASPNETCoreLearn2.Models; //TYPE OR NAMESPACE COULD NOT BE FOUND
namespace ServiceContracts
{
public interface IWeatherService
{
public List<CityWeather> GetWeatherDetails();
}
}
using ASPNETCoreLearn2.Models; //TYPE OR NAMESPACE COULD NOT BE FOUND
namespace ServiceContracts
{
public interface IWeatherService
{
public List<CityWeather> GetWeatherDetails();
}
}
I can import ServiceContracts in ASPNETCoreLearn2 but i can't do vice-versa even though ive properly added the project dependencies.
21 replies
CC#
Created by !Rushaan on 3/28/2024 in #help
button background not changing wpf
I have a very simple but extremely annoying issue, ive assigned 4 buttons with the same mouse enter event and trying to change their background/foreground/border brush AND NOTHING IS CHANGING IT JUST STAYS THE SAME AS WHENEVER BUTTON IS NORMALLY HIGHLIGHTED! im 100% sure the event is triggered though as i checked
<Button Name="Option1" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Margin="0 13 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/cdpr.png"></Image>

</Button>
<Button Name="Option2" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Margin="0 90 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/c.png"></Image>
</Button>
<Button Name="Option3" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Grid.RowSpan="2" Margin="0 140 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/w.png"></Image>
</Button>
<Button Name="Option4" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Grid.RowSpan="2" Margin="0 190 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/g.png"></Image>
</Button>
<Button Name="Option1" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Margin="0 13 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/cdpr.png"></Image>

</Button>
<Button Name="Option2" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Margin="0 90 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/c.png"></Image>
</Button>
<Button Name="Option3" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Grid.RowSpan="2" Margin="0 140 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/w.png"></Image>
</Button>
<Button Name="Option4" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave" Background="Transparent" BorderBrush="Transparent" Grid.RowSpan="2" Margin="0 190 0 0" Padding="5 0 5 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Images/g.png"></Image>
</Button>
private void Button_MouseEnter(object sender, RoutedEventArgs e)
{
if (sender is Button button)
{
button.Background = Brushes.Pink;

Console.WriteLine("BUTTON ETNEENTTERR");
}
}

private void Button_MouseLeave(object sender, RoutedEventArgs e)
{
if (sender is Button button)
{
button.Background = Brushes.Transparent;
}
}
private void Button_MouseEnter(object sender, RoutedEventArgs e)
{
if (sender is Button button)
{
button.Background = Brushes.Pink;

Console.WriteLine("BUTTON ETNEENTTERR");
}
}

private void Button_MouseLeave(object sender, RoutedEventArgs e)
{
if (sender is Button button)
{
button.Background = Brushes.Transparent;
}
}
the only thing i can change about the button is isHitTestVisible
16 replies
CC#
Created by !Rushaan on 2/28/2024 in #help
Out of memory error
Using AForge.Video.DirectShow to integrate a QR Code scanner in my WPF App but whenever the scanner is open it crashes in 15 seconds due to out of memory error as it reaches 4gb memory usage and I'm not able to exactly pinpoint the reason why its happening, BitmapToImageSource() throws the out of memory error. https://pastebin.com/XjsE9BuJ
19 replies
CC#
Created by !Rushaan on 2/25/2024 in #help
Library e_sqlite3 not found
I'm trying to use sqlite database in my WPF .NET 4.7.2 Framework project using Microsoft.Data.Sqlite but I'm getting an error: Also e_sqlite3 is not present in Debug folder
System.TypeInitializationException: 'The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.'

Exception: Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
1) C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
2) C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\e_sqlite3.dll
win TryLoad: C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
win TryLoad: C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
NOT FOUND
System.TypeInitializationException: 'The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.'

Exception: Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
1) C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
2) C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\e_sqlite3.dll
win TryLoad: C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\runtimes\win-x86\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
win TryLoad: C:\Users\rusha\Source\Repos\QRCodeApp\QRCodeApp\bin\Debug\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
NOT FOUND
7 replies
CC#
Created by !Rushaan on 1/3/2024 in #help
Preventing TextBlock from getting deleted
I'm using a RichTextBox and setting some inline as TextBlock but the user is able to delete that textblock and i dont want that to happen, for some reason the inline returns Run type even if its a textblock, how do i see if its a textblock and prevent deletion
private void richTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Back || e.Key == Key.Delete)
{
TextPointer caretPosition = rich.CaretPosition;
if (caretPosition != null)
{
TextPointer prevCaretPosition = caretPosition.GetNextInsertionPosition(LogicalDirection.Backward);
if (prevCaretPosition != null)
{
Paragraph paragraph = prevCaretPosition.Paragraph;
if (paragraph != null)
{
Inline tb = paragraph.Inlines.LastInline;
if (tb != null)
{
Trace.WriteLine(tb.GetType().ToString());
}
}
}
}
}
}}
private void richTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Back || e.Key == Key.Delete)
{
TextPointer caretPosition = rich.CaretPosition;
if (caretPosition != null)
{
TextPointer prevCaretPosition = caretPosition.GetNextInsertionPosition(LogicalDirection.Backward);
if (prevCaretPosition != null)
{
Paragraph paragraph = prevCaretPosition.Paragraph;
if (paragraph != null)
{
Inline tb = paragraph.Inlines.LastInline;
if (tb != null)
{
Trace.WriteLine(tb.GetType().ToString());
}
}
}
}
}
}}
1 replies
CC#
Created by !Rushaan on 1/2/2024 in #help
✅ Image source not being set with C#, WPF
I have a very basic C# statement but whenever it gets executed the image is not set and the image element disappears.
qrcode.Source = new BitmapImage(new Uri(@"/Images/scannn.png", UriKind.Relative));
qrcode.Source = new BitmapImage(new Uri(@"/Images/scannn.png", UriKind.Relative));
I have no clue why its not being set, the image is present in that directory, build action of the image is set to content and copy to output is set to copy always
31 replies
CC#
Created by !Rushaan on 1/2/2024 in #help
Grid not resizing its child elements WPF
No description
18 replies
CC#
Created by !Rushaan on 1/1/2024 in #help
A NuGet package broke my WPF code
Just after I downloaded NuGet package called IronQR my entire code broke and it says IntitializeComponent() and all other bindings to wpf xaml code does not exist. Help what do i do
3 replies
CC#
Created by !Rushaan on 12/27/2023 in #help
Trying to publish WPF App but getting error
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3162,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files\dotnet\sdk\5.0.411\MSBuild.exe" exists and can be run. [C:\Users\rusha\source\repos\WeatherApp\WeatherApp\WeatherApp.csproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3184,7): error MSB4028: The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. Object does not match target type.
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3162,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files\dotnet\sdk\5.0.411\MSBuild.exe" exists and can be run. [C:\Users\rusha\source\repos\WeatherApp\WeatherApp\WeatherApp.csproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3184,7): error MSB4028: The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. Object does not match target type.
I'm trying to publish a WPF C# application so that I get it's .exe but I keep getting that error. The command I ran was dotnet publish -c Release MSBuild.exe was not present in the folder give in error so from somewhere of Visual Studio folder I found MSBuild.exe and copy pasted it in that folder and still getting the exact same error.
34 replies
CC#
Created by !Rushaan on 12/26/2023 in #help
Error while trying to publish WPF Application
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3162,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files\dotnet\sdk\5.0.411\MSBuild.exe" exists and can be run. [C:\Users\rusha\source\repos\WeatherApp\WeatherApp\WeatherApp.csproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3184,7): error MSB4028: The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. Object does not match target type.
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3162,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files\dotnet\sdk\5.0.411\MSBuild.exe" exists and can be run. [C:\Users\rusha\source\repos\WeatherApp\WeatherApp\WeatherApp.csproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(3184,7): error MSB4028: The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. Object does not match target type.
MSBuild.exe was not present in the folder give in error so from somewhere of Visual Studio folder I found MSBuild.exe and copy pasted it in that folder and still getting the exact same error.. The command I ran was dotnet publish -c Release
1 replies
CC#
Created by !Rushaan on 12/25/2023 in #help
An event running every few seconds, want it to run only once
I'm making a WPF application and for that using GeoCoordinateWatcher but the GeoCoordinateWatcher event is supposed to run only once until I want it to run again, but it automatically runs every seconds and i have no idea why. The event name is SettingWeatherData Keep in mind im a beginner and dont have a lot of idea bout events & delegates https://pastebin.com/81UBJjPC
6 replies
CC#
Created by !Rushaan on 12/24/2023 in #help
✅ WPF TTS plays before text updates
mainText.Text = (string)reader.Value;
if (autoplayVar)
{
PlayTTS(mainText.Text);
}
mainText.Text = (string)reader.Value;
if (autoplayVar)
{
PlayTTS(mainText.Text);
}
The above code is inside a button click event. I want the mainText.Text to update before the TTS plays because when it starts playing the mainText.Text doesn't updates to reader.Value until the TTS has stopped playing
3 replies