473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

c# and remoting creating objects

hey this is the error im getting :

--> Cannot widen from target type to primitive type.

this line produces the error :

temp = o.GetType().InvokeMember("", BindingFlags.CreateInstance, null,
null, null);

==============================================
this is what im trying to do : CODE --->

public object[] selectObjects(object o, string where)
{
object[] objects = null;
try
{
//get object type
Type objectType = o.GetType();
//get object properties (atributes)
get/set
PropertyInfo[] properties =
objectType.GetProperties();
//create table sql header + table Name
string query = "SELECT * FROM `"+
getClassName(objectType) +"` ";

if(where != null)
{
query = query + where + ";";
}
else
{
query = query + ";";
}

System.Console.WriteLine(query);
DataSet result =
this._oconn.getDataSetFromQuery(query);

objects = new
object[result.Tables[0].Rows.Count];
int index = 0;

//try to get info
object temp = new object();

foreach(DataRow row in
result.Tables[0].Rows)
{
temp =
o.GetType().InvokeMember("", BindingFlags.CreateInstance,
null, null, null);

foreach(PropertyInfo pi in
properties)
{
//The row names are the
same as the property names
//and i want to load up
the property values into the object
if(pi.Name !=
"TimeStamp")
{

pi.SetValue(temp,row[pi.Name],null);
}
}

objects[index] = temp;
index ++;
}

}
catch(Exception e)
{
System.Console.WriteLine(e.Message
+System.Environment.NewLine +
e.StackTrace);
}

return objects;
}

private string getClassName(Type o)
{
string[] t = o.FullName.Split('.');
return t[t.Length-1].ToString();
}
==============================================

i just cant figure out how to do this properly .. any one have ideas ?

the table name correspond to the object, and to make sure you have the
right object to instantiate i send in a new object to get the right
reflection information ..

Alexandre

Nov 17 '05 #1
0 1040

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fadi | last post by:
Backround: I am trying to figure out how to do the equivalant of a classic COM Local Server Singleton in .NET/C#. I created a coupld of simple Class Libs that exposes public interfaces and hosted...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
3
by: Michael Maes | last post by:
Hi, We have a windows service passing objects to a client application by remoting. The windows service is started and running successfully. * When the client app is running on the same...
5
by: Sam Shrefler | last post by:
I'm working on creating a SOA for my applications. We have numerous .NET IIS applicaitons. They all tie into a central client database for certain pieces of information. I'm trying to decide the...
0
by: blueinterface | last post by:
Hi Experts! I have created a compact framework library that contains the core objects. The library should be consumed by both the pocket pc and desktop applications. However, one of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.