|
Is the _id field a public field? If not the GetField method cannot find it, since it is only looking for public fields with the given field.
To find private fields use the GetField overload that takes an additional bitmask of one or more BindingsFlags e.g.
abstractBaseType.GetField("_id", BindingFlags.NonPublic | BindingFlags.Instance);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
damn, that works. I don't understand why the one that overrides it worked fine though.
Thanks for the suggestion. All my constructors are called like that, got thrown of the scent by the object that worked.
Thanks again
Russ
|
|
|
|
|
Russell Jones wrote: Is there a way of getting to the fields defined in a base class?
base._id
I am not sure what are you doing here.
Are you using reflection because _id is private? Why not use protected virtual method/property? Is InjectID method of AbstractBaseClass?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
I'm writing a factory class that populates the objects from a database.
The id field has a public get accessor but no set accessor for obvious reasons. The object is not defined in the same project as the datafactory so I can't use internal to get to it.
InjectID is in the abstractFactoryBase class from which my databasefactory is derived.
Probably a crazy way to design an app but it's working the way i want with that last change and so far it seems very clean to use.
Russell
|
|
|
|
|
I knew there's more to it, but couldn't get the picture
Russell Jones wrote: The id field has a public get accessor but no set accessor for obvious reasons. The object is not defined in the same project as the datafactory so I can't use internal to get to it.
There is attribute that does that. InternalsVisibleToAttribute[^]. Little brutal tho.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Wow, i don't believe such an attribute exists.
That seems wrong on so many levels,
Brutal seems a very good description
Russell
|
|
|
|
|
Hi,
I'm creating something looked like the development enviorment in Visual Studio.
I have a panel with a listbox for "Activities".
I also have a panel with properties to change those activities properties.
I'm working on the deletion of activities but i'm having problems with the listbox.
i have the following two functions
<br />
private void lbActivities_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
if (lbActivities.Items.Count!=0)<br />
{<br />
selectedActivityName = lbActivities.SelectedItem.ToString();<br />
selectedActivityIndex = activities.FindIndex(withName);<br />
<br />
pgProperties.SelectedObject = activitiesPropertyBags[selectedActivityIndex];<br />
}<br />
}<br />
This is a event for the listbox item change.
Well, i use two global variables to keep track of the selected item name and index. I also use a list to store my activities.
(is this stupid? could i use the listbox to do the same as the list, and avoid the use of two different structures?)
And here i have the code for deletion:
<br />
if (lbActivities.Items.Count != 0)<br />
{<br />
if (selectedActivityIndex == 0) {<br />
selectedActivityIndex = (lbActivities.Items.Count - 1) - 1;<br />
lbActivities.SelectedItem = lbActivities.Items[selectedActivityIndex];<br />
}<br />
else {<br />
selectedActivityIndex = lbActivities.SelectedIndex - 1;<br />
lbActivities.SelectedItem = lbActivities.Items[selectedActivityIndex];<br />
}<br />
<br />
lbActivities.Items.Remove(selectedActivityName);<br />
activities.RemoveAt(activities.FindIndex(withName));<br />
}<br />
}<br />
The problem is that when the lbActivities.Items.Remove(selectedActivityName); is executed, the SelectedIndexChanged callback is called, and occurs an exception in the following instruction:
selectedActivityName = lbActivities.SelectedItem.ToString();
This happens even after i wrote the code above, which trys to change the selected item in order to avoid the selection of non existent item.
Any tips?
Thank you very much,
Nuno
|
|
|
|
|
you could set a bool _deletion in progress when you start doing the delete. In the selectedindex changed look for that flag and exit after changing it back to false.
The temptation with a lot of this code is to stick your list into a listbox and use it to maintain your collection. I always try not to do this as i find it leads to logic that is very hard to disentangle from presentation code. It may take more effort to maintain code this way at the start but later on you'll be glad of the separation if, for instance, you want to switch to using a treeview instead.
HTH
Russ
|
|
|
|
|
Hi,
Thx for the reply.
I managed to solve the problem setting selectedItem to null.
Thx,
Nuno
|
|
|
|
|
hi guys
there's probably others way of installing 2 or more HotFixes on Vista, but i've decided that I'm going to write a program in C#, one that:
1 - will ask you to add the Htofixes to be installed
2 - Will send each of those Hotfixes to CMD.eXE in format of
eg : START /WAIT Windows6.0-KB931675-x86.msu /QUIET /NORESTART
but i'm already stock. i can't figure out to send a command such the one above to cmd.exe. i also have to wait til cmd returns from wat its doing before i can send the other command to it . How cam i do that? plz help
thanx
|
|
|
|
|
How about using
Process.Start(@"START /WAIT Windows6.0-KB931675-x86.msu /QUIET /NORESTART");
?
|
|
|
|
|
[correction]:
i tried:
Process.Start("CMD",@"START /WAIT C:\\Downloads\\Windows6.0-KB931675-x86.msu /QUIET /NORESTART");
but instead of the command been applied through CMD, i get
"Visual Studio 2005\Projects\WindowsApplication
2\WindowsApplication2\bin\Debug>" in CMD?
Also how is it possible to detect when CMD has returned from applying the patch? for example if i have 5 patches to apply, if i put on through CMD , i need to wait until that patch is done, and once thats done, only then i want the second patch to be appied. how can i detect that?
thanx
|
|
|
|
|
ok got that fixed
it should be :
Process.Start("CMD",@"/C START /WAIT C:\\Downloads\\Windows6.0-KB931675-x86.msu /QUIET /NORESTART");
Now how can i detect when CMD has finished processing the current patch and is ready so i can send the other patch to CMD then? thanx
|
|
|
|
|
Hi all,
I'm looking for a way to call functions in a VS2005 Shared Addin from an external VS2005 application.
a) The functions defined in Addin need some special demands?
b) In application how to invoke the function?
Thanks
scott- 3/29/07
|
|
|
|
|
I’m try to read a xml-string into an XmlDocument like this:
string xml = "valid xml";<br />
XmlDocument doc = new XmlDocument();<br />
doc.LoadXml(xml);
It works perfect if I don’t have any strange characters like ‘&’.
Why do I get the following exception if I use ‘&’:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseEntityName()
at System.Xml.XmlTextReaderImpl.ParseEntityReference()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
_____________________________
...and justice for all
APe
|
|
|
|
|
Because the string that you call "valid xml" is not valid xml. You have to encode characters like & into &.
---
single minded; short sighted; long gone;
|
|
|
|
|
Perfect! Thanks
_____________________________
...and justice for all
APe
|
|
|
|
|
hello,
I have Reinstall my windows xp.
and I am restoring my progranm
when I try to "build" or "rebuild" my program I get the error:
"unable to find mainifest signing certificate in the certificate store"
1) what does it mean?
2) how do I fix my program?
|
|
|
|
|
Go to the "Signing" tab of the project properties and uncheck "Sign the ClickOnce manifests".
Gautham
|
|
|
|
|
Hi all,
I have a datagridview, is it possible to copy data, for example from an excel spreadsheet into the grid, and if so how?
Thanks in advance
He who laughs last is a bit on the slow side
|
|
|
|
|
string strConn;
strConn = "Provider=Microsoft.Jet.OleDb.4.0;data source=File Path;Extended Properties=Excel 8.0;";
OledbConnection objCon = new OledbConnection(strcon);
OledbDataAdapter objDA = new OledbDataAdapter("select * from [sheet1$]", strConn);
DataSet ds = new DataSet();
objDA.Fill(ds);
datagrid1.datasource=ds;
datagrid1.databind();
Gautham
|
|
|
|
|
Thanks for the quick reply.
I have a grid that is bound to a datasource, our clients have an excel file with data, so I want to be able to select data from the excel page, copy that, and then just paste the data onto the grid at runtime, is something like this possible
He who laughs last is a bit on the slow side
|
|
|
|
|
hi! how to change the font in one row in a datagrid..
|
|
|
|
|
DataGridId.Items[row number].ForeColor=System.Drawing.Color.Red;
Gautham
|
|
|
|
|
Hi,
Suppose i have a datagrid,have 1000 records.how can i see the duplicates records
in the datagrid?
thanks.
|
|
|
|