The runtime error is:
System.TypeLoadException: 'Could not load type 'Gorp' from assembly 'foopy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.'
Here is all the code for both of the two classes in the project:
using System;
namespace foopy
{
class Program
{
static void Main(string[] args)
{
Object myObject;
myObject = Activator.CreateInstance(null, "Gorp");
}
}
}
namespace foopy
{
class Gorp
{
}
}
From the docs for that second parameter:
typeName
StringThe fully qualified name of the preferred type.
(emphasis mine).
You need to pass the fully-qualified name of the type, including the namespace. So "foopy.Gorp"
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.