activator Questions

10

Solved

I have a class which has the following constructor public DelayCompositeDesigner(DelayComposite CompositeObject) { InitializeComponent(); compositeObject = CompositeObject; } along with a de...
Spurn asked 16/10, 2008 at 14:26

6

I'm trying to improve the performance of our application. We have a lot of Activator.CreateInstance calls that are causing some grief. We instantiate a lot of classes based on an interface (ITabDoc...
Alnico asked 5/7, 2011 at 11:56

9

I have a class (TabControlH60) that both inherits from a base class (UserControl) and implements an interface (IFrameworkClient). I instantiate the object using the .NET Activator class. With the r...
Cariole asked 20/10, 2009 at 19:25

3

Solved

I try to write Activator action for changing current song rating. I now that we can read MPMediaItemPropertyRating property and get rating. But how can we change it from app?
Zettazeugma asked 7/6, 2012 at 7:0

2

Solved

I'm using Activator.CreateInstance to create objects by a type variable (unknown during run time): static dynamic CreateFoo( Type t ) => Activator.CreateInstance( t ); Obviously, I do not ye...
Residue asked 11/9, 2018 at 21:50

5

Solved

Does System.Activator.CreateInstance(T) method have performance issues (since I'm suspecting it uses reflection) big enough to discourage us from using it casually?
Dialectic asked 20/5, 2011 at 9:1

4

Solved

I'm using the Activator to instantiate a new class based on the short name of an assembly (e.a. 'CustomModule'). It throws a FileNotFoundException, because the assembly isn't there. Is there a way ...
Emphysema asked 7/2, 2011 at 9:13

3

Solved

In the sample code shown below, the "CompileError" method won't compile, because it requires the where T : new() constraint as shown in the CreateWithNew() method. However, the CreateWithActivator&...
Becca asked 12/9, 2016 at 5:58

3

Solved

Assume a class with a parameterized constructor as: MyObject(string param1, string param2, string param2) { ... } I have a Generic method that returns an instance of the Generic Class and MyOb...
Gypsie asked 10/7, 2015 at 19:9

5

Solved

In my reflection code i hit a problem with my generic section of code. Specifically when i use a string. var oVal = (object)"Test"; var oType = oVal.GetType(); var sz = Activator.CreateInstance(oT...
Kitts asked 19/1, 2010 at 9:47

1

Solved

Look at the sample code below var genericNullableType = typeof(Nullable<>); var nullableType = genericNullableType.MakeGenericType(typeof(bool)); var returnValue = Activator.CreateInstance(n...
Lucilucia asked 29/5, 2015 at 16:25

6

Solved

I have an example: Assembly asm = Assembly.Load("ClassLibrary1"); Type ob = asm.GetType("ClassLibrary1.UserControl1"); UserControl uc = (UserControl)Activator.CreateInstance(ob); grd.Children....
Jolinejoliotcurie asked 24/5, 2012 at 7:22

5

Solved

I'm tossing around the idea of using the Activator class in order to get access to resources in an assembly that I would otherwise create a circular reference for (dependency injection). I've done ...
Pottage asked 5/3, 2009 at 13:58

2

Solved

I have a class which contains an empty constructor and one that accepts an array of objects as its only parameter. Something like... public myClass(){ return; } public myClass(object[] aObj){ retu...
Tutto asked 26/8, 2014 at 18:54

6

Solved

I try to set a Nullable<> property dynamicly. I Get my property ex : PropertyInfo property = class.GetProperty("PropertyName"); // My property is Nullable<> at this time So the type coul...
Usable asked 28/9, 2009 at 18:47

4

Solved

The below code won't work, I wanted to know how I can dynamically cast an instance to a type determined at runtime? Convert.ChangeType() returns an Object that still needs to be cast. So does all ...
Ovarian asked 25/1, 2014 at 2:24

1

I'm trying to use Activator.CreateInstance Method to dynamically create a new instance. But when I pass the instance of a class that is implicitly castable to the actual type (in constructor), I ge...
Ptolemaic asked 5/1, 2014 at 9:55

5

Solved

I have a generic type Store<T> and use Activator to make an instance of this type. Now how, after using the Activator, can I cast the resulted object of type object back to the instantiated t...
Anaphrodisiac asked 4/2, 2012 at 12:30

5

Solved

In C# I have the following object: public class Item { } public class Task<T> { } public class TaskA<T> : Task<T> { } public class TaskB<T> : Task<T> { } I...
Transistor asked 20/7, 2009 at 1:58

2

Solved

I want to create some instances of classes via Activator.CreateInstance(...). All classes inherit same abstract class. The constructor has one parameter. Classes and constructors should not be pub...
Duster asked 15/10, 2013 at 12:2

5

Solved

My code is type = Type.GetType(key); Key which i pass is a namespace qualified name . My code is in BusinessLayer. I am creating a instance of DataAccessLayer. DataAccessLayer reference is a...
Player asked 16/9, 2011 at 6:36

4

Solved

Can you clarify me why in this piece of code: private Dictionary<Type, Type> viewTypeMap = new Dictionary<Type, Type>(); public void ShowView<TView>(ViewModelBase viewModel, boo...
Mud asked 29/1, 2013 at 17:19

1

Solved

After I run my test that runs my suspect code; I cannot rebuild the assembly in Visual Studio until Nunit (or more specifically nunit-agent.exe) is ended. The error is: Could not copy "C:\path\My...
Luca asked 22/10, 2012 at 1:7

2

Solved

I'm trying to refactor a piece of code and ran out of options I can think off. This is the original code I had: if (WebConfigSettings.ComPartition == null && HttpContext.Current != nul...
Bowlder asked 28/9, 2012 at 10:4

1

Solved

A friend and I were testing using compiled expressions for object creation instead of Activator.CreateInstance<T> and ran into some interesting results. We found that when we ran the same cod...
Valetudinary asked 6/9, 2012 at 20:2

© 2022 - 2024 — McMap. All rights reserved.