Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
19 views

Getting "Bad IL format" when loading exe file

I'm trying to explore .NET 8.0 exe file. When I try to load it with Assembly.LoadFrom or Assembly.LoadFile I'm getting Bad IL format. The format of the file '<file_path>.exe' is invalid. But if ...
Yola's user avatar
  • 18.9k
0 votes
0 answers
45 views

Alternative For Type.IsSerializable

We used in an application if (!value!.GetType().IsSerializable) return; In the meantime the IsSerializable property is obsolete (Formatter-based serialization is obsolete and should not be used.)....
mburm's user avatar
  • 1,493
-1 votes
0 answers
20 views

How to load merged dlls with assembly.load

multiple dlls (a.dll, b.dll, c.dll) are merged into single assembly/dll "MergedAssembly.dll" Assembly.LoadFrom("d:\runtime\MergedAssembly.dll"); but it fails with message "...
Munawar's user avatar
  • 2,586
-3 votes
1 answer
55 views

Foreach can't be used for variables of type "PropertyInfo" because "PropertyInfo" has no defintion for "GetEnumerator"

I want to iterate throug a Dictionary<string, object> with a foreach loop. First I get all of the items with reflection. And when item.Name is not settings the program goes in the else path. ...
user1673665's user avatar
0 votes
0 answers
30 views

Checking the CallingConvention property of MethodInfo

I am working on an ASP.NET MVC project and I am working on reflection. I tried to determine whether a class does not have a standard, non-static public getter. I have devised the code below: ...
tahasozgen's user avatar
0 votes
1 answer
30 views

Facing issue while registering service of generic class after reading all class of same type using Reflection Assembly in c# dotnet

I have one generic class defined as below. While registering bean/service getting error that it didn't get register properly. reflection code: var types = Assembly.Load("Come.Demo") ...
Bushra Saifi's user avatar
2 votes
1 answer
58 views

C#/.Net Enforce use of specific assembly when multiple versions loaded

I need to create a class instance from a specific assembly. The assemblies (and it's dependencies) must be loadedfrom assemblies/dlls that are known runtime, not build time. So Nuget is not an option. ...
Titus's user avatar
  • 168
0 votes
0 answers
43 views

using reflection to assign a dynamically created property

I am looking to assign a dynamically created property value but apparently I only get the value assigned to the backing field and not the actual property value when I call to propertyInfo.SetValue(...
CrsB1's user avatar
  • 1
2 votes
2 answers
168 views

Unhandled exception: System.IO.FileNotFoundException: The file or assembly "System.Private.CoreLib" could not be found in custom generated assmbly

I use .NET 9 to create a .NET assembly/program programatically via the new emit api. My test code looks like the following: PersistedAssemblyBuilder assemblyBuilder = new(new AssemblyName("...
Aaron Junker-Wildi's user avatar
0 votes
2 answers
59 views

Can I access params of method execution passed to a Func<> in C#/.NET?

I am attempting to make a method that can iteratively call RESTful API endpoints that implement paging until a specific JSON object is found. I'll outline the intended pattern below and then describe ...
officeSpacePirate's user avatar
0 votes
0 answers
86 views

Dynamically redirect one C# method to another at runtime in .NET 8

I have been using the following method to redirect a C# method into another at runtime: public class Injection { public static void install(MethodInfo methodToReplace, ...
ysabih2's user avatar
  • 29
0 votes
0 answers
32 views

What's MyNotificationActivator in DynamicComActivator Assembly?

I'm working on a MAUI app. Our app uses reflection to load modules dynamically from available DLLs. However, when loading our modules, some of our developers get this exception: System.Reflection....
G_hi3's user avatar
  • 590
1 vote
1 answer
36 views

Filtering class properties by a specific criteria

Consider the following model (.NET 8, C# 12): public partial interface IEntity { public long Id { get; set; } } public partial interface IEntity<TEntity> where TEntity : class, IEntity, ...
Raheel Khan's user avatar
  • 14.5k
0 votes
1 answer
62 views

Get the enum class from a PropertyInfo [duplicate]

I have a generic method that uses reflection to obtain PropertyInfo of a given type. PropertyInfo[] properties = typeof(TItem).GetProperties(); In the case when one of the properties happens to be an ...
ISquared's user avatar
  • 412
0 votes
0 answers
54 views

.Net compiler resolve package dependencies

I am writing an app in .NET 6.0. It allows the end user to load an arbitrary assembly using Assembly.LoadFrom. Then it uses reflection to call its methods. THAT IS ALL. The challenge is: I have no way ...
Serhii's user avatar
  • 23

15 30 50 per page
1
2 3 4 5
213