zachattack05 70 Posting Pro in Training

Could also be it's the middle of the day and people are working.

Care to share your solution to the problem for others?

zachattack05 70 Posting Pro in Training

If it's not your application, then circumventing it or disassembling it might be a violation of the DMCA. Just a thought...

zachattack05 70 Posting Pro in Training

I think I understand the general concept of how these files work, but I want to make sure, and ask a couple questions about them.

Am I correct in thinking MDF files are "attached" to the SQL instance only as long as the application is running and are "detached" when the application closes?

My question, if that is true, is: is it possible for an application to "attach" an MDF file when it starts, and as long as the application is running and the database is attached, allow remote connections to the same SQL server instance access to that attached database? This is assuming of course that the SQL server instance already has the property set to allow remote connections and that the user(s) connecting to that SQL server remotely have valid SQL server credentials.

The reason why I'm asking is I am trying to create an application that stores data on a server in some form and allows network users to access that data. A basic 3 tier data application. My concern comes from worries that if I allow end users "direct" access to the SQL server, the data is less secure (it holds medical information and thus needs to be secure). I tried creating my own socket server that would return datasets to clients so that the clients couldn't access the SQL server directly, but the complexity of extracting, updating, deleting and maintaining such a venture is beyond me...If I never deal with Async objects …

zachattack05 70 Posting Pro in Training

Bummer!

Thanks.

zachattack05 70 Posting Pro in Training

Need some help with this one.

Is it possible to define a class constructor in an interface? I need to ensure that any classes that use a specific interface all have at least one constructor with specific parameters. Is there a different option that can yield the same outcome?

zachattack05 70 Posting Pro in Training

Another option is to open the main application form when the application starts (the frm form) and immediately hide it, and then show the login form. That's what I usually do.

zachattack05 70 Posting Pro in Training

Hmm...good point.

zachattack05 70 Posting Pro in Training

As a hint.

Instead of creating a new array for the Guid, I just did this:

Array.Copy(sockId.ToByteArray(), NewCommandData, sockId.ToByteArray().Length);
            Array.Copy(commandData, 4, NewCommandData, 16, commandData.Length - 4);
zachattack05 70 Posting Pro in Training

Hmmm...I'll check it out.

Thanks!

zachattack05 70 Posting Pro in Training

Anyone know if there are methods to alter the properties of files such as "Date Created" or "Date Modified" or even extended attributes such as an image file's "Star Rating" or tags, comments or even the Image ID?

I attached some example images of what I am talking about.

zachattack05 70 Posting Pro in Training

Excellent!

Thanks for that. I knew it didn't look right. Also, that Array.Copy trick is kinda nifty :)

zachattack05 70 Posting Pro in Training

I haven't had enough coffee this morning yet and for some reason this doesn't look right.

I have two objects that I need to convert into one byte array. One object is already a byte array, and the other is a Guid.

Given that sockId is a Guid and commandData is a byte array, is this valid?

//finally we need to add the socket's Guid to the commandData so that the interpreter
            //knows where to send the response and also remove the data length that was originally
            //contained in the byte array at position 0.
            int TotalBytes = dataLength - 4 + 16;
            int i = 0;
            byte[] NewCommandData = new byte[TotalBytes];

            while (i <= TotalBytes)
            {
                //add the Guid byte array
                while (i < 16)
                {
                    NewCommandData[i] = sockId.ToByteArray()[i];
                    i++;
                }

                //add the commandData byte array
                NewCommandData[i] = commandData[i - 12];
                i++;
            }

or is there a better (preferrably faster, more elegant) way of doing this?

zachattack05 70 Posting Pro in Training

hehe I would totally have a custom function called mc.hammer.

sorry. Useless post, I just couldn't resist.

zachattack05 70 Posting Pro in Training

I've never written a web application before so I could be wrong here.

I don't know if you can really do this.

If you have 4 different applications and a "host" application, and the host application has 4 buttons, each starts one of the 4 programs, the web program would just have to start a web browser (probably IE for the better compatibility reasons) and then have that browser navigate to a server hosting the application.

I dunno though.

I would just re-write the web application to a form app. Just my 2c

zachattack05 70 Posting Pro in Training

What exactly are you trying to encrypt? The connection strings?

zachattack05 70 Posting Pro in Training

Just wondering if anyone has used, or played with any of the new Thread Safe Collections? When to Use a Thread-Safe Collection.

Anyone found any real performance increases or no? Just curious.

zachattack05 70 Posting Pro in Training

I am still working on getting my socket server working. I would like to have the server keep the socket connection open until the client closes the connection or the server is shutting down.

I have been using the example at MSDN as a starting point. My question is though, since this example shuts down the socket after sending data, how could it be modified so that the server can just loop back to read from the socket again or does it already and I just don't see it?

Should I be using an async socket if I want to keep the connection open?

I fail to see the logic in using an async socket server if the server will only receive one message from a client at a time...what if the same client sends two messages at the same time to the same socket...does one just get lost or does it get queued behind the first?

Here's the example code for those who don't want to click the link:

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

// State object for reading client data asynchronously
public class StateObject {
    // Client  socket.
    public Socket workSocket = null;
    // Size of receive buffer.
    public const int BufferSize = 1024;
    // Receive buffer.
    public byte[] buffer = new byte[BufferSize];
// Received data string.
    public StringBuilder sb = new StringBuilder();  
}

public class AsynchronousSocketListener {
    // Thread signal.
    public static ManualResetEvent allDone = …
zachattack05 70 Posting Pro in Training

Thanks!

zachattack05 70 Posting Pro in Training

So true...about the part of life comment I mean :P

zachattack05 70 Posting Pro in Training

readonly fields: http://www.dotnetperls.com/public-static-readonly

Duh. I feel like an idiot now. I knew that!

Thanks!

zachattack05 70 Posting Pro in Training

There are no strict rules, but more conventions.
You can follow them or not.
The only convention that is followed, with as far as I know, no exception, is that the name of an interface class starts with a capital I.

True. I guess I was asking what the popular convention is?

zachattack05 70 Posting Pro in Training

Anyone know the rule for naming fields with the abbreviation "ID?"

I notice that MS is inconsistent, they have "PlatformID" and "ApplicationId."

I thought the rule was is the abbreviation was 3 characters or more, only the first letter is capitalized. Like Guid instead of GUID?

zachattack05 70 Posting Pro in Training

Is it possible to set a object's value, and once that value is set not allow it to change?

I could write a method to do it, but I wasn't sure if there was some sort of modifier I could use?

I need to set a value once, and not allow it to change at all, but the value needs to be dynamic at run-time.

For example, assigning a value to an integer, and as long as that class is alive that has that field, it will always keep that value and if someone, or something, attempts to change the value it throws a fit and/or refuses to change it.

Anyone know if that's possible?

zachattack05 70 Posting Pro in Training

I am building an async socket server to receive and process incoming commands.

The model I am working on has the sockets receive the data and send it to a "Interpreter" class. I need a way for the interpreter class to know who sent the command to interpret to it, so that once it is finished performing actions on the data it can return the result to the correct socket instance so the data can be returned to the client.

Does that make sense?

I was thinking about using some sort of thread reset event and would just have the interpreter save the result in some dictionary or array of some sort and call a reset event letting the socket unblock and check for the result in that dictionary or array (whatever), read it and send it back.

Any thoughts or ideas?

zachattack05 70 Posting Pro in Training

Thanks!

zachattack05 70 Posting Pro in Training

So the packet really isn't "empty" perse, the sender's system sends packet data but the actual "data" is empty.

Is there someplace I can read about what is actually sent in addition to the data? You indicated status info etc...what exactly is added? Is there a way for an application in C# to actually extract and use that data that the system adds?

zachattack05 70 Posting Pro in Training

So it's possible to send bits?

I'm lost. Even if it was possible to send like 2 or 3 bits which is less than 1 byte, how would it even evaluate the if statement considering that 0 is an integer, and so is "read" in this example...I would think an exception would be thrown or a potentially incorrect value used if you tried to assign a decimal value to an integer?

How would you send 0 bytes? If EndReceive blocks until it receives data, it must be receiving something for it to unblock right?

zachattack05 70 Posting Pro in Training

Looking at examples online, all of them seem to have:

int read = s.EndReceive(ar);

