zachattack05 70 Posting Pro in Training

You mean 3 dlls or 3 different classes?

I'm assuming you meant classes...dll hell sucks :)

zachattack05 70 Posting Pro in Training

Greetings!

Wondering if someone had some ears (or eyes I guess) I could bounce some concepts off of regarding a Client/Server system design.

All technicalities aside (such as message framing etc..) I was wondering if anyone had ideas for how a system like that should be set up?

Currently my concept involves the following:

  1. A Server Control Panel (GUI Interface)
  2. A Server Service (Windows Service)
  3. Communication Management System (Server core)

The Server Control panel simply queries the Communication Management System to get information about the windows service (is it running? start it, stop it, change a setting etc...) The server control panel also contains a log viewer as well.

The Server Service is the actual service that can run on the windows system. This allows the server to run in the background without a GUI open or hidden in the task bar...you know...a service.

Communication Management System is a library (dll) of commands that the control panel AND the service can use to communicate with each other AND with any users connected to the system. I think I want this in it's own library for one simple reason: The server manager can, at any time via the Control Panel (and also during system setup) indicate that the server should run "in service mode" or "only when the control panel is open." By putting the server commands in a dll, it can be shared (preventing redundant coding).

Is this the standard way …

zachattack05 70 Posting Pro in Training

Thank you sir!

zachattack05 70 Posting Pro in Training

If I have an internal class that implements an interface, the interface method must be public. Is that interface method visible to other assemblies or does the internal class that implements the interface prevent it from being visible?

zachattack05 70 Posting Pro in Training

I don't really understand what you are trying to achieve. are you trying to find a percentage of a given number or are you trying to multiply a number by a percentage of another number?

A percentage is based on the number 100 and is just some number divided by 100...just rummage through your input and isolate any numbers with a %, drop the % symbol, divide the number by 100 and finish the rest of the math.

Your example of 10*100% is confusing though...you can't multiply 10 by 100% because the 100% is out of context. 100% of what? 50? 20? 3.14? I'd recommend you first find a different input method because the string you gave as an example doesn't make much sense...I'm assuming you want to find 100% of 10...which is 10 of course but let's say you want 50% of 10 instead...

The real math is 10*0.5 = 5...so, just isolate the percentage (50%) drop the % sign and divide 50 by 100 = 0.5 and then move on with the math 10*0.5.

Sorry if that doesn't make sense, but the example is a bit confusing to me.

Is this a console program or winforms? If it's a console it might be more difficult because you need to work with a string instead of having a input box. But I could be wrong...I don't like console programs...never made one.

Another consideration is multiple operators...what would your program do if given this: 10*100%*50? Just something to ponder...

zachattack05 70 Posting Pro in Training

You could write your own setup program, or you could use the Visual Studio Installer template or InstallShield LE template included in VS.

You could also use Click-Once deployment which I believe is under the project properties screen under "Publish..." I think...

Try starting here.

Good luck!

zachattack05 70 Posting Pro in Training

paddypowa,

You could have a system that displayed a password in a messagebox or email the password, but in my experience and I'm sure others will agree...storing passwords in a database in plain text is a bad idea and could potentially be a security issue. Strike that...it IS a security issue.

I'm assuming that since you are having users create usernames and passwords that there is, or there is the potential to be, sensitive (however you wish to define that) data stored somewhere in the application. User based systems usually are designed so that certain users see only certain things. Storing passwords in plain text (unencrypted) could allow someone to "sniff" the packets with passwords if the data is transmitted over a network, or if someone gains physical access to the SQL server, they could download and see all the usernames and passwords in plain text. Not cool.

A much better idea, in my opinion, is to not allow for password retrieval, but have a system in place to reset passwords, by utilizing a secret question/answer, or simply have the request send a email to the user with a new temporary password or something.

I would highly recommend you encrypt your passwords in some fashion...just a FYI so you don't end up with security concerns later.

Check out the System.Security.Cryptography Namespace if you are unaware of it. I'd go with a hash type of encryption such as any of the SHA-2 options (SHA256, …

Antenka commented: Imho, worth more points than -1 :) +7
zachattack05 70 Posting Pro in Training

Not sure how to answer your question, but as a bit of info (only in case you didn't know) MSDN states that applications shouldn't be developed using this technology anymore and instead should be using WCF. MSDN Website.

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

Just a FYI. :)

zachattack05 70 Posting Pro in Training

ddanbe,

