|
Darrall wrote: Can anyone tell me how to change all the back slashes to forward slashes?
For what purpose? In Windows, the standard path seperator is a backslash while the forward slash is used for command line switches.
|
|
|
|
|
I am using folderBrowserDialog to locate the folder where the user stored his program which also has the location of the data files which are needed for the program. The path is returned as it is in the computer with backslashes but can't be used that way by the program.
|
|
|
|
|
Darrall wrote: can't be used that way by the program
Fix the program.
|
|
|
|
|
hi, I defined groups for a listview and I want to add items to the groups but I can't. Could you please see below code and tell me what's wrong?
listview1.Groups[0].Items.Add("item");
|
|
|
|
|
Hi,
teknolog123 wrote: but I can't
that is not informative.
What you need can be achieved through the Group property. Here[^] is a simple example.
|
|
|
|
|
Hello,
I am writing a messenger like client server application for a school project.
My client and server are communicating trough tcp protocol via the the .net sockets.
It all worked fine untill I tried to transfer complex data from the server to the client,like a custom classes I made.
To transfer this data I have decided to use Serialization and turn the objects to bytes,than send the bytes to the client via the the sockets SendTo method.
I did manage to send the object,but when I try to deserialize the bytes back to an object on the server side , I get this exception
System.Runtime.Serialization.SerializationException was unhandled
Message="Unable to find assembly 'SmallTalkServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."
Source="mscorlib"
I googled around for a few hours and learned that the source of the prroblem is that since the object was serialized on the server side application that have X assembles,it can't be deserialized on the client server which other assembles.
I tried to use the proprtey
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
But it didn't help,also from my searching I learned that there is a bug with the proprtey (I am using 3.5 framework s1)
I tried to change to soap foramtter and I soon learned that soap foramatter can not serialize generic types and thus he is help less for me.
I am really not sure how to solve this problem,please help me,
Thanks in advance!
btw this is my Serializer class which I have the same on both of the app.
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Formatters;
namespace SmallTalkServer
{
public static class Serializer
{
public static void SerializeObject(string filename, BuddyList buddyList)
{
Stream stream = File.Open(filename, FileMode.Create);
BinaryFormatter bFormatter = new BinaryFormatter();
bFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
bFormatter.Serialize(stream, buddyList);
stream.Close();
}
public static BuddyList DeSerializeObject(string filename)
{
BuddyList buddylist;
Stream stream = File.Open(filename, FileMode.Open);
BinaryFormatter bFormatter = new BinaryFormatter();
bFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
buddylist = (BuddyList)bFormatter.Deserialize(stream);
stream.Close();
return buddylist;
}
public static BuddyList DeSerializeObject(byte[] arrBytes)
{
MemoryStream memStream = new MemoryStream();
memStream.Write(arrBytes, 0, arrBytes.Length);
memStream.Seek(0, SeekOrigin.Begin);
BuddyList buddylist;
BinaryFormatter bFormatter = new BinaryFormatter();
bFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
buddylist = (BuddyList)bFormatter.Deserialize(memStream);
memStream.Close();
return buddylist;
}
public static byte[] ObjectToByteArray(object obj)
{
if (obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
public static object ByteArrayToObject(byte[] arrBytes)
{
MemoryStream memStream = new MemoryStream();
BinaryFormatter binForm = new BinaryFormatter();
binForm.AssemblyFormat = FormatterAssemblyStyle.Simple;
memStream.Write(arrBytes, 0, arrBytes.Length);
memStream.Seek(0, SeekOrigin.Begin);
object obj = (object)binForm.Deserialize(memStream);
return obj;
}
}
}
|
|
|
|
|
A class is identified by its name and the assembly in which it is declared.
I presume you have included your BuddyList class code in both your server and client assemblies. This creates 2 different types because they are in different assemblies. You cannot, by default, serialize one class and deserialize a different one, even if they have identical members.
One solution would be to put any shared classes in a separate library assembly and reference that from both your server and client applications.
Another option would be to use a SerializationBinder . This would also help you maintain backwards compatibility between versions, if you also implement ISerializable .
Nick
|
|
|
|
|
Thanks for the anwser,I was wondering if you have any good guide for how SerializationBinder is working,or more details on how to create a separate library assembly,since I am learning through creating the project I am not familiar with those things.
Thank you!
|
|
|
|
|
Ok, the easiest way is to create a library assembly:
1) Add a new project in your solution of type "Class Library"
2) Put your code for any classes that are shared ( like BuddyList ) into this project.
3) Right-click on the References node of both your server and client and add a reference to the new project.
Both your server and client will now be using the exact same classes and you will be able to serialize them in one and deserialize them in the other.
Nick
|
|
|
|
|
Thank you very much! I did what you said,and now it working perfectly.thanks!
|
|
|
|
|
I have created setup of my .net window application. If I am installing same setup in other PCs, first time software is running fine. but if I closed software and again try to open , again installing of setup is started. as
Please wait while while windows configuring XXXXX
any solution for this?
|
|
|
|
|
I am using the property grid and have it doing most things in need. the property grid is loaded with custom class and i have used ExpandableObjectConverter to display subproperties. I would like to know if there is a way to hide one or more of these subproperties at runtime.
In the below link they are doing this with the standard font class. is there a way to do the same with a custom class instead of the font class.
http://www.eggheadcafe.com/forumpost.aspx?redirect=forumpostsubmission&topicid=2&forumpostid=10158840#Post10158840[^]
an example of my custom class is below:
public class CustomClass
{
CustomClassSubProperty m_ccsp = new CustomClassSubProperty();
public CustomClassSubProperty M_ccsp
{
get { return m_ccsp ; }
set { m_ccsp = value; }
}
}
public class CustomClassSubProperty
{
string m_s = "Hide Me";
public string S
{
get { return m_s; }
set { m_s = value; }
}
string m_a = "Show Me";
public string A
{
get { return m_a; }
set { m_a = value; }
}
}
Is there a way I can hide the sub property S in the property grid at runtime? Thanks for the help.
|
|
|
|
|
Yes - Hiding inherited properties[^] works the same for your own ones.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
yeah I can do that but is there anyway i can hide it at runtime. so i can show it if a certain condition and hide not.
|
|
|
|
|
I had once configured my nokia (supporting AT commands), thus, each incomming SMS appeared on my hyperterminal immediately. So it was forwarded automatically from the phone.
But I heave forgot how to configure the phone via AT commands to achieve that. How to do it?
SPIRANCA
|
|
|
|
|
I need to get machine hardware information - what i need to know is the machine memory, computer name, system type ( 32 bit / 64bit ) hard disk size and so on ...
Thanks.
|
|
|
|
|
Yanshof wrote: I need to get machine hardware information
One possibility is WMI[^], but a lot could also be achieved my simply importing the My namespace into the C# project.
Good luck
Current status: looking for a new (paid) challenge
|
|
|
|
|
what do you mean by "importing the My namespace..." ?
Can you please explain.
Thanks.
|
|
|
|
|
The functionality can partially be provided by importing one of the .NET Framework libraries that were originally developed with use for VB.NET - the My namespace contains some fun goodies.
The procedure of adding the reference can be found here[^], also explaining shortly what one can do with it.
I are Troll
|
|
|
|
|
|
hi! i want to give product key requirement feature in desktop application if possible in setup, is there any way this thing is avail in .net or do i have to do some coding in program , please if possible give tutorials.
|
|
|
|
|
it depends how you would like to do it ,
Have a hash of a users hardware id , have it just a random code with "-" in it , have it check online etc
Jed
|
|
|
|
|
i grabbed the idea but a link example will be more helpful meanwhile i will going to try it.
|
|
|
|
|
Webbrowser control doesn't work when opening page "http://photos.weirwindle.org[^]". The problem is: after page is opened, user can click 'start', 'next' or 'previous' only once, after one click, these buttons are disabled!!!
I guess there is something wrong with browser configuration, but both internet explorer and firefox can open this page correctly. I can't figured out this problem for a long while...
I pasted some code on my test application, one textbox, one button and one webbrowser:
private void Form1_Load(object sender, EventArgs e)
{
string url = "http://photos.weirwindle.org";
txtAddress.Text = url;
//webBrowser1.Navigate(url);
}
private void btnGo_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(txtAddress.Text);
}
|
|
|
|
|
Not sure, but maybe this can help you.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|