	if (read > 0) {//Some code}

The question I have is...why?

Why bother with the if (read > 0) when the MSDN says that EndReceive blocks until data is received?

If you call int read = s.EndReceive(ar); your code execution halts until the socket receives something. Once it does, it stops blocking and then will evaluate the if statement...wouldn't the if statement always return true or is it possible to receive 0 bytes?

zachattack05 70 Posting Pro in Training

Ahhh! A zombie!

zachattack05 70 Posting Pro in Training

Do you need to have both on their own form? You could have one form, and have the form show a panel that holds a custom control and just show and hide the different panels, that way it's all on the same form but "appears" to have two forms. It also prevents that annoying fade in and fade out effect for vista users. Just an idea...I use it a lot for "control panel" or "settings" forms.

I can post an example project if you would like to try that approach.

zachattack05 70 Posting Pro in Training

Great. Thanks!

I was looking for a way to put a command version in each command I send over the network so if/when different versions of a command set come out, if something changes, the server still will have backwards capabilities. Guess I'll use something other than System.Version for this.

Thanks!

zachattack05 70 Posting Pro in Training

Does anyone know if you can use the comparison operators like ==, >=, <=, >, < etc... on two different System.Version objects to detect different versions and in what direction (like which of the two is a newer version vs older?)

zachattack05 70 Posting Pro in Training

Not at all. However, when you talk about "serializing", I'm assuming that you mean a good chunk of the discussion we've had in this thread, not necessarily the .NET version of serialization. First, I'm not as familiar with that, as I've stated earlier, but I feel certain that you can do that over a socket (any stream, for that matter).

The approach I've used is a custom serialization process. I wouldn't be able to use .NET serialization, since I have UNIX processes as some of the endpoints, and didn't want to have to "invent" the serializer/deserializer on that platform, or perhaps, attempt to use Mono or something like that (OK, the real truth is the UNIX side of the software was written before .NET was even invented). It works for me, and should work in most applications where you're having to send data over sockets to various processes.

As far as size is concerned, you'll have to do some tests to see how large your objects are and determine if that's the best approach. However, how else would you do it? If you have to get the data to a process on another machine, it's going over the network somehow - either directly, via your soon-to-be-developed solution, or via FTP/SCP/Samba/E-Mail - i.e., file transfer - but one way or another, the data's got to get there.

Start small, run some tests and see what results you get. Hopefully, you can gather enough data to help make a good choice.

You …

zachattack05 70 Posting Pro in Training

Would you say then that serializing and deserializing classes is a bad approach? I'm not sure how much bandwidth something like that would take? I guess I could always serialize my classes to a file and get an idea of their size, but I'm really not sure.

zachattack05 70 Posting Pro in Training

True, but I would still be careful and do everything in a legal fashion. Piracy and DMCA violations are expensive and it could end up being worse. If I was you, I would call the software manufacturer and suggest your enhancement, or like you did ask for an API, or some form of written permission to do what you want to do.

I've never gotten in trouble for those violations...everything I have is legal and legit, and now that I see the work involved in writing those applications, I appreciate the rules a bit more than the average person I guess. I'm sure you do to.

Anyway, I'll get off my soapbox now :D sorry for stirring the pot...just wanted to offer a few suggestions/alternates.

zachattack05 70 Posting Pro in Training

I don't mean to interject because I really have no answer to your question, but I did want to throw some things out there to consider:

1. Would it be easier for you to just write your own program that functions in the same way the one you use now does? You said it was simple, if it's really simple just replicate it and add your own features.

2. Be weary (and I mean very weary) of copyright laws. When I was in high school and college I'll admit I had no care for those (I don't think anyone really did), but meh since learning how to write software and getting older I've found that saying "OMG! Why didn't Microsoft add x, y, z feature!! What a ripoff! It wouldn't be that hard" is not actually true :) I know you aren't saying that so don't take it that way, but the point is, 99% of the time reverse engineering, patching or whatever you want to call it is illegal and even if there is an API, it might not provide the functionality you want.

Just some points to ponder :)

