Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
89 views

I am extending my C# J2K library to dynamically register codecs from other assemblies. That part is working, but I am having trouble understanding IsAssignableFrom(TypeInfo) and how I can deduce which ...
Cinder Biscuits's user avatar
0 votes
2 answers
73 views

I'm currently working on a console application that essentially mimics an ASP.NET Web API. Everything was going smoothly until I ran into an issue regarding route attributes. What I'm trying to ...
Mateusz's user avatar
0 votes
1 answer
98 views

I use .NET 9 and blazor, ASP.NET Core Identity - role, policy, claim. To differentiate access on pages and components, the code is using policies - like this: @attribute [Authorize(Policy("...
kocapb's user avatar
  • 1
-1 votes
1 answer
70 views

I got tired of dealing with properties and fields separately so I made a VariableInfo strategy pattern to handle both without having to know what type it is. You feed the context a FieldInfo or a ...
A person's user avatar
2 votes
1 answer
265 views

The short of it is that I got tired of dealing with properties and fields separately. I made a VariableInfo strategy pattern to handle both without having to know what type it is. You feed the context ...
A person's user avatar
2 votes
0 answers
47 views

Is there a way to use reflection to programmatically inspect and determine if a given compiled cmdlet requires elevation? Notes: This question concerns compiled cmdlets, not script (text) files. ...
Paul π's user avatar
  • 585
0 votes
1 answer
86 views

PROBLEM TO SOLVE I'm trying to create a mock of interface ISomeService using Moq library which will wrap its real implementation SomeService. Right now I'm doing this manually like this: var instance =...
Arthur's user avatar
  • 201
3 votes
1 answer
126 views

I need some way of constructing a function pointer type that points to a specific function signature. So something like this: Type[] args = [typeof(int), typeof(int)]; // Pointer to (int -> int) ...
Jonas _'s user avatar
  • 172
-1 votes
2 answers
135 views

My class looks something like this: public class Test { public A[] ArrayA { get;set; } } public class A { public string P1 { get;set; } public int P2 { get;set; } } Suppose I have two ...
Shao Skywalker's user avatar
2 votes
2 answers
186 views

using System; using System.Runtime.InteropServices; using System.Reflection; public struct StructCreatedByUser { public int x; public float anything; public string name; } class Program { ...
Bilal's user avatar
  • 31
1 vote
1 answer
123 views

Preamble: I was looking at how best to implement a general-purpose decorator in C# that copes with async methods. Most examples use DispatcherProxy, which only offers a synchronous Invoke. Unless NET ...
naviwhack's user avatar
  • 127
2 votes
2 answers
139 views

I need to invoke a given DynamicObject with a given array of arguments. However, I am struggling on how exactly to do this. What I would like to do: using System.Dynamic; using System.Reflection; ...
user avatar
0 votes
2 answers
71 views

Given the following sample POCO class: public class TestClass { public int Id { get; init; } public TestClass() {} } How can I initialize the Id property using Reflection? The result should ...
AxD's user avatar
  • 3,282
-2 votes
2 answers
141 views

I want to activate, via reflection automatically and recursively all the nested classes inside a class I am instantiating. Here is the template of what I am trying to do, but I do not know how to make ...
Jada's user avatar
  • 25
0 votes
3 answers
202 views

I have a class called Department which contains some constants, I need a method to check if a given value exists in this constants list. public static class Department { #region Public Constants ...
Sandy's user avatar
  • 231
0 votes
1 answer
100 views

I have several (very old and code frozen) VB.Net class libraries that have dozens of classes derived from a single base class, cBaseRow. The subclasses are mostly collections of properties that call ...
Maury Markowitz's user avatar
1 vote
0 answers
64 views

I know AppDomain.GetAssemblies can be used to get all loaded assemblies of the current app but there is no guarantee of order remarked there. I need that list but also need to make sure that ...
Luke Vo's user avatar
  • 21.6k
0 votes
0 answers
143 views

In my ASP.NET Core 8 project, I added a reference to a nuget package containing the following controller: public class ShoppingCartController : Controller { // ... [HttpGet] [Route("...
DotCat1985's user avatar
1 vote
1 answer
59 views

I want to get all property names in a class and list(of class) in deep hierarchy. I can get property names of Address and Address.Floors but with Address.Floors.Peoples I get an error that the object ...
Hans's user avatar
  • 68
1 vote
0 answers
48 views

synopsis It's been a long time since writing VB.NET code and since then .NET CORE has been created and grown. So quite some time. And programming practices and patterns have evolved without my keeping ...
periblepsis's user avatar
0 votes
2 answers
161 views

I am attempting to use System.Reflection to modify values in a generic dictionary in which I do not know the types of the IKey and IValue. I am able to set the values of the Dictionary.Entry.value ...
devopsdinosaur's user avatar
0 votes
1 answer
79 views

I have below fields in my class [JsonProperty("LTR-AMT-1")] public string? LTRAMT1 { get; set; } [JsonProperty("LTR-AMT-2")] public string? LTRAMT2 { get; set; } [JsonProperty(...
Prajwal MR's user avatar
0 votes
0 answers
98 views

This question is a follow up on Unhandled exception: System.IO.FileNotFoundException: The file or assembly "System.Private.CoreLib" could not be found in custom generated assmbly. I ...
Noraa Junker-Wildi's user avatar
2 votes
1 answer
1k views

I believe I've exhausted the answers and comments on SO related to this topic. Full source code for the project I used to demonstrate the problem can be found here: https://github.com/jchristn/...
joelc's user avatar
  • 2,841
0 votes
1 answer
78 views

I have a .NET assembly that I retrieve from a service that gets put into a byte[]. I then load this assembly using reflection. Despite this being successful, PowerShell will give an error saying it is ...
Dave's user avatar
  • 2,661
0 votes
0 answers
33 views

so i have an object "Tabs" that i would to read the properties of. in this case, we have a count of 3, so there are 3 tabs. specifically trying to get the HeaderText property of the very ...
abc123's user avatar
  • 51
2 votes
0 answers
138 views

In C# 11, the new file type modifier was introduced. I was looking for a way to detect such non-public type using reflection, however, I have not find any "good" way to do so. There is no Is…...
Matt Stuvysant's user avatar
3 votes
1 answer
165 views

The scenario: We wrote a small program, let's call it MyLittleProggy.exe, that can be launched and it will continue to run, basically just idling. MyLittleProggy.exe contains a public class Class1 Now ...
DinahMoeHumm's user avatar
0 votes
1 answer
63 views

I am generating a proxy dynamically in C# to wrap over a derived type from an interface, intercepting the methods from the interface and calling another method with the intercepted parameters. My ...
Alecu's user avatar
  • 2,708
0 votes
0 answers
56 views

I use the Assembly.LoadFrom(dll) method to load the assembly with tests and get a list of tests in the project from it public IEnumerator<string> GetEnumerator() { Assembly.LoadFrom(...
Marat Tim's user avatar
0 votes
1 answer
80 views

I am using reflection and dynamic expressions to auto-populate a class and all its properties with fake data using bogus, my code looks like: static Faker<T> AutoInferRules<T>() where T ...
Ismail's user avatar
  • 993
1 vote
1 answer
88 views

The EventHandlerType property of the System.Reflection.EventInfo class is declared as returning a nullable Type?: EventInfo.EventHandlerType Property public virtual Type? EventHandlerType { get; } ...
ChrisW's user avatar
  • 56.4k
0 votes
0 answers
118 views

Hopefully I explain this well enough. When I try to access a dll I created (I access this dll via reflection)I get an error at a certain point saying its "deactivated". I can run code from ...
Eugene Paul's user avatar
-1 votes
3 answers
701 views

I refactored the code and added comments to make it clear. See pic of code and result UPDATE: I know the info I provided was a bit flawed so I edited the question. Nevertheless, how does one get the ...
BMET1's user avatar
  • 21
0 votes
1 answer
92 views

I am trying to retrieve attribute information from the Identity User Model. Data in the User model either came from a database or API and here is the From the controller, I am retrieving data by ...
Nurat Jahan's user avatar
1 vote
1 answer
259 views

I have this code which tries to load all assemblies in a folder and then for each assembly, also check if all of its dependencies too can be found in the same folder. private static string ...
Very Professional Username's user avatar
0 votes
2 answers
392 views

I know how to use the System.Reflection API, but not how to parse IL (Intermediate Language), though I do know how to parse x86 opcodes for what that's worth. Now I want to find all the methods in an ...
ChrisW's user avatar
  • 56.4k
-2 votes
1 answer
145 views

I'm trying to avoid code duplication by having a function in a base class that creates a list of properties which implement a specific interface. When I call the function it doesn't work as I hope. ...
Jase99's user avatar
  • 35
-1 votes
1 answer
79 views

I have a class which was derived from base class. To make some manipulations with it in unit tests I would like to change some protected properties with reflection. But when I'm trying to do this I ...
Snail's user avatar
  • 109
1 vote
1 answer
57 views

I want to add value to a value I got through reflection. The += does not work and SetValue does not fit my needs. * Instance.Field does exist but this would not be good for my script(For reasons). ...
ReoCyan's user avatar
  • 13
-1 votes
1 answer
97 views

I have this code to find my variable: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System.Reflection; ...
ReoCyan's user avatar
  • 13
3 votes
1 answer
116 views

Calling IEquatable.Equals from an integer 0 to test against a null object should return false but when using reflection it returns true. Given the following code, I would expect for iEquals and equals ...
Evelyn's user avatar
  • 81
0 votes
1 answer
133 views

If I have a C# enum where two objects map to the same integral value, is there any possible way to get each unique Enum object? Every method I have tried returns only one of the objects - which is ...
jhdepoiii's user avatar
0 votes
1 answer
72 views

In XAML I define some elements, e.g. ToolbarItems: <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" ...
Bernd Morgeneyer's user avatar
1 vote
1 answer
212 views

I have a NET 7 console app using EF core, I have a situation where I need to instantiate my custom DB Context classes using reflection passing in a DBContextOptions parameter. I am getting the ...
AndyW's user avatar
  • 523
1 vote
2 answers
349 views

How to iterate through DbContext and decrypt certain fields I am using this StackOverflow answer as a guide: Database Table Export to CSV using EntityFramework DbContext .NET 6 We have very a legacy ...
Tyson Gibby's user avatar
  • 4,969
1 vote
0 answers
301 views

I’m comparing two snapshots taken using dotMemory profiler, and I find that there are a number of RuntimeMethodInfo objects that survived through two snapshots. These objects represent methods of a ...
Alison's user avatar
  • 71
0 votes
0 answers
112 views

I am here after spending weeks trying to resolve the below issue. I have c# code which is written in the front end editor. We use Monaco Editor on the front end to write the code. That code is ...
Shankar Kumar's user avatar
-1 votes
1 answer
65 views

I have a project with around 100k XML configuration files for managing test equipment. In order to make the files easier to update, I want to be able to port them around to Excel, Access, etc. I've ...
Manfred ad. Rickenbocker's user avatar
0 votes
0 answers
17 views

My base view model uses Type.GetProperty to verify that a given property (for which we are about to raise PropertyChanged) actually exists in the class. It works great. But if you test for the ...
Joe's user avatar
  • 7,194

1
2 3 4 5
24