Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am making a bll class. and trying to create a instance object with Type.GetType. My string is :
V2.PaidBLL.Reports.ReportRequests, V2.PaidBLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
it comes in str.
code is:
C#
Type t= Type.GetType("System.String");
t= str.GetType();
object listObject = Activator.CreateInstance(objectType);
but it is not not working.

Error:
No parameterless constructor defined for this object.
Posted
Updated 16-Dec-11 10:28am
v2
Comments
Wendelius 16-Dec-11 16:30pm    
Pre tags added

1 solution

There's no parameterless constructor for String, see: String Class[^].

If you want to create for example an empty string you could use something like:
C#
object stringObject = Activator.CreateInstance(typeof(string), new object[]{ null, 0 });


This would use the following constructor: String Constructor (Char, Int32)[^]
 
Share this answer
 
Comments
Wonde Tadesse 16-Dec-11 17:11pm    
5+
Wendelius 17-Dec-11 0:49am    
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900