Hi,
I got the following problem :
I have an defined an Array of different Actions:
public PRootActions[] AllActions = new PRootActions [10];
I got a dynamic method where all Actions or other things like
Materials are loaded from a Database to my Actions or Materials
Array:
public void All_Db2Cl (Object[] AllData, ref int totalData)
This method is called like this:
PMain.myPArray. All_Db2Cl (AllAction, ref
PMain.myPGlobal s.totalActions) ;
Inside this Method I call the Activator.Creat eInstance Method to
initialize the Array Element:
AllData = Ativator.Create Instance (null,
"PentaEngine.PR ootActions");
With this instruction I receive the following error message :
An unhandled exception of type 'System.ArrayTy peMismatchExcep tion'
occurred in PentaEngine.exe
Additional information: Attempted to store an element of the incorrect
type into the array.
Does anyone has an idea ?
Thank you very much
Frank 4 7654
Hi, Inside this Method I call the Activator.Creat eInstance Method to initialize the Array Element: AllData = Ativator.Create Instance (null, "PentaEngine.PR ootActions");
With this instruction I receive the following error message :
An unhandled exception of type 'System.ArrayTy peMismatchExcep tion' occurred in PentaEngine.exe
Arrays must be created using System.Array.Cr eateInstance.
Bye
Rob
garak <fp*******@gm x-dot-de.no-spam.invalid> wrote: I got the following problem :
I have an defined an Array of different Actions: public PRootActions[] AllActions = new PRootActions [10];
I got a dynamic method where all Actions or other things like Materials are loaded from a Database to my Actions or Materials Array: public void All_Db2Cl (Object[] AllData, ref int totalData)
This method is called like this: PMain.myPArray. All_Db2Cl (AllAction, ref PMain.myPGlobal s.totalActions) ;
Inside this Method I call the Activator.Creat eInstance Method to initialize the Array Element: AllData = Ativator.Create Instance (null, "PentaEngine.PR ootActions");
With this instruction I receive the following error message :
An unhandled exception of type 'System.ArrayTy peMismatchExcep tion' occurred in PentaEngine.exe
Additional information: Attempted to store an element of the incorrect type into the array.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
OK Thanks,
but with Array.CreateIns tance I need to have a TYPE variable,
describing the desired type. I only have the typename as a STRING
variable.
Is there a way to get a TYPE variable with the typename ?
garak <fp*******@gm x-dot-de.no-spam.invalid> wrote: OK Thanks, but with Array.CreateIns tance I need to have a TYPE variable, describing the desired type. I only have the typename as a STRING variable. Is there a way to get a TYPE variable with the typename ?
Type.GetType.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Sworder |
last post by:
Hi,
I need to design a method that creates and returns a large array of
objects. The problem is that the *type* of object to create isn't know until
runtime. As a result, a parameter of type "Type" must be passed in:
IMyInterface CreateObjects(Type type,int numberOfObjects);
Internally this method will call Activator.CreateInstance() to create
the objects. Here's my question: Is there a significant performance penalty
|
by: shmeian |
last post by:
I have the following code which works fine.
However I want to pass the object I'm instantiating a string for its
constructor.
I can't get the syntax right. Can someone give me an example of
Activator.CreateInstance where they pass an argument with the object type?
Assembly a = Assembly.GetExecutingAssembly();
Type type = a.GetType("MyAssemb.MyClass");
Object o = Activator.CreateInstance(type);
MyClass myObj=...
|
by: Terry |
last post by:
I'm building some dll assemblies that have in them the implementation of an
abstract class defined in a different assembly.
I'm trying to create objects of the type defined in the dlls with
"Activator.CreateInstance".
Everything was working fine until I started to fill out the class def with
some implementation. At some point the CreateInstance was failing with a
"MissingMethodException - No parameterless constructor defined for this...
|
by: hazz |
last post by:
this is a repost with more concise code (well, for me) and better questions
(I hope....) .
given the following two classes, my intent is to use either
Activator.CreateInstance or InvokeMember pass a token into the instantiated
class DBPassword and return a string;
**************************************
namespace DBPasswordProvider
public class DBPassword
{
|
by: Frank Pleyer via .NET 247 |
last post by:
Hi,
I got the following problem :
I have an defined an Array of different Actions:
public PRootActions AllActions = new PRootActions ;
I got a dynamic method where all Actions or other things like Materials are loaded from a Database to my Actions or Materials Array:
public void All_Db2Cl (Object AllData, ref int totalData)
| |
by: John Jenkins |
last post by:
Hi,
I have a fairly simeple question. What are the differences between
Assembly.CreateInstance and System.Activator.CreateInstance? I had read that
one maps to the other, however when I use Assembly.CreateInstance to create
an object that implements an interface it cannot cast to the appropriate
interface type before returning. e.g.
ISubmit lo_MessagingObject=null;
string
|
by: System.Reflection Activator |
last post by:
**************************************
//Load the Assembly
Assembly a = Assembly.LoadFrom(sAssembly);
//Get Types so we can Identify the Interface.
Type mytypes = a.GetTypes();
BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
//Iterate through the Assembly to find Class with a Public Interface.
|
by: MichaelSL |
last post by:
When I build an executable which uses System.Activator.CreateInstance and
execute it on my PC, which has Microsoft Visual Studio installed, the
CreateInstance works just fine and the class constructor is called. But when
I move this executable to another PC (even one with Microsoft Visual Studio)
the execution proceeds all the way to the CreateInstance statement but hangs
there with the constructor never executing.
Any ideas? Is there...
|
by: jcomber |
last post by:
Hi,
I'd be grateful for some help...
I'm trying to create a late bound object using:
Activator.CreateInstance(Type, ConstructorParameters())
The constructor of the object takes a delegate as the only parameter.
However, ConstructorParameters() is an object array and because a
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |