|
in SerializeApp :
[SerializableAttribute]
ref struct MyStruct
{
int n;
int j;
};
MyStruct ^my=gcnew MyStruct;
my->j=1;
my->n=1;
FileStream ^file=gcnew FileStream("c:\\Test.dat",FileMode::Create);
BinaryFormatter ^formatter=gcnew BinaryFormatter;
formatter->Serialize(file,my);
///////////////////////////////////////////
In DeserializeApp :
FileStream ^file=gcnew FileStream("c:\\Test.dat",FileMode::Open);
BinaryFormatter ^formatter=gcnew BinaryFormatter;
try
{
MyStruct ^my=(MyStruct ^)formatter->Deserialize(file);
}
catch (SerializationException^ e)
{
textBox1->Text=e->Message;
}
Error:
Unable to find assembly 'SerializeApp, Version=1.0.2987.23837, Culture=neutral, PublicKeyToken=null'.
|
|
|
|
|
|
Good article Giorgi!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark
|
|
|
|
|
|
You are welcome
|
|
|
|
|
When I Seriliaze Object In the File how To save Assembly Name And Typename with My self
|
|
|
|
|
Hi,
I'm using a commandbox for the user to select commands and they pass these commands to a listbox and therefore whatever commands in the listbox are ran when the user clicks on "Run Commands" button.
The problem is if more than one command in the list box then only the first command is ran. If I try to add a queue behind the listbox then the program crashes.
Anyone have any ideas to solve this problem?
Cheers
<br />
<br />
if(lstCommands->Items->Count >0)<br />
{<br />
if(lstCommands->Items->Contains("Move forward")) <br />
{ <br />
this->lstLogCommands->Items->Add(numLog + " Move forward");<br />
}<br />
else if(lstCommands->Items->Contains("Move Back"))<br />
{<br />
protocol_test(3);<br />
this->lstLogCommands->Items->Add(numLog + " Move Back");<br />
}<br />
else if(lstCommands->Items->Contains("Turn Right"))<br />
{<br />
protocol_test(4);<br />
this->lstLogCommands->Items->Add(numLog + " Turn Right");<br />
}<br />
else if(lstCommands->Items->Contains("Turn Left"))<br />
{<br />
protocol_test(5);<br />
this->lstLogCommands->Items->Add(numLog + " Turn Left");<br />
}<br />
<br />
numLog++;<br />
}<br />
else if(lstCommands->Text->Empty)<br />
{<br />
MessageBox::Show("No Commands selected","NoCommands",MessageBoxButtons::OKCancel,MessageBoxIcon::Exclamation);<br />
}<br />
}<br />
<br />
<br />
queue <int> q;
int i;<br />
while (lstCommands->Items ->Count >> i)<br />
q.push(lstCommands->Items->Count >> i);<br />
while (!q.empty())<br />
{<br />
cout << q.front() << " ";<br />
q.pop();<br />
</int>
|
|
|
|
|
gman2008 wrote: queue q; //queue int q - int brackets round it
Does that mean
queue<int> q;<br /> ? If so you really need to figure out how to post code before you try to get us to decipher it.
is this also a posting mistake?
gman2008 wrote: while (lstCommands->Items ->Count >> i)
because if you really have a right shift operator there then I guess you have no idea what you are doing. You need to go read some documentation on the '>>' operator[^]
led mike
|
|
|
|
|
It is hardly to find article or information on c++/cli .net asynchronous socket programming. I even cannot find a piece of it on internet. Any have it? Most i can find is in c#.
When i try convert and use this code as below:
m_mainSocket->BeginAccept(gcnew AsyncCallback(OnClientConnect), null);
AsynCallback^ pfnWorkerCallBack = gcnew AsyncCallback(OnDataReceived);
it show error like this:
error C3867: 'ServerChat::Form1::OnClientConnect': function call missing argument list; use '&ServerChat::Form1::OnClientConnect' to create a pointer to member (i try put full function prototype onClientConnect(IAsyncResult^ asyn) but still error)
error C3867: 'ServerChat::Form1::OnDataReceived': function call missing argument list; use '&ServerChat::Form1::OnDataReceived' to create a pointer to member
error C3350: 'System::AsyncCallback' : a delegate constructor expects 2 argument(s)
error C2065: 'null' : undeclared identifier
other errors just same with those listed. Help pls...
modified on Wednesday, March 12, 2008 11:09 PM
|
|
|
|
|
Member 4542272 wrote: it show error like this:
error C3867: 'ServerChat::Form1::OnClientConnect': function call missing argument list;
see if this helps[^]
led mike
|
|
|
|
|
Hey mike, i did find and read articles often but problem is i cannot find any relevant information or solution. Thx for your reply but this help ntg.
|
|
|
|
|
Also, those C# articles can be helpful - The .NET framework is the same - so is the code logic. The
code syntax is pretty similar too....
The first two errors are pretty obvious (or should be) from the error message. ..In C++ you don't get the address
of a member function that way anymore - you use the address-of operator, as shown in the error message.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark, the c# articles really useful to get me in c++/cli.
Can u simply show me how to use the address of operator for a function to solve that error? Thx.
|
|
|
|
|
did you try this?
m_mainSocket->BeginAccept(gcnew AsyncCallback(&ServerChat::Form1::OnClientConnect), null);
AsynCallback^ pfnWorkerCallBack = gcnew AsyncCallback(&ServerChat::Form1::OnDataReceived);
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
By doing AsyncCallback(&Form1::OnClientConnect) the problems is solved but it still prompt a strange errors like this:
error C3352: 'void ServerChat::Form1::OnClientConnect(System::IAsyncResult ^)' : the specified function does not match the delegate type 'void (System::IAsyncResult ^)'
It is exactly the same type why it still happen to be an error?
I try put static void OnClientConnect(IAsyncresult^ ar) as fuction can solve it somehow but it prompt out error after put static to the function like this:
error C2227: left of '->Text' must point to class/struct/union/generic type
by right richTextBoxRcvMsg->Text don't have any problem.
error C2227: left of '->EndAccept' must point to class/struct/union/generic type
by right m_Socket->EndAccept(ar) don't have problem.
Someone help pls..
modified on Monday, March 10, 2008 6:36 AM
|
|
|
|
|
Are these the new questions you referred to?
Can you provide some relevant code that causes the errors?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yup.
The relevant code i already stated at the new question thread. I will make it more clear here.
I try solve error:
(1)error C3352: 'void ServerChat::Form1::OnClientConnect(System::IAsyncResult ^)' : the specified function does not match the delegate type 'void (System::IAsyncResult ^)'
by putting static to function void OnClientConnect(IAsyncResult^ ar) and relevant functions.
The error gone but doing this the statement within the function:
richTextBoxRcvMsg->Text = str;
come out error:
(2)error C2227: left of '->Text' must point to class/struct/union/generic type
I just don't understand that even richTextBoxRcvMsg is a form component within the class this still happen. Is that i need to make the ref class static also?
Instead of using static to the function, i just got a suggestion to try with this code:
Asynchronous(this, &Form1::OnClientConnect);
Later i back home only can try.
modified on Wednesday, March 12, 2008 11:11 PM
|
|
|
|
|
Hi,
I need to create a file inside the directory.I have to get the directory name and file name from the textbox. How to do this ? Can you help me.
Note:-
I can able to create a file(getting the file name from the textbox).
I can able to create a directory also(getting the directory name from the separate textbox).
|
|
|
|
|
Specify the full path to the file when you create it. Otherwise, you will create it in your working directory
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I am creating a modeldialogbox,I wrote the code as follows.
void Mform::newToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
Form ^dlgl= gcnew Form();
this->btn = gcnew Button();
this->btn->Text = L"OK";
this->btn->Location = System::Drawing::Point(100,160);
this->btn->Click += gcnew System::EventHandler(this,&Mform::bt1_Click);
this->label = gcnew Label();
this->label->Text = L"Enter the filename : ";
this->label->Location = System::Drawing::Point(45,20);
this->label->Size = System::Drawing::Size(113,13);
this->textbox = gcnew TextBox();
this->textbox->Location = System::Drawing::Point(178,20);
this->textbox->Text = "";
this->textbox->Multiline = true;
this->textbox->AcceptsReturn = true;
this->textbox->AcceptsTab = false;
this->textbox->WordWrap = true;
dlgl->AcceptButton=btn;
dlgl->CancelButton = btn1;
dlgl->MaximizeBox = false;
dlgl->MinimizeBox = false;
dlgl->Controls->Add(this->btn);
dlgl->Controls->Add(this->btn1);
dlgl->Controls->Add(this->label);
dlgl->Controls->Add(this->textbox);
dlgl->ShowDialog();
}
void Mform::bt1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->rtext = gcnew RichTextBox();
String ^path1;
path1=textbox->Text::get();
if(path1 == "")
{
MessageBox::Show("Enter the filename","Error",MessageBoxButtons::OK);
}
else{
FileInfo ^fi = gcnew FileInfo(path1);
if(fi->Exists)
{
MessageBox::Show(" filename exists","Error",MessageBoxButtons::OK);
}
else
{
FileStream ^fs = fi->Create();
this->f = gcnew Form();
this->f->MdiParent = this;
this->f->Show();
this->rtext->Dock = DockStyle::Fill;
this->f->Controls->Add(this->rtext);
}
}
}
In this code when i press ok button, it perform needed the operation but the dialog box is not closed.
help me. where i done a mistake.
|
|
|
|
|
In Winforms, you need to either close the form in code, or set the AcceptButton and CancelButton properties, etc, in the forms designer, to set up which button(s) close the form.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Can you tell me how to create a model. I need a step by step process.
I read msdn already i couldn't understand. Can you guide me.
Thanks,
|
|
|
|
|
Do not repost your questions. it's rude.
led mike
|
|
|
|
|
I am doing project using visual c++ 2005 clr windows form application.I used a treeview& a contextmenustrip. On right clicking the rootnode the strip contains "Add&Find" item.I need some code samples to add & find a node using visual c++.Send me the same.
Thanks in advance
|
|
|
|