|
I searched in Google for that book to see what you were talking about, and I couldn't find it.
However, I don't think a book can help you learn much. Sure, you'll learn the basics (I myself have many books from which I've learned the basics for many technologies), but for more advanced knowledge, you have to sit down, roll up your sleeves and do it.
If you want to really learn, I'd say that you set your self a difficult goal (writing a more or less big application, that uses different things -- a smart client app and a web app, both working on a remote database for example). Trying to accomplish something, as opposed to reading about it, will really make you learn.
If you want to learn about the architecture side of an application, MSDN[^] has several good articles and advanced sample applications.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Hi All,
I've try to send a Microsoft Access Database file through the network, sending the file works fine with the same length of the original. The problem is when I try to open the file at the client side a message appears (“unrecognized database format ").
Any help please, Thanks
Kind Regards,
Mohammad
|
|
|
|
|
How do you send the file?
---
b { font-weight: normal; }
|
|
|
|
|
// Server Side.
FileInfo file = new FileInfo("Inventory.mdb");
// Send the file lenght to the client.
this.client.Send(Encoding.ASCII.GetBytes(""+file.Length));
// Send only database.
FileStream MyFile = new FileStream("Inventory.mdb", System.IO.FileMode.Open);
byte [] output = new byte[file.Length];
// Reading the file.
MyFile.Read(output, 0, (int)file.Length);
MyFile.Flush();
// Send the file to the client.
this.client.Send(output);
MyFile.Close();
---------------------------------------------------------------------------------------
// Client Side.
// Recieve the file length
input = new byte[1000];
int length = this.server.Receive(input);
length = int.Parse(Encoding.ASCII.GetString(input,0,input.Length));
// Receive the file.
input = new byte[length];
length = this.server.Receive(input);
// Create the Backup file.
FileStream myDataBase = new FileStream("CopyofInventory.mdb",System.IO.FileMode.Create);
myDataBase.Write(input,0,input.Length);
myDataBase.Close();
Thanks,
Mohammad
|
|
|
|
|
From what I can tell from the code, you read 1000 bytes into the array input, then parse the length from he beginning of that. If the length occupies the first 6 bytes of the stream, you will be discarding the first 994 bytes of the actual database file.
---
b { font-weight: normal; }
|
|
|
|
|
I want to use VC++ *.lib into C# application. I know that I must compile the lib in to a dll. How can i do that? Any method and hits to me.
|
|
|
|
|
One way is to create a new .NET project called Class Library and copy over your VC++ code. Sometimes the "It Just Works" effect will be able to translate the code. Then when you compile it, you will have your dll which you can make other projects reference. The easier way would be to open the .lib project in VC++ 6.0 and go into Project->Settings and change the output from a static library (.lib) to a dynamic library (.dll). Compile it in VC++ 6.0 to get your .dll file, which your .NET project will be able to reference.
|
|
|
|
|
As the other reply says, I would link your static library (.LIB) into a regular DLL using Visual C++ 6.0. Then I would use P/Invoke to call into the unmanaged DLL from .NET.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
I'm trying to serialize a tree-like structure, and I get a System.InvalidOperationException: "When serializing an object of type RTBranch, a circular reference was found".
I've trached this to a public property which I don't want to be serialzed anyway, but the compiler says I can't apply the [NonSerializable] attribute to this. Removing the property fixes the problem (but obviously that's not what I want )
So far, the data only has a single branch (the root), but RTBranch has a public property AllBranches { get }which (recursively) returns all branches (i.e. this and all child branches, child child branches) in an ArrayList.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
You can use the [XMLIgnore] (MSDN[^]) attribute on the offending property to stop it being serialized
"I think I speak on behalf of everyone here when I say huh?" - Buffy
-- modified at 3:36 Sunday 4th September, 2005
|
|
|
|
|
Thanks!
Would that work for non-XML serialization too?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
No, I believe XMLIgnore attribute works only for XML serialization. I belive NonSerialized attribute is meant for binary serialization.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hm... a little inconsistency.
Is is actually possible to tag only the attributes / properties I want to serialize?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Actually, I may have misled you in my previous post. The Serializable and NonSerializable attributes apply to wide-scale serialization: for example, if you wanted to use .NET remoting to send an object over to another process or another machine, these attributes would apply.
The XmlIgnore and XmlInclude attributes really apply only to the specialized case of XML serialization.
However, I use Xml serialization so rarely, you might be better off getting an answer from someone more experienced with it. At work, we almost exclusively do binary serialization, as it's quite a bit faster. The only xml serializing we do is with application config files, and even then, there's built-in support in the framework for configuration files.
peterchen wrote:
Is is actually possible to tag only the attributes / properties I want to serialize?
Sure. Mark your class as Serializable, then have it implement ISerializable. This will allow you to control precisely what data is saved and what is ignored.
*edit* Or, optionally, just mark your class as Serializable, then mark each field you don't want serialized as NonSerializable.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
-- modified at 21:02 Sunday 4th September, 2005
|
|
|
|
|
When I execture my app "normally", I get a complete exception description. However, when I run it under the debugger, I only get a general text in the "Output" Window.
Any way to have full exception reporting in debug mode?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
(1) How to make a button the default one?
(2) How to rearrange the control order (except juggling the TabOrder property on each control individually, trying not to hit one that was already used)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
-- modified at 3:00 Sunday 4th September, 2005
|
|
|
|
|
How to make a button the default one?
Use the Form's AcceptButton property (under Misc)
How to rearrange the control order
I'd like to know too - I only ever found it once and that was by accident
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
|
Sweet
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
Hi all,
Can anyone please explain how to add a binary file resource such as a wav, zip, avi, etc... to a .resources file BY CODE?
I've been searching msdn site for an answer but all the examples apply to Visual Studio .NET resource editors, as all programmers own and use it, right? And correct me if i'm wrong, Microsoft says that files can only be embeded directly to the assembly and not to .resources files.
I use notepad to write software and compile with batch files, so never think about suggesting me on using Visual Studio .NET resource editors.
Thanx man,
Heinz
|
|
|
|
|
I would look closely at the System.Resources.ResourceWriter class; I think it does everything you're looking for.
I actually used it one time when I wanted to embed some sound in a Windows app.
Something like the following would probably do the trick if you're just wanting to write binary resources to the file:
using System;
using System.IO;
using System.Resources;
using System.Runtime.Serialization.Formatters.Binary;
class ResourceUtility
{
public static void WriteResourceToFile(string name, object graph, string fileName)
{
BinaryFormatter serializer = new BinaryFormatter();
MemoryStream mem = new MemoryStream();
serializer.Serialize(mem, graph);
using (ResourceWriter writer = new ResourceWriter(fileName))
{
writer.AddResource(name, mem.GetBuffer());
writer.Generate();
writer.Close();
}
}
}
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi,
Thanx for your method. I use ResourceWriter in my programs to create resources and your method use it too so it's easy to understand how it works.
BUT, how do i call this function, i mean: If i want to add a .wav, a .zip or a .txt file, which parameter should i pass to the graph object?
For example: If i want to add an image i send the parameter 'Image.FromFile("C:\MyImage.jpg");' to the graph object.
If a want to add and icon i send the parameter 'new Icon(C:\MyIcon.ico);'
Thanx in advance.
|
|
|
|
|
If you have a file whose contents you want to add to a .resources file, use a FileStream to read the contents of the file, and the buffer from that stream as the source of the resource you're adding.
My example was just a generic example assuming you wanted to add a managed object as a resource.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi, thanx for your reply. I just want to add a .zip file for example, if i add this zip to a .resources with a visual editor like "Resourcer" or the sharpdevelop editor, you can see the object type, when i add the zip the type shown is System.Byte[] and this type is shown for all the binary files cause managed object shows as System.Drawing.Icon System.Drawing.Image System.String
I just want to add by code a non managed file so the type shows as System.Byte[]
I've tried all but never found how.
Thanx in advance
|
|
|
|
|
As I mentioned in my previous message, if you have a file you want to embed in a resource file, create a file stream using the target file, read the stream from start to end (will yield a byte array - type = byte[]), then use that byte array as the source of the resource entry. When you read the bytes back out of the resource, you can then use whatever kind of writer you want to "rehydrate" the bytes into a file, an image etc.
Here is an example of embedding a single .JPG image in a resource file - it's a trivial example, but it works and should get you started in the right direction:
public static void WriteResourceToFile(string importPath, string resourceKey, string resourceFileName)
{
byte[] buffer = null;
using (Stream file = new FileStream(importPath, FileMode.Open, FileAccess.Read))
{
buffer = new byte[file.Length];
file.Read(buffer, 0, (int)file.Length);
file.Close();
}
using (ResourceWriter writer = new ResourceWriter(resourceFileName))
{
writer.AddResource(resourceKey, buffer);
writer.Generate();
writer.Close();
}
}
The preceding function could be called to store an image file using:
ResourceUtility.WriteResourceToFile(@"c:\pic1.jpg", "pic1", "image.resources");
To read the image back out of the resource file, you could implement something like:
private System.Drawing.Image ReadImageResourceFromFile(string resourceFileName, object resourceKey)
{
MemoryStream stream = null;
Image i = null;
using (ResourceReader reader = new ResourceReader(resourceFileName))
{
IDictionaryEnumerator loop = reader.GetEnumerator();
while (loop.MoveNext())
{
if (loop.Key == resourceKey)
{
byte[] buffer = (byte[])loop.Value;
stream = new MemoryStream(buffer);
break;
}
}
reader.Close();
}
if (stream != null && stream.Length > 0)
{
stream.Position = 0;
i = Image.FromStream(stream);
stream.Close();
}
return i;
}
...and could be called using:
System.Drawing.Image result = ReadImageResourceFromFile("image.resources", "pic1");
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|