|
Stealing my signature! :P
Bryan Ray
http://bryanray.net
"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."
|
|
|
|
|
System.AppDomain.CurrentDomain.BaseDirectory returns the current application start folder. It migth do the trick, I use it and it works.
|
|
|
|
|
The first option given does not work. It looks in the application folder for the GUI application. The service however will look in the system32 folder.
MSilviu seemed to have the right anwser. I tested it out and it worked. So thanks for the input.
|
|
|
|
|
Hello.
So these are my problems:
I have to find a way to save a class of mine to a file.
I found serialization and I thought it might work.
But... When I tried BinarySerialization, some chars would just disapear, and I'd get an exception for "not a correct format".
XmlSerialization is throwing non-stopable exceptions, I just went to the one after.
I tried SOAP serialization, but now I came across another problem.
I need to serialize a generic collection which I built. This gives me an exception, saying that it cannot serialize a generic class. (that's after successfuly serializing List<t>).
Another thing that I have with SOAP serialization is that i'm not sure that it'll work in Linux (I was unable to install mono), since I need to import the SOAP class from Windows folder.
Can anyone recommend me on what to do?
Waiting for your help.
NaNg.
|
|
|
|
|
I don’t really understand what the problem is you are experiencing but I could tell you how I serialize into a binary stream I stream can be send or saved to file. Serializing to XML goes the same way. Note both serializer and deserializer and the object definition of the object to serialize should be the same at the sending and receiving end. To ensure this I simply put the classes in a dll which both sides use. With dotnet 1.x the formatter will give an exception when a version difference is detected. In dotnet 2.0 the formatter will serialize everything it recognizes even if there are version differences. The class to serialize should be declared with [Serializable]
///
/// Serialize object to byte array, object must be Serializable
///
/// <param name="someobject" />object to serialize
/// <returns>array
public byte[] Serialize(T someobject)
{
byte[] objectstream=null;
BinaryFormatter f = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
f.Serialize(stream, someobject);
stream.SetLength( stream.Position);
objectstream = stream.GetBuffer();
return objectstream;
}
public void Deserialize(byte[] stream, out T someobject)
{
BinaryFormatter f = new BinaryFormatter();
MemoryStream serstream = new MemoryStream(stream);
someobject = (T)f.Deserialize(serstream);
}
Class def of class to serialize:
[Serializable]
public class SetConfigMessage
{
public string Name = "";
public string Value = "";
///
/// Config message
///
/// <param name="name" />
/// <param name="svalue" />
public SetConfigMessage() { }
public SetConfigMessage(string name, string value)
{
this.Name = name;
this.Value = value;
}
}
madv113
|
|
|
|
|
My problem is that I can't serialize with binary formatter (even like you did, I can't), and SOAP doesn't let me serialize generic classes that I've made.
I don't get what's hard to understand, I wrote it perfectly clear in the first message.
|
|
|
|
|
hi
i am using remoting..
on the remote system wwwroot i have a dll (FXP) which returns several strings(For different varaites of functions)....
now from the client i am getting reply for few functions and for another function i am getting server encountered internal error....
i want to knwo how can i debug and solve the problem...
as far as i know i dont have any security problems i have given all the rights.. to the folders and files which i access,,,,
thanks in advance
bye
|
|
|
|
|
This is just a shot in the dark, but if you have both static methods and instance methods, I would guess the static methods work and the instance don't. I would suggest all the methods be static. Which means you don't have to create an object to use them.
Hope that helps.
Ben
|
|
|
|
|
thanks for the idea ...
i will give try and let u knwo about it..
thanks dude
bye takecare
|
|
|
|
|
does calling a member function on a struct invlove boxing?
(Sorry for the simple question, I got all my books at work...)
|
|
|
|
|
I'm not sure I follow. I don't think so, but perhaps I am not understanding the question ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
struct X
{
int x;
void Foo() { ... }
}
X x;
x.Foo();
Thinking about it, it would be patently silly, so I guess not. But they left default args out of the language, too
|
|
|
|
|
I expect not, no.
Yeah, I've been complaining about default variables for as long as I've been an MVP, who knows, they may one day listen.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: I've been complaining about default variables
shameless plug[^]
|
|
|
|
|
Nope I don't think so as it comes under value types !!
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
It does not, unless you call the method via an interface that the struct implements. The boxing happens when you cast up from the struct to the interface.
|
|
|
|
|
i have install a assembly and i want to use it how can i
|
|
|
|
|
You can import it into a project.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
In solution explorer, right click "References" and select "Add.."
|
|
|
|
|
Hi Everyone,
I have created table in sql with 12 fields
Field1 Field2 Field3 Field4 ……… Field12
I have an excel sheet with 12 columns and 150 rows.
My question is how can I import all of the columns from the excel sheet to my table without losing any information.
thanks
Tirumal.
|
|
|
|
|
This is pretty easy.
1. Make an oledb connection as:
OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ExcelFileName+";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1;\"");
2.Set the command. OleDbCommand ExcelCommand = new OleDbCommand();
3.ExcelCommand.Connection = ExcelConnection;
4.OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand);
ExcelConnection.Open();
System.Data.DataSet ExcelDataSet = new System.Data.DataSet();
ExcelCommand.CommandText = @"SELECT * FROM [SHEET1$]";
ExcelAdapter.Fill(ExcelDataSet);
ExcelConnection.Close();
The ExcelDataSet can be looped thro' and data can be saved to the database.
Hope this helps!
Parimala
|
|
|
|
|
You can use OdbcConnection to open Excel file as a database, then use DataAdater(s) and DataSet(s) to transfer data from excel to SQL Server db
Cheers,
Suresh
|
|
|
|
|
Hi!
I'm trying to load an image from a web site into Image object..
i tried something like this:
<br />
HttpWebRequest hwr = HttpWebRequest.Create("http://www.onet.pl/_m/32006b80b5eb4c237bb11e1a25895e83.jpg") as HttpWebRequest;<br />
hwr.ContentType = "image/jpg";<br />
hwr.Method = "POST";<br />
hwr.BeginGetRequestStream(new AsyncCallback(Callback), hwr);<br />
<br />
void Callback(IAsyncResult result) {<br />
HttpWebRequest request = (HttpWebRequest)result.AsyncState;<br />
Stream stream = request.EndGetRequestStream(result);<br />
<br />
StreamReader sr = new StreamReader(stream);
pictureBox1.Image = Image.FromStream(sr.BaseStream);<br />
}<br />
but i get an exception that the stream is not readable..
i don't get it - why the EndGetRequestStream returns a stream if it's not readable..
anybody knows how to make this work or some other way to load jpgs from http?
thanks for any help!!
life is study!!!
|
|
|
|
|
Seishin# wrote: i don't get it - why the EndGetRequestStream returns a stream if it's not readable..
Since the request is what is sent to the web resource it is expected to be filled with information. You're interested in the response, so switch to the GetResponse or BeginGetResponse method.
"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
|
|
|
|
|
thanks!!!
i also had to switch hwr.Method form "POST" to "GET"..
life is study!!!
|
|
|
|