Click here to Skip to main content
15,918,193 members
Home / Discussions / C#
   

C#

 
GeneralRe: Remote event update RichTextBox problem Pin
ZarazaPhd3-Jan-09 9:10
ZarazaPhd3-Jan-09 9:10 
GeneralRe: Remote event update RichTextBox problem Pin
Luc Pattyn3-Jan-09 9:44
sitebuilderLuc Pattyn3-Jan-09 9:44 
GeneralRe: Remote event update RichTextBox problem Pin
ZarazaPhd3-Jan-09 10:59
ZarazaPhd3-Jan-09 10:59 
GeneralRe: Remote event update RichTextBox problem Pin
Luc Pattyn3-Jan-09 11:34
sitebuilderLuc Pattyn3-Jan-09 11:34 
GeneralRe: Remote event update RichTextBox problem Pin
ZarazaPhd3-Jan-09 11:47
ZarazaPhd3-Jan-09 11:47 
GeneralRe: Remote event update RichTextBox problem Pin
Luc Pattyn3-Jan-09 12:20
sitebuilderLuc Pattyn3-Jan-09 12:20 
GeneralRe: Remote event update RichTextBox problem Pin
ZarazaPhd4-Jan-09 3:04
ZarazaPhd4-Jan-09 3:04 
QuestionUsing Type and ConstructorInfo: Can't understand why this doesn't work... Pin
pikmindoctor3-Jan-09 4:19
pikmindoctor3-Jan-09 4:19 
Ok here's what I'm trying to do:

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Reflection;
using System.Runtime.Remoting;
using System.Drawing;
using System.Windows.Forms;


namespace GetConstructorTest
{
    public class GooConsistency
    {
        public GooConsistency()
        {
        }
    }

    public class Monster
    {
        public Monster()
        {
        }
    }
    public class GooeyMonster: Monster
    {
        public GooeyMonster(GooConsistency gooness)
        {
        }
    }
    public class SqueltcheyMonster : Monster
    {
        public SqueltcheyMonster(Color tongueColor, bool isBackflipping)
        {
        }
    }

    public partial class Form1 : Form
    {
        public Form1()
        {
            object[] MonsterData1 = new object[] { new GooConsistency() };
            Monster Monster1 = CreateMonster("GooeyMonster", MonsterData1);
        }
        public Monster CreateMonster(string type, Object[] vConstructorArgumentValues)
        {
            Type[] argtypes = Type.GetTypeArray(vConstructorArgumentValues);
            Type t = Type.GetType(type);
            ConstructorInfo info = t.GetConstructor(argtypes);

            return info.Invoke(vConstructorArgumentValues) as Monster;
        }
    }
}


But on the line: ConstructorInfo info = t.GetConstructor(argtypes);

I get this exception:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="GetConstructorTest"
StackTrace:
at GetConstructorTest.Form1.CreateMonster(String type, Object[] vConstructorArgumentValues) in G:\Portable Documents\Visual Studio 2008\Projects\GetConstructorTest\GetConstructorTest\Form1.cs:line 50
at GetConstructorTest.Form1..ctor() in G:\Portable Documents\Visual Studio 2008\Projects\GetConstructorTest\GetConstructorTest\Form1.cs:line 44
at GetConstructorTest.Program.Main() in G:\Portable Documents\Visual Studio 2008\Projects\GetConstructorTest\GetConstructorTest\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Why?
AnswerRe: Using Type and ConstructorInfo: Can't understand why this doesn't work... Pin
User 66583-Jan-09 4:26
User 66583-Jan-09 4:26 
GeneralRe: Using Type and ConstructorInfo: Can't understand why this doesn't work... Pin
Luc Pattyn3-Jan-09 4:28
sitebuilderLuc Pattyn3-Jan-09 4:28 
QuestionQuestion on string.Format(...) Pin
Charith Jayasundara3-Jan-09 4:08
Charith Jayasundara3-Jan-09 4:08 
AnswerRe: Question on string.Format(...) Pin
Colin Angus Mackay3-Jan-09 5:21
Colin Angus Mackay3-Jan-09 5:21 
GeneralRe: Question on string.Format(...) Pin
Charith Jayasundara3-Jan-09 6:17
Charith Jayasundara3-Jan-09 6:17 
GeneralRe: Question on string.Format(...) Pin
Colin Angus Mackay3-Jan-09 6:32
Colin Angus Mackay3-Jan-09 6:32 
GeneralRe: Question on string.Format(...) Pin
Charith Jayasundara3-Jan-09 8:31
Charith Jayasundara3-Jan-09 8:31 
QuestionAutoincrement ID field in a xsd Pin
tharkaway3-Jan-09 2:50
tharkaway3-Jan-09 2:50 
QuestionHow to check whether network busy or not? Pin
George_George3-Jan-09 1:20
George_George3-Jan-09 1:20 
AnswerRe: How to check whether network busy or not? Pin
Abhijit Jana3-Jan-09 1:34
professionalAbhijit Jana3-Jan-09 1:34 
GeneralRe: How to check whether network busy or not? Pin
George_George3-Jan-09 1:55
George_George3-Jan-09 1:55 
GeneralRe: How to check whether network busy or not? Pin
Abhijit Jana3-Jan-09 2:25
professionalAbhijit Jana3-Jan-09 2:25 
GeneralRe: How to check whether network busy or not? Pin
George_George3-Jan-09 21:25
George_George3-Jan-09 21:25 
GeneralRe: How to check whether network busy or not? Pin
Abhijit Jana4-Jan-09 0:51
professionalAbhijit Jana4-Jan-09 0:51 
GeneralRe: How to check whether network busy or not? Pin
George_George4-Jan-09 22:30
George_George4-Jan-09 22:30 
AnswerRe: How to check whether network busy or not? Pin
S. Senthil Kumar4-Jan-09 0:34
S. Senthil Kumar4-Jan-09 0:34 
GeneralRe: How to check whether network busy or not? Pin
Abhijit Jana4-Jan-09 0:53
professionalAbhijit Jana4-Jan-09 0:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.