Ossie
Ossie
CC#
Created by Ossie on 12/6/2023 in #help
Process Start without my Program being the "parent"
Hi, How can I use System.Diagnostics.Process.Start without my program being the "parent" program, I'd like it to launch "externally" like if the Process was opened manually by the user. Is this possible?
9 replies
CC#
Created by Ossie on 11/9/2023 in #help
❔ Execute code on WPF program close
Hi, is there a way I can execute some code every single time the application closes. Either if it crashes, is closed manually, the computer restarts, or closed thru task manager or whatever? For WPF
60 replies
CC#
Created by Ossie on 9/5/2023 in #help
❔ WPF Window click-thru/non-clickable
Hey, how is it possible to make a WPF Window click-thru/non-clickable. I don't want to highlight or click on it in any way. The window is for an overlay, so I needs to be uninteractable, so you don't click it accidently. I already tried the following without success: 1. Using SetWindowLong
[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

public const int WS_EX_TRANSPARENT = 0x00000020;
public const int GWL_EXSTYLE = (-20);

public static void MakeTransParent(IntPtr hWnd)
{
int extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
}
[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

public const int WS_EX_TRANSPARENT = 0x00000020;
public const int GWL_EXSTYLE = (-20);

public static void MakeTransParent(IntPtr hWnd)
{
int extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
}
This didn't work, and its still clickable for some reason. Is it because im trying to do it from inside the WPF windows own code? 2. IsHitTestVisible I tried setting IsHitTestVisible to false, both in the XAML and after instancing the window. Still clickable... Any help is appreciated, as I can't seem to find anything online that is not the methods listed above. Thanks
29 replies
CC#
Created by Ossie on 8/25/2023 in #help
❔ Making WPF window click thru / unclickable?
I have a overlay window, which is on top of some other programs, but right now, if you click on the overlay part on the window, it will try to focus the overlay and start blinking, and you will loose control of the program the overlay is on top off. So how do I make the overlay click thru or unclickable? Thanks
7 replies
CC#
Created by Ossie on 8/23/2023 in #help
✅ .EXE works in release but not publish?
Hi, I have a WPF application, and I have made some stuff with the notification area (system tray), I tried yesterday to do it with <UseWinForms>true<UseWinForms>, and everything worked perfectly when building with release. but when I build with publish, it doesn't work. And I know its because of the WinForms thing, since if i removed it, it launched fine. Then I found a nuget package today, which can do the system tray things, but now, again, it doesn't wanna run in publish, but it again runs just fine in release. I use the following settings in my PublishProfile:
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
This is my csproj:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Platforms>x64</Platforms>
<ApplicationIcon>henry.ico</ApplicationIcon>
<_SuppressWpfTrimError>true</_SuppressWpfTrimError>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Platforms>x64</Platforms>
<ApplicationIcon>henry.ico</ApplicationIcon>
<_SuppressWpfTrimError>true</_SuppressWpfTrimError>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
Is there some way I can debug it to figure out why it doesn't work, it is really pissing me off that it doesn't work when I publish it... but for some reason works when I build it for release
3 replies
CC#
Created by Ossie on 8/22/2023 in #help
❔ Minimizing WPF app to system tray?
Hey, Is it possible? I looked it up online but could only find very old things for win 7 and xp, and also nothing really for WPF mostly for win forms… Is it possible, if so how? 🙂 By system tray I mean the litlle arrow down besides the clock. Thanks
4 replies
CC#
Created by Ossie on 8/21/2023 in #help
[WPF] Creating grouped content in XAML to hide.
Hi, Is it possible to group multiple UI elements into a group, and then hide the entire group, while also being able to access each individual elemt of the group. This is just pseudocode of what I wish to achieve:
<Group Name="Group1">
<Element1 Name="Ele1">
<Element1 Name="Ele1">
<Element1 Name="Ele1">
</Group>
<Group Name="Group1">
<Element1 Name="Ele1">
<Element1 Name="Ele1">
<Element1 Name="Ele1">
</Group>
Then from C# I can do something like
Group1.Visibility = Visibility.Hidden;

// or

Ele1.Text = "Whatever";
Group1.Visibility = Visibility.Hidden;

// or

Ele1.Text = "Whatever";
Hope this is possible, so I don't have to hide each element individually. Thanks
3 replies
CC#
Created by Ossie on 8/18/2023 in #help
❔ Overlay on other Windows from WPF
Hello 🙂 Is it possible from WPF to make a overlay over another window. I wanna show some information over another window on the computer from my WPF application, and was wondering if its possible, and if so how? Thanks
340 replies
CC#
Created by Ossie on 8/14/2023 in #help
❔ Embed images within .exe [WPF App .Net 6.0]
Hey, I have some Images that I would like to use within my app, how do I have them embedded within the .exe, I tried to do
<Content Include="Images/*.*"/>
<Content Include="Images/*.*"/>
But, then it tries to get the images from the build output/images/theimage.png How do I have them within the .exe, I was able to do this in older version of WPF Thanks
59 replies
CC#
Created by Ossie on 8/13/2023 in #help
System.IO.FileLoadException
System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)' That is the error I'm getting, I read online something about it being two packages being dependant on different version, but I have the
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
Setup in my App.config, so I don't see why it gets mad... Reference to what I read: https://stackoverflow.com/questions/62764744/could-not-load-file-or-assembly-system-runtime-compilerservices-unsafe It seems to be System.Text.JSON which is mad for some reason
1 replies
CC#
Created by Ossie on 8/13/2023 in #help
✅ Good obfuscators for protecting .NET WPF Application?
Hello, I have my my own small WPF Application, and I have noticed I can just open it up in something like DotPeek, and get the full source code back, is it possible to prevent this some other way than obfuscation? If not, what are some good obfuscators, I looked at some applications, which seem to make everyone across a lot of classes, and then giving all variables weird names etc. but, not sure which obfuscator do this. Thanks 🙂
8 replies
CC#
Created by Ossie on 1/6/2023 in #help
Shifting a List(int) to become 1,2,3,4,5...
Hi, If I have a List like this: 2,3,4,5 And I would like for it to become: 1,2,3,4,4 This should be done by taking from the higher numbers in the list shifting them to the left so they come in order like above, how would I do that?
85 replies
CC#
Created by Ossie on 10/20/2022 in #help
MySQL Connector Paramerts.AddWithValue, not working?
Hello, I'm trying to do a prepared mysql query, however it doesn't seem to wanna bind my values. My code is the following: https://sourceb.in/9gNZINmB4C It shows the follwing in my console with the debugs: https://i.imgur.com/AvlrWlV.png In my database it becomes like this: https://i.imgur.com/bSoRCD9.png Which tells me it doesn't bind my params to the SQL statement, am I doing something wrong? I tried following this: https://dev.mysql.com/doc/connector-net/en/connector-net-programming-prepared.html
3 replies
CC#
Created by Ossie on 10/7/2022 in #help
Index was out of range. How to check if list has items without triggering this error?
Hello, I have a list, with a list inside.
List<List<dynamic>> characterData
List<List<dynamic>> characterData
This is because I wan't to have 3 possible lists, with a list inside. However there isn't always 3 lists present. Sometimes it might only be 1 or 2 lists that are filled, and the last one is empty. My problem occurs when trying to check if the List has any value. This works fine if none of the lists have any value, by checking if characterData.Count > 0. However when this is not the case, I try to check if a value inside the list is NullOrEmpty, however this is causin the error Index was out of range. Which makes sense because the list doesn't exist, but how would I then check if the list itself exists inside the the other list? I hope this makes any sense, I will post a snippet. I would wanna check if characterData[i] exists, without getting an index error.
List<List<dynamic>> characterData // This get its value from another place, not important

for (int i = 0; i <= 2; i++)
{
if (characterData.Count > 0)
{
if (!string.IsNullOrEmpty(characterData[i][0].ToString())) // This give me a error, so how do I check if the list has any values, I'm just checking the first value as it seemed logically to me
{
// Rest of my code
}
}
}
List<List<dynamic>> characterData // This get its value from another place, not important

for (int i = 0; i <= 2; i++)
{
if (characterData.Count > 0)
{
if (!string.IsNullOrEmpty(characterData[i][0].ToString())) // This give me a error, so how do I check if the list has any values, I'm just checking the first value as it seemed logically to me
{
// Rest of my code
}
}
}
Thanks, Ossie
63 replies
CC#
Created by Ossie on 10/3/2022 in #help
What does MySQLConnector return in a SelectQuery if nothing is found?
Question is in the title
3 replies