zachattack05 70 Posting Pro in Training

Good points.

I think I'm really hitting a different wall though. After talking this over with you in this discussion, for the most part everything you are saying makes sense, some of them I thought of already others are different takes on things I've thought of and there are new ideas too.

I think the problem is the actual design of the system. I think it's a conceptual thing.

Maybe you can help shed some light or offer some advice on that end? The thing is, I'm having problems coming up with the objects (serialized classes) to send.

I had ideas of creating a class for each command, each containing it's own set of fields and methods to help the client and server process the incoming and outgoing data stream. The sheer number of classes I would have to create seems enormous and to be honest, I'm scared to start creating classes just to find out on the 50th one that oops! I should actually do it *this* way instead....which has happened before.

I was hoping to have one class that the client could serialize with information and send to the server, the server would deserialize it, find the field that contains the command and based on that command would look for other fields. Process the command, create a new class instance with the response and send it back to the client.

Two classes...command, response. I just can't figure out how to impliment it, …

zachattack05 70 Posting Pro in Training

Do you normally explicitly define the integer in your command enum or actually use the enum "string" name in the switch or just leave the default values (0,1,2,3,4 etc...)

Sending a variable length string would be a nightmare I would imagine, I would probably shoot myself, but an integer is a set size. But I would guess that if you are using a switch statement with integer values, you would HAVE to explicitly define the enum values...unless I guess you just add commands to the end of the list if a new one is added, otherwise if you wanted them in alphabetical order and you added one, the command number would change and so the wrong methods would be called because the server would think command 5 is still command 5 because it doesn't realize that the real command 5 moved down 2 spaces because 2 new commands were added above the 5th one.

See what I mean? Does that make sense or am I worrying about nothing?

zachattack05 70 Posting Pro in Training

I know this thread is getting moldy, but I wanted to say thanks and ask a followup question.

Do you think that having an enumeration of commands would be easier to maintain than having a list of commands that are integer based?

Granted, they would still be integer based (enums are integers after all) but as far as programming and readability and to make sure you dont type 10001 instead of 100001 as the command (or whatever) when programming do you think it might help?

Do you see any downfall to this?

The only downfall I can see is possibly having someone alter the enum list (which would move the integer values around) but even that could be fixed by specifying a value for each enumeration item like so:

enum Command
{
     NoCommand = 0x0000,
     FirstCommand = 0x0001,
     SecondCommand = 0x0002
}

That way even if someone inserted a new command between the first and second one in the list, the command numbers don't change.

What do you think?

zachattack05 70 Posting Pro in Training

I don't know if it necessarily requires less work or more work, or even the same work. C# and C++ are tools, and each tool has a niche. C# can be used for web applications that run on IIS servers and (as far as I know) C++ cannot. I don't write in C++, mainly because Windows is the target platform, all Windows machines come with .Net now and I honestly don't know enough about C++ to effectively write software. I rely on the CLR and the framework to do work for me that I would otherwise have to do by hand. To me, C# is great and does what I want, quickly and effectively. I've never found something I couldn't do in C#. I may not understand how it's done, but I know it can be done.

Just another 2c worth :)

zachattack05 70 Posting Pro in Training

I believe what you are probably looking for is this.

Hope that helps :)

zachattack05 70 Posting Pro in Training

