Ruttie
Conflicting System dlls
I have project that has
DisableImplicitFrameworkReferences
and NoStandardLib
enabled and references custom mscorlib
and System.*
dlls.
However, when I add a package like this:
I get a compile error because the compiler could not choose between the default System.dll
and the custom one.
How might I fix this issue?
Using <ExcludeAssets>runtime</ExcludeAssets>
works, but I need the MonoMod.exe
created by the MonoMod
package...
Thanks in advance for any help.42 replies
EFCore - When to save changes
I have an application that uses EFCore.
In this application, I have a method that gets some values from the database, and may or may not change them based on some conditions.
How should I handle the saving of changes in this scenario?
I've thought of a few solutions:
- Meticulously try to only call SaveChanges if a values was changed (for example by having a local change boolean)
- Simply always call SaveChanges at the end of the function
- A hybrid approach, call DbContext.ChangeTracker.HasChanges() and only call SaveChanges if this returns true
What would be the best approach of these? (alternate approaches are also welcome)
5 replies
Files not copying to output directory - Linux
I have the following in my csproj:
however, when using
<Exec WorkingDirectory="@(BuildDir)" Command="$(Mono) MonoMod.exe TestDll.dll" />
in one of my PostBuild targets, it fails saying that MonoMod.exe does not exist.
Why does this happen?2 replies
Source generators VSCode
I'm using VSCode on linux, but it seems like source generators do not work...
In specific, the resx generator.
It just does not generate the .Designer file.
Is there a way to fix this? Are source generators not supported in VSCode?
4 replies
duplicate key error efcore
I'm trying to use efcore but I'm getting a
duplicate key value violates unique constraint "PK_Tags"
error.
My model contains:
however, this is not a key?
I'm updating the value by getting it from the database, modifying it, then calling Update with the modified value.34 replies
Ensure folder can be read/written to by current user, even if program is admin
I want to ensure that a folder I create is fully accessible by the current user.
I'm afraid that if the user runs my program as admin, the folder and its files will be created as the root user, and they will become inaccessible to other programs that are not running as admin/sudo.
How can I make sure they can access it?
10 replies
❔ ThreadStatic for tasks
I need something that acts like ThreadStatic, but for async/await code.
In my case, I need to set a context value.
For example, in ASP.NET I want to set the HttpContext to have a value I want to access later, but only from this task and its children.
How might I do this?
3 replies
❔ Better user experience inputting commands
How would I get input from a user, the fancy way?
What I mean is that for example when a user types 'could you run {appname}?' that it runs the application.
I want a project of mine to be like talking to the program instead of executing commands
6 replies
❔ Analyzer trouble
This is my first time creating a C# analyzer, and I had the following question:
I want to prevent users from creating and executing code in new threads in an event handler of an event that has a
SyncOnly
attribute.
Does anyone know how I might do this?4 replies
✅ EntityFrameworkCore lists
This has probably been asked before, but is it possible to store a
List<T>
in a npsql database using EntityFrameworkCore?
If so, how would I go about it?
(For context, I have a DbSet<Guild>
, and I want the model to store data on guilds, and one of the things I want to store is a collection of tags)4 replies
✅ Source Generator, dynamic assembly not added.
I have the following code:
When trying to compile a project that references the source generator, I get a
CS0103
, saying "The name 'MyType' does not exist in the current context".
Any ideas on how to fix?11 replies
✅ `??=` and `??`
This question may not fit here because it is not a question about C# but more about why it is implemented in such a way, but I'll ask anyways:
Why is
item ??= item2
implemented as
instead of
?
The cast makes it so if the ==
operator is changed by the class, it will not use said operator, instead using the default ==
operator of object
.
This makes it so that in unity for example, where the ==
operator is changed by all unity objects, the ??=
operator cannot be used.
My other question is, does the ??
operator also cast to object
before null checking, or does it use something else completely, like pattern matching? I've used https://sharplab.io to see the lowering of ??
, but it doesn't appear to be lowered.66 replies
❔ Making two dlls interact
This is a bit of a weird question, but...
I have a .net 4.7.2 dll which is loaded by a different program.
I also have a .net 6/.net 7 executable that needs to be able to call functions and such from said .net 4.7.2 dll.
Is there any way to achieve this?
I can give more information if needed.
2 replies