|
You want to check out object serialization.
Here's a good start:
http://www.codeproject.com/csharp/objserial.asp?forumid=3218&mpp=50&df=100&fr=51&select=2169777&msg=2169777
|
|
|
|
|
I am working on an application using Visual C# (2.0). I want to have something in my application that supports signatures, now I dont`t know how to do it so that it can support ignatures using pen.Please tell Is there any hardware require, and if require then definitly there would be require some interface I mean a software . Please help me how to solve this problem.
|
|
|
|
|
If you buy a digitizer, a tablet, or whatever your manufacturer chooses to call it,
it will come with a cable, a driver and a manual.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hi
I couldn't set the width of a form less than 123 pixels..
I tried not to include maximize and minimize boxes , text and even icon
but form width size still can not be set to less than 123 pixels..
I need form to be about 60 pixels.. can anyone help pls?
|
|
|
|
|
it also depends on FormBorderStyle !
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
You can set the FormBorderStyle property to be either FixedToolWindow or SizableToolWindow.
|
|
|
|
|
Hi,
I have following problem. I am trying to use in c# a simple DLL created in C++ unmanaged code. When I call the function 'square' the debugger enters C++ but gives me following message. I dont know what I am doing wrong. Any ideas? Thanks
A call to PInvoke function 'OptimizerCS!OptimizerCS.LEVMAR::square' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
namespace OptimizerCS<br />
<br />
{<br />
public class LEVMAR<br />
{<br />
[DllImport("OptimizerCPP.dll", EntryPoint="square",ExactSpelling=false,CallingConvention=CallingConvention.Cdecl)]
<br />
public static extern int square(int a);<br />
<br />
void main()<br />
{<br />
int a = 3;<br />
int b = square(a);<br />
}<br />
}<br />
}<br />
namespace OptimizerCPP {<br />
public class OptimizerCPPLEVMAR<br />
{<br />
private :<br />
OptimizerCPPLEVMAR()<br />
{<br />
};<br />
public:<br />
DllExport int __stdcall square(int a);<br />
<br />
};<br />
};<br />
<br />
#include "stdafx.h"<br />
#include "OptimizerCPP.h"<br />
using namespace OptimizerCPP;<br />
<br />
DllExport int __stdcall OptimizerCPPLEVMAR::square(int a)<br />
{<br />
return a*a;<br />
}
|
|
|
|
|
Hi,
in one place you say calling convention is Cdecl, elsewhere you say stdcall.
This is a recipe for trouble; you should be consistent !
All these attributes and keywords actually mean something, they are part of the
contract between the managed and native worlds; if you feel uncertain,
look them up; and for some of them: leave them out, the default may work for you.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
thanks for the answer. I have changed all calling conventions to be the same and recompiled. When I use __stdcall I still have the same error message. I have as well changed in the compiler settings the calling convention to __stdcall (/Gz). Still I get the same error message.
When I use __cdecl I do not get the error message but the returned value is false as it seems to enter the routine not with an int datatype.
Any suggestions?
|
|
|
|
|
PS I forgot to mention that I really need to call using __stdcall convention
|
|
|
|
|
THIS is the info that I've been following to serialize my object. Now, the unfortunate thing about this info is that it does NOT cover serializing any kind of array or arraylist.
Anyone have any info on how to accomplish this???
|
|
|
|
|
all Arrays including ArrayList are marked as Serializable So to serialize them just create your formatter and put your array as the object which must be serialized and for Deserializing that Get the object and cast it to ArrayList or your Array (just like the Article)
ArrayList arr = new ArrayList();
arr.Add(1);
arr.Add(2);
arr.Add("Hello");
arr.Add(new Bitmap(100, 100));
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream ms=new System.IO.MemoryStream();
bf.Serialize(ms, arr);
bf.Serialize(ms, arr);
System.IO.Stream newMS = new System.IO.MemoryStream(ms.ToArray());
ArrayList arr2 = bf.Deserialize(newMS) as ArrayList;
int[] myIntArr = new int[] { 1, 2, 3, 4, 5 };
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream ms=new System.IO.MemoryStream();
bf.Serialize(ms, myIntArr);
System.IO.Stream newMS = new System.IO.MemoryStream(ms.ToArray());
int[] myIntArr2= (int[])bf.Deserialize(newMS);
|
|
|
|
|
I see what it is that you are doing, but not quite what I am trying to do...
I have an object, lets call it Note. And within Note, there are a couple of ArrayLists. Now... I want to serialize ALL of Note. And the info found here:
http://www.codeproject.com/csharp/objserial.asp?forumid=3218&mpp=50&df=100&fr=51&select=2169777&msg=2169777
does not cover how to serialize the whole object WITH any kind of Array or ArrayList.
|
|
|
|
|
On your example the only thing you need is to mark your class as Serializable, just that, and its going to work if all instances you have inside it created from serializable classes which Array and ArrayList are.
[Serializable]
Class Note
{
ArrayList arr1=new ArrayList();
ArrayList arr2=new ArrayList();
int integer=0;
string str=1;
Bitmap bmp=new Bitmap(100,100);
public ArrayList Arr1
{
get{return this.arr1;}
}
public ArrayList Arr2
{
set{this.arr2=value;}
}
public static stream Serialize()
{
BinaryFormatter bf=new BinaryFormatter();
bf.Serialize(stream,this);
return stream;
}
public static Note Deserialize(Stream stream)
{
BinaryFormatter bf=new BinaryFormatter();
return bf.Deserialize(stream) as Note;
}
}
I hope this one help
|
|
|
|
|
So... does that mean that I don't need the Deserialization Constructor and the Serialization Function of GetObjectData???
|
|
|
|
|
|
hehe... that link brings me back to my previous post...lol...
would it be possible to get the link to whatever you were trying to link to???
Thanks
|
|
|
|
|
Sorry About that
i put it all here
<br />
<br />
[Serializable]<br />
class GraphicsPathData<br />
{<br />
byte[] types;<br />
PointF[] points;<br />
FillMode fillMode;<br />
<br />
public GraphicsPathData(GraphicsPath gp)<br />
{<br />
this.types = gp.PathTypes;<br />
this.points = gp.PathPoints;<br />
this.fillMode = gp.FillMode;<br />
}<br />
<br />
public static System.IO.Stream Serialize(GraphicsPathData gpd)<br />
{<br />
System.IO.MemoryStream ms=new System.IO.MemoryStream();<br />
<br />
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();<br />
<br />
bf.Serialize(ms, gpd);<br />
ms.Flush();<br />
return ms;<br />
}<br />
<br />
public static GraphicsPathData Deserialize(System.IO.Stream stream)<br />
{<br />
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();<br />
<br />
object obj=bf.Deserialize(stream);<br />
GraphicsPathData gpd =obj as GraphicsPathData;<br />
return gpd;<br />
}<br />
<br />
public static GraphicsPath GetGraphicsPath(GraphicsPathData gpd)<br />
{<br />
return new GraphicsPath(gpd.points, gpd.types, gpd.fillMode);<br />
}<br />
<br />
public static GraphicsPath GetGraphicsPath(System.IO.Stream gpdStream)<br />
{<br />
return GetGraphicsPath(Deserialize(gpdStream));<br />
}<br />
}<br />
<br />
and I tested that like
<br />
<br />
GraphicsPath gp = new GraphicsPath();<br />
gp.AddEllipse(10, 10, 100, 100);<br />
<br />
GraphicsPathData gpd = new GraphicsPathData(gp);<br />
System.IO.Stream gpdStream = GraphicsPathData.Serialize(gpd);<br />
<br />
<br />
System.IO.Stream newStream = new System.IO.MemoryStream(((System.IO.MemoryStream)gpdStream).ToArray());<br />
<br />
GraphicsPath gpDeserialized = GraphicsPathData.GetGraphicsPath(newStream);<br />
<br />
|
|
|
|
|
Oh MAN!
You are king. Thanks a ton. This is almost exactly what I['m trying to do too...lol...So it works out perfectly!
Only now to code the saving to file...
|
|
|
|
|
Hey, thanks for the great reply at http://www.codeproject.com/script/comments/forums.asp?forumid=1649&fr=126&select=2170482&df=100&mpp=50&msg=2170482
However if i got an 3 arraylist to be serialize, one of them is an arraylist containing graphicspath, how do i deserialize them back to the 3 different arraylist. Should i save the number of items in each of the arraylist?
Below is how i put all the arraylist into a single arraylist
ArrayList arr = new ArrayList();
arr.Add(Arraylist1);//arraylist containing Point[]
for(int i=0;i
{
GraphicsPathData gpd = new GraphicsPathData((GraphicsPath)PathList[i]);
Stream gpdStream = GraphicsPathData.Serialize(gpd);
arr.Add(gpdStream);
}
arr.Add(Arraylist1);//arraylist containing enum
formatter.Serialize(myStream, arr);
myStream.Close();
What other method do you suggest?
Thanks in advance
|
|
|
|
|
I send a post to Graphicspath serialization for you.
|
|
|
|
|
So you have provided me with some fantastic help. Although I'm once again at a loss.
Now that I have a Serialized Stream, how do I save it to a file?
|
|
|
|
|
if you don't need your Stream after serialization process you can simply use FileStream instead of MemoryStream and directly save it to the disk.
but if you need your stream so you can save it using StreamWriter Class
<code>
void SaveToDisk(string path, Stream stream)
{
stream.Seek(0, SeekOrigin.Begin);
using (StreamWriter sw = new StreamWriter(path))
using (StreamReader sr = new StreamReader(stream))
{
sw.Write(sr.ReadToEnd());
sw.Flush();
}
}
</code>
if you had problem with StreamWriter and Reader you can use BinaryWriter and Reader (a little bit harder to use but I don't think you need them)
good Luck my Friend
|
|
|
|
|
I have developed a small database software in .Net 2.0 which has backend as Sql Server Express2005.Both of the server and client are running Windows XP. My client successfully detects the server but when connecting to the server, it displays the error message "Cannot
generate SSPI context".
I have also searched the internet but couldnot find any good solutions.
Could you people have any solution for this terrible error?
Help appreciated in both VB.Net and C#.
X
|
|
|
|
|
Probably should post this in the SQL / ADO / ADO.NET section... If you go over to that forum and search for SSPI, you might even get some answers. The 5th search down should have the answer you're looking for.
Hogan
|
|
|
|