I am using something like the following to load DLL's in my C# app.
foreach (String s in Directory.GetFiles(".", "*.dll"))
foreach (Type t in Assembly.LoadFrom(s).GetTypes())
But it does not apply the App.config settings for those binaries. Is there a programatic way to load these settings?
...
Is there some clever way of getting the date and time of when the dll was built/compiled?
I’m using the assembly version numbering and reflection to retrieve and display this info when the app is deployed. But in some scenarios it would be more convenient to know when then dll was actually compiled rather than the auto incrementing vers...
If you have an enum that you are accessing via reflection how would you pass it's value into method.invoke call.
Would it be something like (shown as a static method for simplicity)
Class enumClazz = Class.forName("mypkg.MyEnum",true,MyClassLoader);
Class myReflectedClazz = Class.forName("mypkg.MyClass",true,MyClassLoader);
...
Hi,
Is it possible to read the comments on the dll.
Comments are listed under Version when one looks at the property of the dll.
I know that i can get the version number but would rather get the comments as it is user friendly.
Assembly.GetName.Version.ToString --will give version number
thanks
...
I have a set of properties and need to provide a default values for them. Sure I can do the following in getter:
public string MyProp {
get {
if(!string.IsNulOrEmpty(_myProp))
return _myProp;
else
return "Default";
}
But I`d like it to look li...
Let's say I have base class FooParent, and it has a numerous amount of FooChildren. At runtime I must create an instance of one of the FooChildren. How would I do this? I realize I could create a huge map (and use delegates) or a huge switch/case statement, but that just seems a bit sloppy. In something like PHP, I can easily create a cl...
The .NET Framework 4.0 introduces several items to the Reflection API that range from extremely useful to vital for my work. Among these are protected constructors for Assembly, Module, MethodBody, and LocalVariableInfo and the new CustomAttributeData class. There are a couple items I still need that are quite troublesome to work around....
I want to call Type.GetFields() and only get back fields declared as "public const". I have this so far...
type.GetFields(BindingFlags.Static | BindingFlags.Public)
... but that also includes "public static" fields.
...
Hello, i received a small problem to resolve in my free time regarding changing an objects behavior and also the class behavior at runtime in C++. I read a little bit and found this link, really useful for me. http://www.vollmann.ch/en/pubs/meta/meta/meta.html Mr. Volmann made a Meta object protocol(MOP) for defining classes at runtime, ...
After successfully getting a list of specific types out of an assembly using reflection, I now want to get at the public properties of each of those.
Each of these types derives from at least one base class.
I notice when I get properties on a type that I get properties from the base classes as well.
I need a way to filter out base c...
Hello,
I am using C# and reflection to load and invoke methods from an assembly. I have the source code of the assembly itself. What do I need to do to get the debugger to step into (and not over) the code of the dynamically loaded assembly ?
If I press F11 on the ....Invoke line it just steps over it ..
Thanks
...
Hi everyone,
I'm working on a project that requires me to do simple geometrical transformations (translation, reflection over x and y axis) on some figures drawn on a Java applet. The previous guy working on the applet was drawing the figures from arrays representing the caretesian points for the vertices of each figure. I decided to...
I'm writing a library that will be used to Hibernate many types of EJBs via JPA. When loading an EJB from JPA, the library needs the datatype of the field(s) annotated with @Id. The @Id may be annotated on a superclass of the EJB. Is there a method in Hibernate or JPA that can get the datatype of @Id?
I'm tempted to use reflection, b...
EDIT: I changed wording, added long sample code to be more descriptive
I need to read type name of object bind via BindingSource.
My method accepts BindingSource as parameter and it doesnt know about object type 'hosted' by BindingSource. But I need to read that object type
To explain better what I meant, assume I have 2 classes
clas...
Let's assume type MyType implements interface IMyInterface. How to find type declaring an interface ? For example,
class UnitTest
{
MyTypeBase : IMyInterface { }
MyType : MyTypeBase { }
void Test() {
Type declaration = FindDeclaration(typeof(MyType), typeof(IMyInterface));
Assert.AreEqual(typeof(MyTypeBase), declarati...
Hi I have the following requirement.
I want to create variable number of String arrays in a method, based on the number of levels present.
For e.g
I have the variable numOfLevels (int) received from a jsp page.
Based on this I want to create:
String[] level1;
String[] level2;
String[] level3;
String[] level4;
etc ...
I know my re...
I'm looking the way to read all assemblies (DLLs) used by my app.
In standard C# project there is "References" folder, when it is expanded I can read all libs used.
GOAL is read programically (in runtime) all assemblies used by each project in my solution.
Finally I'd like to see what libs are used by compiled *.exe application
Do y...
Jquery has utility a function called 'extend' which can be used to merge objects. It is very useful to merge default options with the user specified options , to get the effective options.
Is there any similar function in c#/.Net ?
class settings
{
public string Directory;
public string Username;
}
settings default_set = new ...
I'm using GetParameter to determine what parameters the constructor needs. I can get a list of them. Now I want to invoke the ctor. Is this possible if there is no empty one?
...
Consider the following PHP snippet:
<?php
class Is
{
function __get($key)
{
$class = __CLASS__ . '_' . $key;
if (class_exists($class) === true)
{
return $this->$key = new $class();
}
return false;
}
function Domain($string)
{
if (preg_match('~^[0-9a-z\-]{1,63}\.[a-z]{2,6}$~i', ...