I'm with you. WPF is odd to me. The whole thing is unfamiliar and every time I try working with it I get frustrated and end up deleting whatever I spent hours on with nothing to show for it (don't tell anyone...I still get paid for it) but I think I'm going to have to bite the bullet and figure it out eventually. I just wonder if it's a fad.

I've always been under the impression that a fancy, dramatic, colourful UI is just a cover for poor programming. Course that's not true, but it's been my perception for a long time. I'd rather spend more time making the application work, and work well and be intuitive than work on flair.

Just my opinion though.

ddanbe commented: Well said! +8
zachattack05 70 Posting Pro in Training

Ha! Good idea momerath...forgot about WPF...I never use it.

zachattack05 70 Posting Pro in Training

Draw them? :) Wouldn't be much fun, but I'm sure you could? If not, maybe there's a library out there you can buy, or you could use images?

Just some quick thoughts.

zachattack05 70 Posting Pro in Training

Do you have the source for the c# executable? I haven't used VB in...wow...forever. But it's hard to offer up suggestions without some source code to go with it :)

zachattack05 70 Posting Pro in Training

Ahh, sorry, not a .Net web developer so I can't help you there :( I only use PHP on the web :)

zachattack05 70 Posting Pro in Training

Very true. Even if you could filter that one, I would leave it be.

zachattack05 70 Posting Pro in Training

Thank you so much!

zachattack05 70 Posting Pro in Training

I have a page that displays information about a person and contains a "contact me" form. I don't want anyone to know the email address of the person, that's the reason for the form. My submit button executes some code behind to send the email message.

How can I securely pass the email address?

Right now, when the person's information is displayed, I save their email address as a session variable. I then read it back in the code behind method. Is there a better way to do this? In the past I've had the action code lookup the email address, but that still means I must pass their ID number.

Suggestions?

If you are talking about a web page, don't you have to have SSL to transmit data from a browser to your webhost in a secure fashion?

zachattack05 70 Posting Pro in Training

Heres a super simple example of what I'm talking about.

Hope it helps.

zachattack05 70 Posting Pro in Training

Could you open a form with no border and set it to "maximize" on open and make it semi-transparent. Open the form(s) that the user must interact with on top of the semi-transparent form and when they are finished interacting with it, close the form with no border.

If you want to truly do that though, you would need to also capture certain keystrokes that the user could use to defeat it. The Windows Logo key, Alt+Tab as well etc...never tried it but it doesn't sound too complex to do really.

I'll put together an example and post it in a few minutes.

zachattack05 70 Posting Pro in Training

I tried asking this at the MSDN website and didn't get an answer at all...I was hoping someone here could help.

If I indicate that SQL Server Express is to be a pre-requisite for my application, how does the installer interpret this? For example:

If end user A already has SQL Server Express installed when they install my application, does my application create a new instance of a SQL Express Server or does it use the one that's already available? What about if there are multiple instances installed already or if the instance name I specified is already taken?

If end user B already has SQL Server Express installed and my application uses the installation they already have, what happens if there is a database name conflict? In other words, they already have a database with the same name that my application uses in that instance?

Finally, if end user C does not have SQL Server Express installed, but has a retail version of SQL Server installed, will my application use the retail version or install the express version along with it?

Sorry for the odd questions but I have yet to find an answer to these questions and I'd rather not spend hours developing an application and run into a surprise.

kvprajapati commented: Nice question. +12
zachattack05 70 Posting Pro in Training

Hey, here's a thought...What about a COM addin or something for Word? We could have our own tab on the ribbon and custom commands that would communicate with the data server...that might be easier and we wouldn't have to imitate any sort of protocol, we can continue to use our own.

What do you think? I think I might suggest that instead of trying to deal with the built in MS Mail Merge feature.

zachattack05 70 Posting Pro in Training

Hi Mike,

