|
|
Thanks,
Thats more precise and clear.
Best Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
With the minor exception that ValueType is an actual type that structs extend. Reference type is only a concept... Well not only, but there is no ReferenceType class. Or would object count? ehh, food for thought.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
BoneSoft wrote: With the minor exception that ValueType is an actual type that structs extend.
Got it, thanks.
And what i have little knowledge about a class is, its like a template for similar objects. Objects are called Reference types. Is that right?
Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
All things .Net extend object, even ValueType. Ints and decimals and string, everything.
A class is the cookie cutter, objects are the cookies.
The primative types like int decmial and the like, plus anything that extends ValueType like enums and anything declared as a struct, are all value types. All interfaces and classes are reference types because they are always heaped. Balue types are meant to be simple because they are stacked.
Try code model generation tools at BoneSoft.com.
-- modified at 10:06 Thursday 29th June, 2006
Balue = Value
|
|
|
|
|
i am using a monthcalendar control in my form. and its my first time to use such control.
how would i be able to know what year is the current display of the calendar
after i clicked the buttons from either side of the navigation button?
one of the functionality of the form is also to save holidays on a certain date. and to determine that date to be a holiday, i should change the backcolor of the specific date of the calendar. how would i be able to do such?
thanks in advance.
|
|
|
|
|
Say I have a structue defined in c++:
struct Test
{
char first_name[80];
char last_name[80];
}
I then use an ostream to write an instance of that stucture to a binary file. How can I read that binary file in c#? I tried to create a similar structure in C# and then deserialize the binary file, but failed. I then read in my c# book that when you serialize an object, not only does the data get stored in the file but the object schema as well, so I can see why my code failed. So how do I go about reading the "pure" binary file in C#?
Thanks!
|
|
|
|
|
Just a shot in the dark, but when you read all the bytes in, are there 160 bytes? If so, that would mean there is no excess data stored, which would mean you could probably just read in the bytes, cast each byte to char, store the first 80 in firstName, the last 80 in lastName, then assign firstName and lastName to your struct fields.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Goof around music jam with my brothers (with video)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango Last modified: Tuesday, June 27, 2006 10:58:29 PM --
|
|
|
|
|
It must be something like this:
using(BinaryReader reader = new BinaryReader(new FileStream("myfile.bin", FileMode.Open)))
{
string firstname = Encoding.ASCII.GetString(reader.ReadBytes(80)).Replace("\0", "");
string lastname = Encoding.ASCII.GetString(reader.ReadBytes(80)).Replace("\0", "");
}
|
|
|
|
|
Can I use this structure in c#? I'm looking for a sample code for reading text file and throwing the values to textbox of richtextbox.
|
|
|
|
|
I dont think so. Just use the code above and put the firstname and lastname in textbox, using :
textBox.Text = firstname + " " + lastname;
|
|
|
|
|
I just wanna ask if what does 80 signifies in this code:
Encoding.ASCII.GetString(reader.ReadBytes(80)); -> the ReadByte(80)
is it the range to be read by the program?
|
|
|
|
|
Yes. reader.ReadBytes(80) return a byteArray with length 80.
Then Encoding.ASCII.GetString convert that byteArray to string.
|
|
|
|
|
So, this code:
using(BinaryReader reader = new BinaryReader(new FileStream("myfile.bin", FileMode.Open)))
{
string firstname = Encoding.ASCII.GetString(reader.ReadBytes(80));
string lastname = Encoding.ASCII.GetString(reader.ReadBytes(80));
}
returns the same value for firstname and lastname?
-- modified at 8:05 Wednesday 28th June, 2006
|
|
|
|
|
No. Firstname is the first 80 bytes. Lastname is the next 80 bytes.
|
|
|
|
|
The thing is, I simplified my question. In reality, the structure I am reading has a big list of vaiables of char arrays, and some ints and shortints. I was under the impression that I can somehow de-serialize it to eqiuvalent C# structure using some attributes or whatnot in System.Runtime.InteropServices. So I guess this is not the case?
|
|
|
|
|
Try to play with this code and see the file test.bin.
using System;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace ConsoleApplication22
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Test t;
t.firstname = "Hello".ToCharArray();
t.lastname = "World".ToCharArray();
using(FileStream fs = new FileStream("test.bin", FileMode.Create))
{
BinaryFormatter b = new BinaryFormatter();
b.Serialize(fs, t);
}
using(FileStream fs = new FileStream("test.bin", FileMode.Open))
{
BinaryFormatter b = new BinaryFormatter();
Test newt = (Test)b.Deserialize(fs);
}
}
}
[Serializable]
struct Test
{
public char[] firstname;
public char[] lastname;
}
}
|
|
|
|
|
That works in C#, i can read it no problem. C++ (non .NET) cannot read it properly.
|
|
|
|
|
That is a special formal from BinaryFormatter. It contains not only firstname and lastname, but also assembly name, etc...
|
|
|
|
|
Hi,
I am new to .Net. I developed a web application in ASP.Net and C#. Here I included a reference to Acrobat COM dll. I actually want to remove the toolbars from the PDF Document. But when I try to run the application, it throws a runtime error "Access Denied". I tried to register the COM dll using:
"regsvr32 Interop.Acrobat.dll". But here the error message is that: "the dll was loaded but entry point was not found".
To deal with the error "Access denied", I included "<identity impersonate="True">" in the web.config file. This helps run the application only on the server. When I try to run the application form a client, it throws a "runtime error" or "Server eror".
Can anyone suggest me a solution. Either how to run the application on clients using identity impersonate="true" or a solution to the Acrobat COM object.
I am facing a tough time and any help would be really appreciated.
Thanks,
Awase.
|
|
|
|
|
hi
how to streaming audio/video playback in windows application ?
do you know whether i should use wmplayer sdk ??
if yes how to do that ?
|
|
|
|
|
If you want to use WMPlayer supported formats and streaming protocols then yes.
Go here -> Clickety[^] for information to get you started.
The one adjustment is if you're running VS 2005 where you add the Windows Media Player component to the toolbox.
Line one reads "Right-click within the Toolbox and then select Add/Remove Items."
For 2005 it should be "...select Choose Items...".
Mike Poz
-- modified at 21:05 Tuesday 27th June, 2006
VS 2005 adjustment...
|
|
|
|
|
Hello,
For doing audio streaming u can use BASS[^]
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
Hello,
I currently have my application, which uses remoting to connect to the server. My problem is that if I change the assembly version on the server, the application will have trouble deserializing and the local copy of the assembly must be updated.
However, if I make very small changes to my app, I will only update the build and revision numbers, and not the major or minor versions. I would like my client and server apps to work if the major.minor version is the same, not taking into account the build.revision part.
I have found the bindingRedirect tag in the application config file, but a) it seems from the docs that when the app looks for a range of versions it will be ok to use a new version, and b) it seems to me that it is for loading assemblies locally, and not from remoting (altough I am not so sure about this.)
[EDIT: I tried bindingRedirect and it works as I expected. I will have to use two bindingRedirects , so that lower versions resolve to my version, and higher versions also resolve to my version. Now I'll have to change app.config for every build. No, that won't do it... and I also tried using an * instead of the revision number -- it didn't work either.]
BTW, my assemblies are strong named.
So, any ideas?
Thanks!!
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
-- modified at 20:59 Tuesday 27th June, 2006
|
|
|
|
|
Hi,
I am getting the name of the class from database as string. I want to create object for this class dynamically.
how do I do it?
|
|
|
|