|
Is your class derived from MarshalByRefObject? Or is it serializable?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil,
Thanks for your response, my class is derived via MarshalByRefObject.
|
|
|
|
|
Hi
please I need help, i need icon in system tray which manages my window service. windows service run on my computer but it doesnt show the icon. and other thing is how i can send messages to window service to do some perticular stuff.
|
|
|
|
|
We'll need some more information before we can help in regards to the notification icon problem (systray icon). Do you already have code to display a system tray icon, or do you need help adding that code?
As for communicating with your windows service, there are many ways, and it all depends on the environment the service is intended to be used in, and what kind of performance you need out of the communication protocol. You can use named pipes (there are several EXCELLENT implementations of named pipe communication here on CodeProject), .NET Remoting (search this site and google for it), as well as custom implementations such as with TCP/IP. Again, more information is needed before useful advice can be given.
|
|
|
|
|
HI Jon Rista,
Thank you for speedy reply.
In my project I need to create communication between .net application and MFC application on the same machine.
Please help me.. after resolving this communcation problem i will handle system tray problem.
Thanks in advance.
Regards,
vidya
|
|
|
|
|
If you want to communicate between dissimilar apps like that (and dissimilar platforms), I would say the best option is TCP/IP if you need to communicate accross a network, or Named Pipes if you just need to communicate to the same machine. There are a couple good named pipe implementations here on CodeProject that should help you get started. You will need to write custom communication code for each app.
|
|
|
|
|
I have an XML formatted string that my program receives from any number of other programs.
It may contain:
<br />
< value="name" type="string" >Aristotle< /value > (Without spaces around value tags)<br />
I need to have a collection which will dynamically create those variables inside itself, but I'm not sure how to do this.
Something like:
public class XMLParser
{
string m_RawXML;
CollectionWithMultipleTypes m_Values = new CollectionWithMultipleTypes() // IS THERE A COLLECTION TYPE BUILT FOR THIS PURPOSE?
public XMLParser(string RawXML)
{
ParseXMLString(string RawXML);
}
public void ParseXMLString(string RawXML)
{
string[] ValueStringsArray = GetValueStrings(string RawXML);
foreach(string valueString in ValueStringsArray)
{
try
{
// Parse string to create new type with name and store data in it
mValues.Add(newVal);
}
catch(Exception err)
{
MessageBox.Show(err.ToString());
}
}
}
}
So, my questions are: Is there a datatype in C# that can store mulitple types of data in it? There aren't built in XML functions for recreating data types from a string, are there? Is this a viable approach? If it is, does anyone have any code that might simplify my life?
As always, Thanks!
-- modified at 15:22 Thursday 3rd November, 2005
|
|
|
|
|
budidharma wrote: So, my questions are: Is there a datatype in C# that can store mulitple types of data in it?
Since all classes are derived from the Object class any collection that can hold objects (e.g. an Array or ArrayList) is capable of holding objects of any class.
For recreating objects from XML I think you'll want to look in to the Reflection classes. You'd need to extract the type attribute from your XML string and use reflection to try and create the object of that class. Maybe it would also be possible to use serialization to recreate your objects?
|
|
|
|
|
Is there a build in XMLRead type command that will retrieve name value pairs from an xml formatted string?
|
|
|
|
|
|
I would check out the XmlTextReader class. Its a very low-profile, rapid, and generally forward-specific class that can blast through huge xml files in short order. Its VERY easy to use, and should solve your problem in a heartbeat. You can likewise use XmlTextWriter to reserialize your collection to similar xml, too.
|
|
|
|
|
|
Basically, you're app has to check out its command line arguments. What is your popup app written in?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
My Popup app is written in C#
|
|
|
|
|
|
I have two release configurations set up in which one has an additional symbol defined so that I can do conditional compilation for each configuration. However, one doesn't need a reference to the 3rd party library, while the other does. When I try to remove the reference in one configuration, it removes the reference in both. Is this possible, or am I doing something wrong?
My articles
BlackDice
|
|
|
|
|
Yes, You have to have the reference in your project. There is no way to remove the reference for just one configuration.
What you can do is, in the properties of the project, select the type of configuration(debug, release, etc what ever you defined) and go to "configuration properties". Then in the configuration in which you need the reference, go to "Build" category add another condition compilation constant eg: "CLASS_LIBRARY"
Modify your code for the using statement.
Only for the reference object do this.
#if CLASS_LIBRARY
using addyourreference;
#endif
This will add your reference conditionally.
|
|
|
|
|
I'm trying something new, but not quite sure how to do it. I have a class for modeling data that contains three types of data - persistant data, data that is semi-persistant, and data that is updated constantly. I would like to have each defined in a struct defined inside my data model class, like so: (This is obviously incorrect syntax, but I can't figure out how do it correctly)
<br />
public class DataModel<br />
{<br />
<br />
private struct PersistantData<br />
{<br />
int m_int1;<br />
int m_int2;<br />
}m_PersistantData;
<br />
private struct SemiPersistantData<br />
{<br />
int m_int3;<br />
int m_int4;<br />
}m_SemiPersistantData;<br />
<br />
private struct DynamicData<br />
{<br />
int m_int5;<br />
int m_int6;<br />
}<br />
<br />
public UpdatePersistantData(int int1, int int2)<br />
{<br />
m_PersistantData.m_int1 = int1;<br />
m_PersistantData.m_int2 = int2;<br />
}<br />
<br />
...<br />
}<br />
Obviously, thats not the actual program, but it shows how I would like to declare and use the structs. Is this possible?
|
|
|
|
|
I am curious as to why you want to declare the structs inside the class.
|
|
|
|
|
Plainly because they are for use only by the class, in it's internal workings.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
budidharma wrote: private struct PersistantData
{
int m_int1;
int m_int2;
}m_PersistantData; // I WOULD LIKE TO DEFINE AND INSTANTIATE THE STRUCT RIGHT HERE, INSIDE THE CLASS. IS THIS POSSIBLE?
You're doing two things at once.
private struct PersistantData
{
int m_int1;
int m_int2;
}
PersistantData m_PersistantData;
One more thing, unlike C++, C# structs have default access as private, so you'd need to make these int's public if you wanted to use them for anything
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks. I knew I could declare them like that, which is the way it's currently written, I was hoping for a shortcut to define and declare a single instance, since each class simply needs a single instance of each. Not necessary, just a little elegant.
And of course, you're correct - they are ONLY used within the internal structure of the class. I'm simply separating the data into catagories that they belong in.
|
|
|
|
|
You can't declare a struct inside a class, the same way you can't declare a struct inside a struct or a class inside a class.
---
b { font-weight: normal; }
|
|
|
|
|
You can declare classes and structs inside classes, as well as classes and structs inside structs.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Oh, you are absolutely right. Sorry about that.
---
b { font-weight: normal; }
|
|
|
|