Thanks for the reply. The custom file format and server app is/was, used for security reasons and to prevent tech support nightmares. SQL servers, while they are secure and efficient when setup correctly can cause tech support nightmares and finger pointing (the problem isn't our application, its your server setup! Call Microsoft or read blah blah blah) you get the idea.... A standard business user may have 5 or 6 computers accessing the server at any given time, and a SQL server, while efficient, can be a problem for those clients who like to "tinker" with it, leaving us to find out what they tinkered with and fix it if it stops working...and god forbid they lower security and data gets stolen, it makes our application look bad even if it wasn't our application's fault.

The other problem we discussed and was a large factor for deciding against a SQL server was because of the lack of control on our end. If the client already has a SQL server running on their network and they wish to install our application, there could "possibly" be conflicts with other databases (names most likely) and possibly user permission problems. With a SQL server controlling permission to access certain data, a user is required to setup users on the server for everyone that could access the data. Another concern we had was our general database design. We would potentially need multiple databases and multiple tables and each would have to …

zachattack05 70 Posting Pro in Training

I am working on a project that stores it's data in serialized files on the hard drive in a custom file format. The server end of the application accepts TCP connections from clients and returns data to the clients based on the query, it's kinda like a light weight, custom SQL server, but no where near as complex.

I have been asked to make the server available to outside applications, such as Microsoft Word for the purposes of mail merges.

The question I have is, instead of implementing a custom ODBC driver or something insanely complex and beyond my expertise, I was wondering if it was possible, easier, or even legal, for the server application I have to "pose" or present itself as a SQL server, or something, and actually accept connections from remote computers who setup the mail merge to retrieve data from a SQL Server? So if a client machine has a SQL ODBC driver already installed, they can select it, type in the connection information to the server running my server application and have my application accept the connection, process queries from the driver and return the data it requested? Kind of like a mini-SQL server?

The only other thing I could think of is to have an option in the server controls to periodically dump the data into a csv file or something and network users can connect to the csv file to get data...I just seem to see file permission errors amok …

zachattack05 70 Posting Pro in Training

Have you looked at the inner exception? Not sure if this will help, but it's the first place I'd look.

Me too...it's null :(

The exception occurs when EndEdit() is called on the bindingSource with the error. I just can't figure this out...The exception message says: "Column 'ParentCode' is constrained to be unique. Value 'ATI2' is already present." so the information I am looking for can be found, it has to be there...I just can't find it!

Here's the exception details from the debugger, do you see anything that I might be missing?

System.Data.ConstraintException was caught
Message=Column 'ParentCode' is constrained to be unique. Value 'ATI2' is already present.
Source=System.Data
StackTrace:
at System.Data.UniqueConstraint.CheckConstraint(DataRow row, DataRowAction action)
at System.Data.DataTable.RaiseRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataRow.EndEdit()
at System.Data.DataRowView.EndEdit()
at System.Windows.Forms.CurrencyManager.EndCurrentEdit()
at System.Windows.Forms.BindingSource.EndEdit()
at DATA.Editors.Companies.toolStripButton1_Click(Object sender, EventArgs e) in U:\Projects\DATA\DATA\Editors\Companies.cs:line 38
InnerException:

zachattack05 70 Posting Pro in Training

I am putting together an editor for an application I am creating.

The data ultimately resides on a SQL server.

The application loads some of the data from the server into a dataset, which is used by a bindingsource which is then used by a bindingnavigator. (wow that's a mouthful).

The issue is, the dataset contains some constraints, one of them involves a "code" that must be unique, similar to an account number for any company, they can't repeat but are more useful to end users than the identity data.

Anyway, if I have 2 records, and the code for one record is A and is B for the other...if I change B to A, I get a constraint exception. Great! That's what's supposed to happen, except that there are other text box controls on the form that are bound too dataset fields that have a unique constraint...is there any way at all of finding out what form control contains the invalid data?

Also, to throw another wrench in the gears, the form contains 2 total bindingsources, both of which are bound to tables that have unique constraints.

I have looked everywhere I can think of and I can't find anything on handling these errors correctly other than a message box that just shows the standard e.Message error (which is useless if you ask me).

Anyone?

zachattack05 70 Posting Pro in Training

if you wanted it entered as you type you could use the text changed event instead.

I don't like masked textboxes personally, I think they look messy, but they do work just as well...I think....I think masked textboxes can only have a length equal to the mask though...but I could be wrong.

zachattack05 70 Posting Pro in Training

You could use a masked text box instead of a regular text box and just make a mask to match?

I haven't tried, but setting the mask to something like 0,000,000.

I guess the other option would be after the user inputs the data and the textbox loses focus, just run a quick method to get the length of the data input into the box and start inserting "," in the box.

Like this:

private void textBox1_Leave(object sender, EventArgs e)
        {
            //make sure the textbox isn't empty
            if (textBox1.Text != string.Empty)
            {
                //get the data from the textbox
                string TextBoxData = textBox1.Text;

                //use a string builder
                StringBuilder StringBldr = new StringBuilder(TextBoxData);

                //remove any "," strings already in the field in case the user put them in
                StringBldr.Replace(",", "");

                //find out how long the textbox data is
                int TextLength = StringBldr.Length;

                //use 3 here to put a "," every 3 characters
                while (TextLength > 3)
                {
                    StringBldr.Insert(TextLength - 3, ",");
                    TextLength = TextLength - 3;
                }

                textBox1.Text = StringBldr.ToString();
            }

        }
zachattack05 70 Posting Pro in Training

I think it is serializing the data into the exe...when i add images to the image list and then delete or change the name of the source image, it still works in the debug version of the application. The .exe file size also increases. But does anyone know for sure?

zachattack05 70 Posting Pro in Training

You'll need to add them to the project if you want them packaged up for distribution.

So would it be safe to add the image as a project resource, then just select the image that is in the project resources folder?

I read here that if I add images to an image list they ARE compiled into the app for distribution...is there anything official from Microsoft on this?

zachattack05 70 Posting Pro in Training

If I add an imagelist control to my project it asks me to select images from the hard disk. When my application is compiled and distributed are the images I selected serialized and/or compiled into the exe? or do the images need to reside on the end-user computer in the same location?

zachattack05 70 Posting Pro in Training

I think I solved my problem.

Here's the solution I came up with...suggestions welcome:

private void Main_Load(object sender, EventArgs e)
        {
            treeViewSettings.ExpandAll();

            UserSettings = new LocalSettings();
            UserSettings = UserSettings.Load();

            //General Tree
            panelContent.Controls.Add(new General.Root());
            panelContent.Controls.Add(new General.Help());

            //DataAccess Tree
            panelContent.Controls.Add(new DataAccess.Root());
            panelContent.Controls.Add(new DataAccess.DataManagementSystem());

        }

        private void treeViewSettings_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            foreach (Control x in panelContent.Controls)
            {
                x.Hide();
            }
        }
        private void treeViewSettings_AfterSelect(object sender, TreeViewEventArgs e)
        {
            string TreeNameToLoad = treeViewSettings.SelectedNode.Name.Remove(0, 4);
            string ControlNameToLoad;

            foreach (Control x in panelContent.Controls)
            {
                ControlNameToLoad = x.ToString().Replace("DATA.Settings.", "").Replace(".", "");

                if (TreeNameToLoad == ControlNameToLoad)
                {
                    x.Show();
                    break;
                }
            }
        }

Not very graceful, but it works so long as each tree node name is prefixed with "Node" and each usercontrol name matches the the name of the node it corresponds with.

zachattack05 70 Posting Pro in Training

I'm lost on this one.

I'm creating a "Preferences" type form. On this form I have a tree view and a panel.

I have created multiple user controls, each to be displayed in the panel when a certain tree node is selected.

The problem I am having is finding the best way to display the correct user control when a node is clicked. All I can seem to reference in the Panel.Controls collection is an index number and that is rather useless to me because I cant find a value in the tree view to correspond to it.

Is there a way to "bind" so to speak, a tree view node to a user control?

How would you go about doing something like this and keep it relatively easy to maintain and update?

Any suggestions are welcome.

zachattack05 70 Posting Pro in Training

kplcjl,

Your right. I was a bit tired and frustrated when I wrote that.

The problem was not creating a database, it was that the name of the database was incorrect. It's okay though, I figured it out and everything is working now.

Thanks for the help!

zachattack05 70 Posting Pro in Training

I guess the rest of the code should be present.

Yes, using SQL parameters does prevent injection attacks...at least thats what it is advertised as doing.
(MSDN: Sql Injection)
(MSDN: SqlParameter Class)

This code works:

//create the string
string sqlstring = "UPDATE accounts SET @company WHERE id = @id";

//create the command object
SqlCommand cmd = new SqlCommand(sqlstring, connection);

//set the SQL Parameters
cmd.Parameters.Add(new SqlParameter("@id", (object)id.Text));
cmd.Parameters.Add(new SqlParameter("@company", (object)company.Text));

//execute the command
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();

But this does not work:

//create the string
string sqlstring = "CREATE DATABASE @DatabaseName";

//create the command object
SqlCommand cmd = new SqlCommand(sqlstring, connection);

//set the SQL Parameters
cmd.Parameters.Add(new SqlParameter("@DatabaseName", (object)dbName.Text));

//execute the command
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
zachattack05 70 Posting Pro in Training

That would work, but would that prevent injection attacks?

zachattack05 70 Posting Pro in Training

I can't figure out what I'm doing wrong here.

I want to allow the user to name the database on their own. Can you use parameters in a situation where the command is simple like:

CREATE DATABASE @DatabaseName

I've been trying forever and it just keeps creating a database called @DatabaseName, it just ignores the parameter.

zachattack05 70 Posting Pro in Training

on any methods that might be called from a different thread I always use something like this in the method:

private void UpdateStatusText(string status)
        {
            Action UXUpdate;
            UXUpdate = () => textBoxStatus.AppendText(status);
            this.Invoke(UXUpdate);
        }

and in the thread that calls that method I' just call it as normal:

UpdateStatusText("thread start: OK");

Works like a charm every time.

Dunno if that helps though.

zachattack05 70 Posting Pro in Training

Hey! That's clever! I'll have to check that out! Thanks!

zachattack05 70 Posting Pro in Training

Thanks for the information.

I fear you might be correct. However, I was only keeping the information in a datatable temporarily to loop through it to create SQL parameters.

There aren't hundreds of data types, there are just a bunch of parameters and it's a maintenance nightmare to have to edit the parameter lists over and over when I can just loop through either all the form controls and get information and assign them all random parameter names and then loop through all that and create parameters from it.

I think I'm stuck though.

zachattack05 70 Posting Pro in Training

Is something like this possible:

int MyParameter = 3356;

            DataTable x = new DataTable("CommandParams");
            x.Columns.Add("ParamName");
            x.Columns.Add("ParamType");
            x.Columns.Add("Object");

            DataRow y = x.NewRow();
            y["ParamName"] = "@SomeParamName";
            y["ParamType"] = MyParameter.GetType();
            y["Object"] = MyParameter;

            SqlCommand z = new SqlCommand();
            z.Parameters.Add(new SqlParameter(x.Rows[0]["ParamName"], (x.Rows[0]["ParamType"])x.Rows[0]["Object"]);

I'm trying to come up with a method that can loop through a datatable (or something) and add parameters to an SqlCommand instead of typing out hundreds of lines of code if there are hundreds of parameters.

Thoughts?

zachattack05 70 Posting Pro in Training

Not sure if this actually qualifies for this forum so please by all means move this topic to the appropriate place if it isn't.

I'm writing a C# Windows Application (not a web app) and it uses either an SQL or Access database to store its data for multiple network users.

With an Access database, backing up and restoring data is easy, just copy the file and everything should be fine. But what about backing up and restoring data on a SQL server?

I am building an SQL database design that makes use of MANY one-to-many and many-to-many relationships. Some of the relationships are based off of the auto increment field "ID." If I back the data up, I would imagine if there was a break in the ID field sequence at backup time (which is VERY possible if a record is deleted)...when I restore that database, how will the server know which records are related because a record after backup might not be assigned the same auto increment ID number that it was before backup? I know the relationship rules will be restored, but you can't assign a value to an auto increment field, so record 20 in table1 that used to reference many records in table2 by using the ID number of "20" might not be assigned the number 20 when it is restored right? It could be assigned 10 or 5 or 1 depending on where it is restored.

Am I missing something? …

zachattack05 70 Posting Pro in Training

Ahhh...duh...thanks for the obvious.

It's going to be one of those weeks...I can tell.

zachattack05 70 Posting Pro in Training

I have an application that, on occasion, might need to perform certain tasks on files, or other things that are "in-use" while the application in running.

This is what I've tried to do, but I'm running into problems:

I created an interface:

interface IShutdownCommand
    {
        void OnShutdown();
    }

I wanted to create, on my main application window code the following:

//initialize shutdown Commands
        public List<IShutdownCommand> ShutdownCommandList;

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
                foreach (IShutdownCommand Command in ShutdownCommandList)
                {
                    Command.OnShutdown();
                }
        }

But I'm getting this compiler error:

"Inconsistent accessibility: field type 'System.Collections.Generic.List<DATA.IShutdownCommand>' is less accessible than field 'DATA.Main.ShutdownCommandList'"

Any thoughts on how I could do this and actually get it to work?

zachattack05 70 Posting Pro in Training

Thank you so much! You have no idea how many HOURS I spent on this...thank you thank you thank you!

I also changed this line from:

//read the length of EncryptedMemStream that is stored in the ParentMemStream at position 4
                //NOTE: This is not the length of the EncryptedMemStream that is initialized in this method, it is 
                //      the length of the serialized one from the .usf file
                EncryptedMemStreamLength = BitConverter.ToInt64(ParentMemStream.GetBuffer(), 4);

to:

//read the length of EncryptedMemStream that is stored in the ParentMemStream at position 4
                //NOTE: This is not the length of the EncryptedMemStream that is initialized in this method, it is 
                //      the length of the serialized one from the .usf file
                EncryptedMemStreamLength = BitConverter.ToInt64(ParentMemStream.ToArray(), 4);

Don't know if GetBuffer() and ToArray work the same, but why take any chances?

zachattack05 70 Posting Pro in Training

On the assumption that no one here will probably ever use my software, and that those of you here that would could probably defeat the encryption methods anyway with enough practice, and simply because I am about to lose my mind on this one...I'm going to post my method I am using to encrypt and save user settings...overkill? probably, that's why I'm really not to worried about it.

Disclaimer: some of the information has changed from what I am really using. I did my best to make sure it would repeat the same problem if you are bold enough to copy/paste my madness into your VS. Nick, someone? Can you tell me what in the world I am doing so wrong here?


The situation: When my application first starts, it checks for a user settings file, if one does not exist, it creates one. Here is the relevant portions of the "Load()" event with irrelevant portions commented out:

//check to see if this is the first run
            //TODO: Change the file name here from LUser.usf to User.usf
            if (!File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "LUser.usf"))
            {
                //there is no user settings file, create a blank one
                LocalSettings NewUserSettings = new LocalSettings();
                
                //set some default values
                NewUserSettings.BalloonHelp = true;
                NewUserSettings.SysRunNumber = -1;
                NewUserSettings.SysFirstRun = true;
                NewUserSettings.dbmsIntegratedSecurity = false;
                NewUserSettings.dbmsPersistSecurity = false;
                
                //save the new settings file
                NewUserSettings.Save(NewUserSettings);

                //load settings (FOR DEBUG OF ENCRYPTION ONLY)
                UserSettings = UserSettings.Load();

                //open the setup wizard
                //SplashScreen.labelSplashActivity.Text = "Starting System Setup...";
                //SystemSetup.Start SystemSetupWizard = new …
zachattack05 70 Posting Pro in Training

Nick,

I'll play with the code I have and see what I come up with. I am working on a different project right now, but I'll start back up on the one that's using the encryption here in a few hours.

I'll let you know what I find...maybe the two of us can figure this out. Two heads are better than one :) ... that is if you don't mind me picking at your brain a bit more.

zachattack05 70 Posting Pro in Training

Nick,

With your example, the question then becomes: What if you are not encrypting a string? Using

byte[] Data = ASCIIEncoding.ASCII.GetBytes(str);

is great if you are encryping data of the ASCII variety, but if I am encrypting an object or a class instance, or an image, or whatever...isn't there the potential for data loss or corruption by using ASCIIEncoding on non-ASCII data? I would imagine that when you go back and forth between one encoding to another (bytes to ASCII etc...) it would be okay if the data is of that type, but if it's not that seems like a bad idea.

If I am encoding a MemoryStream (which is simply a byte array) I shouldn't need to use any type of encoding correct? bytes are bytes bit for bit so to speak. But changing from a byte array to ASCII and then back again...I dunno...seems fishy to me. Am I wrong?

zachattack05 70 Posting Pro in Training

I don't necessarily want to read what I put into it, I want to read what comes out of it.

Like this:
OriginalData => CryptoStream => EncryptedData

I want to get EncryptedData...What's the point of encrypting data if you can't get the encrypted data and save it to a file, or manipulate it in some way?

zachattack05 70 Posting Pro in Training

I was right.

Using CryptoStream.CopyTo() throws the "Stream does not support reading." exception.

Evidently CryptoStreams cannot be read from and are not seekable either.

Any other suggestions? I'm lost here.

zachattack05 70 Posting Pro in Training

Oooh good idea nick!

I was kind of thinking the exact same thing actually. Basically creating my own memory map so I know the first 4 bytes represent where blah blah blah starts and the second 4 bytes represent where blah blah blah ends etc...and I can just use that as a reference.

zachattack05 70 Posting Pro in Training

Yep. I have serialized it, and I can get the data to encrypt. Here's the issue:

MemoryStream A is encrypted and put into MemoryStream B.
MemoryStream B also has to hold other information, such as some strings, integers and an object.
Once the strings, integers and objects are added to the stream and the serialized and encrypted MemoryStream A is added to MemoryStream B. MemoryStream B is then serialized to a file.

I think I'm getting close to figuring this out. But I just cant seem to figure out, when I deserialize stream B, how do I deserialize stream A when I don't know where it ends. I know where it starts, but I don't know it's length.