I don't think I've ever sealed a class before...would there be any benefit to sealing a public class that contains fields for a server to process? The object is sent over a network socket to the server, the server reads the data in the object and responds accordingly.

I read sealed (C# Reference) at MSDN, and at the bottom it says:

To determine whether to seal a class, method, or property, you should generally consider the following two points:

  • The potential benefits that deriving classes might gain through the ability to customize your class.
  • The potential that deriving classes could modify your classes in such a way that they would no longer work correctly or as expected.

I would say no class would ever NEED to derive from the class, any added data would be ignored by the server because it wouldn't know to look for it. The second though...I'm not sure about. Anyone know of any security concerns or issues that I should possibly consider with this?

I'd really appreciate any feedback :)

zachattack05 70 Posting Pro in Training

I would say no it doesn't count.

C++ and C#, while similar, are different languages. I can't program in C++, but I can in C#. I don't know what header files really are, no idea how to even create a window in C++. If you want to work at a job that requires C# experience, and you only have C++, if I was a project manager or working in HR, I wouldn't hire you.

I would say that 3+ years of C# experience means just that. Either working on a project (or many) that were written in C# for at least 3 years. Some places might include school work, but it depends.

I think that personal projects can count as well. If you have source code that you can part with and a compiled, finished project, share it with them so they can see that while you are "self-employed" or "self-taught" you actually can provide something to show for it.

Just my 2c worth.

zachattack05 70 Posting Pro in Training

hmm...I'm still lost.

The images on Google Earth are copyrighted by their respective owners, Google has a license to use them.

Are you going to draw the maps yourself and use image files?

If you intend to use the data from Google Maps, I would check out the Google API page to see if theres something that could help, but I don't think it's there. Google lets you use their maps on your website, not software (I could be wrong though).

If you want to create a software application that mimics the functionality of Google Earth, the 3D part is beyond me, a flat image would probably be easier. A picture box could be re-drawn with new data if you drag your mouse over it using events.

Someone else could probably help you better though, I'm just throwing ideas out there.

zachattack05 70 Posting Pro in Training

A map? A map of what?

zachattack05 70 Posting Pro in Training

Hmmm...

Well...it appears to me that you are not reading the information in the file, not the data anyway, but your loading an array (not sure of what type, but it looks like an integer array) with one entry, the size (length) of the file. Maybe I'm missing something but could you attach a copy of the ANSWRFIL.HEX? Put it in a zip file so you can upload it, or it wont upload.

Also, could you share the code that you use to actually read the data from the file? If you can use the code tags too :) Helps with readability.

zachattack05 70 Posting Pro in Training

To be honest I don't know if it's serializing and deserializing correctly. It appears that you are serializing to a file on the disk.

Clean your solution, delete the file at "K:\MiniSteam\ChessGame\Replays\Replays.dat" start the program in debug mode, do something to make the application serialize and see if the file is created. If so, it's serializing something.

How you use the data afterwards is up to your application's logic.

Since I really don't know what your ultimate goal is I can't really comment on if it "works" or not. The act of serializing "something" is working if the file is made and actually contains the data you need to use.

My suggestion would be to see if you can use the data in the file, if you can, it works, if not, it's not. :)

NewOrder commented: thanks for the help +0
zachattack05 70 Posting Pro in Training

Ahhh I see it now.

Because your class named ClassMoveToSerialize contains a field to hold another class instance called Class2, that means Class2 also needs the serializable flag.

Add the [Serializable] flag to Class2 as well.

NewOrder commented: Thanks for helping me with seriliazation +0
zachattack05 70 Posting Pro in Training

I think he meant the array is uint...but I dunno...I thought the same thing, but was hoping some code would shed some light.

zachattack05 70 Posting Pro in Training

Hmm...that's a big if statement.

Have you considered dropping the second if statement and just using an else one? If the first one is not true, it uses the code in the else statement. Just a thought.

If it's not writing "Correct!" does it write "Incorrect!" or does it write nothing at all?