|
|
Currently, my server DLL just runs locally without remoting logic, and when I want to read and save a UserAccount class I just pass the class back and forth as is. I use binary serialization to save and read the UserAccount class. I want to do 2 things now.
1) Make the server DLL run remotely as a client activated object.
2) Encrypt the UserAccount and other data passed to the server (like the password).
I would like to know what a best practice would be for #2. I am thinking that I would serialize the UserAccount to a memory stream and then encrypt that data before sending it to/from the server. The receiving side would un-encrypt it and deserialize it back into a UserAccount object.
Currently, my application is a Windows Forms one, but I will eventually learn ASP .NET and make it into a web app. So, I would like to come up with a solution now that would also work with a web app, if possible. I am doing all of this to learn C# and .NET. I don't know SQL or ADO yet, and am wondering if my suggested solution is a good one, or if a real programmer .NET pro would do it differently.
Thanks!
|
|
|
|
|
I am using Managed C++ (not C++/CLI) with VS .NET 2003 and .NET framework 1.1.
I have a DataGrid on one of my forms, and I override the MouseUp event so that when the user clicks on a cell, it highlights the entire row:
System::Void datagrid_MouseUp(System::Object* sender, System::Windows::Forms::MouseEventArgs* e)
{
using System::Drawing::Point;
using System::Windows::Forms::DataGrid;
using System::Windows::Forms::DataGridCell;
Point pt = Point(e->X, e->Y);
DataGrid* datagrid = __try_cast<DataGrid*>(sender);
DataGrid::HitTestInfo* hti = datagrid->HitTest(pt);
if (hti->Type == DataGrid::HitTestType::Cell) {
datagrid->CurrentCell = DataGridCell(hti->Row, hti->Column);
datagrid->Select(hti->Row);
}
else {
}
} However, now my DataGrid will not sort when clicking on one of the header columns. My guess is that since a column header is not a cell, then this event handler says to do nothing; therefore, I need to add code in the else block to tell it to sort if it is a column header. How do I do this? I would rather not have to derive my own class from DataGrid if possible.
--
Marcus Kwok
|
|
|
|
|
Is anyone aware of how to dynamically resize specific item font sizes in a list control?
basically i want to be able to increase the size of the font for the selected item only.
Any help would be greatly received.
Tom
|
|
|
|
|
tom_barber wrote: in a list control?
to confirm ideally a ListBox control
|
|
|
|
|
There's no built-in way to do it. You'd have to ownerdraw each item in the ListBox yourself and, in your painting code, determine how you wanted to paint each item in the list. At least that's how'd you do it in the full .NET Framework. I have no idea if it's possible in the CF.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm having a little problem with some unit tests. I have a project that has some files that get copied to the bin folder. Each file has a build action of "Content" and Copy To Output Directory of "Copy Always".
So far so good. Even the projects that are dependent on the project with the files get the files copied to their bin directory. That is perfect - exactly what I want.
However, if I run a unit test, VSTS creates a directory to run the tests in. (Fair enough - good to keep the tests in isolation) The directory looks like this:
C:\<solution folder>\TestResults\<username>_<machine> <datetime>\Out
The parts in angle brackets depend on where, when and who is running the test so the directory structure is unknown (and doesn't exist) at build time. (It creates a new folder for each test run)
The problem is that it does not copy in the additional files I need, just the assemblies and the pdb files. So when the code attempts to load one of the files it fails because it doesn't exist.
Does anyone have any ideas for getting the files to get copied into the correct folder? (i.e. the one with all the assemblies)
|
|
|
|
|
Double clicking the .testrunconfig opens up a dialog that allows you to add additional files to the directory (click Deployment in the dialog)
|
|
|
|
|
Thanks - I've got it working now!
|
|
|
|
|
Hi all...I am a novice in reports so if my question is stupid please let me know..I am working on an OMR application.I want to print an OMR sheet.I want the users to customize the sheet by selecting no of Questions and no of options.I am thinking about using a report to print the sheet.So my question is how could i make a report programatically by supplying the no of columns and rows...Is there any other alternative..Please help me folks as i am stuck..!
|
|
|
|
|
Is there anything available that will automatically take care of the < > & ' and " chars in a string upon adding it to an attribute in an XML node?
I don't have a problem with creating a function that escapes and unescapes the text in my class but kind if figured that this might be something that is already in there and I am just missing it.
I am looking around (have been for about 30 minutes so far) and am not finding anything so I thought I would ask. Usually Google gets me there pretty quick if it exists.
|
|
|
|
|
If you use the XML DOM classes it does do it for you.
using System;
using System.Xml;
class Example
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement("root");
doc.AppendChild(root);
XmlElement child = doc.CreateElement("child");
root.AppendChild(child);
XmlAttribute attr = doc.CreateAttribute("example");
attr.Value = "<CodeProject ©>";
child.Attributes.Append(attr);
doc.Save(Console.Out);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
You could always do this by using HttpUtility.HtmlEncode on the text. This converts the characters that Html doesn't understand into ones that it does, e.g. & becomes &.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a problem with a Windows Forms project I am toying with. I am creating a quicken like program. The main window creates a MDI child for each account (checking, credit card, and broker). I cannot figure out how to handle the close button. I want the form to just hide itself and remain in the main menu item that I dedicated to keeping the names of the children, so that the user can reselect and open the form again. However, this doesn't work:
private void CheckingAccountForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
this.Visible = false;
e.Cancel = true;
}
}
The window is removed from the menu, and I currently have no way to bring it back.
Ideally I would like to remove the close button from the header of the form but leave the other two. I can't see any way to get rid of that button without losing the others.
I may just get rid of the header and add two custom buttons for the other two functions (minimize and full/screen toggle).
Any ideas?
Another pesky problem is that if I click the close button on the main form, it closes the children but stays open, and I gotta click the close buttong again.
Thx.
|
|
|
|
|
I think you'll have to roll your own MDI window list if you want it to show hidden forms.
You can probably remove the close button from the child forms by using P/Invoke. I wouldn't though nor would I suggest you implement your own buttons for minimize and maximize. People expect those buttons to be there if the function can be done.
You must be doing something somewhere to prevent the closing. I put together a quick MDI application that maintains a window list, creates children, and hides children instead of closing them when requested (although I overrode the OnFormClosing method instead of creating an event handler).
|
|
|
|
|
Thanks. I did end up adding my own combobox to my toolstrip. I found that the way I am handling the form_closing event works, in that it keeps the MDI window in the parent's mdiChildren list. So, by setting the e.Cancel to true, the child stays in the list, but setting Visible to false causes it to be removed from the menu item.
|
|
|
|
|
I wrote a routine using some of the reflection features to look for paired member fields in a class. The function looks up this variable's value and the value of the paired variable, which may or may not actually exist. If it does, then its boolean value is read, and if true the function returns a System.DBNull.value, otherwise the function just returns the value of the named field passed into it when called.
Rather than use variant variables to store my database fields, I'm using two fields to store the value read from a database. The first is a typed field variable for the actual data, if it's not Null, and the second is a boolean to track if the database value was Null or not, i.e., Name and Name_Is_Null, both of which belong to an instance of the DataBase_Info class.
Currently, the function is called with a string containing the name of one of the member fields, and there is only one instance of DataBase_Info. Now I'd like to pass the actual field variable to the function, and have resolve the class instance, if there is a paired member, and return either the value passed in if their isn't a paired member or it's false, otherwise return System.DBNull.value. How can I resolve the name of a variable passed in as a parameter and its container at run-time?
Thank you
|
|
|
|
|
Rather than writing your own mechanism, why not just use strongly typed data sets, which do this all for you? They're easy to create, very robust, and with .NET 2.0 very flexible to change the underlying connection and fetch behaviors. Take a look at many of the search results on MSDN from http://search.msdn.microsoft.com/search/default.aspx?siteId=0&tab=0&query=strongly+typed+dataset[^].
As far as answering your question, you can use Type.Method or Type.GetMethods . With each MethodInfo , you can call MethodInfo.GetParameters . There are also other interesting and pertinent properties on MemberInfo you may need to pay attention to, like IsGenericMethod . Just depends on what methods you're reflecting and how they're written.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you for your reply.
I've tried to stay away from using strongly typed data sets in favor of "self-healing" code. I'm forced to use VS2003 with .Net 1.1, so this may not be a problem with the later version(s), but when the database changes, i.e., a column goes from not null to null, we've had to update the strongly typed data sets and the programs. I'm more interested in having the code able to deal with nulls directly. However, I'll need to look at the link you gave, it may be that we're not using stongly typed data sets properly.
As I said in my first posting, I want to be able to create a class structure instance to contain all of my database column data. Currently I'm testing the columns for null as they are read from the database using a query. If the value is null then I set a paired member flag variable to true and a 0 or empty string, or some other default value in the value member variable, and if the column isn't null, then I'm setting the flag to false and store the column value in another member variable. The flag member adds the suffix '_Is_Null' to the name of the one used by the value member.
This works well enough, I just need to check the '_Is_Null' suffixed flag member to see if the database value was Null or not to determine how to use the value member variable. However, when it came to sending values back to the database via a stored procedure I wanted to "hide" this code so the assignments easier to read. Instead of passing both the flag member variable and the value member variable to the function in which I was hiding the test, I decided to pass the name of the value member into the function, and use Reflections to look up the paired flag member and its value, then return the appropriate value to be assigned to the stored procedure's parameter. This too works well enough, except that because I was passing in the name of the member as a string instead of the member's value, I'm not able to take advantage of the compiler check for misspelled member names. So, I want to use the value member instead of its name in the function call.
However, when I tried using them with the debugger I could see the data types of the parameters, but I couldn't figure out how to get the names of the variables passed in to them with the function call. Another issue is that Reflections tells me what the containing class's type name is, but not the instanced variable, so if I had more than one instance of the class, how would I know that I'm looking at the right instance when I resolve the paired flag member to see if it is Null (true) or a value (false)? In my current code I hard-code which parent class instance I'm using, this isn't a problem in this one case because there is only one instance of the class, but I'm pretty sure that Reflections techiques could be used inside the function to could get this information from the variable being passed in as the parameter.
Thank you
|
|
|
|
|
Hi folks,
I am nearing the end of the first cycle of developement for my application. We began this with the .net framework 2.0, However we are now interested in using WPF and for that it appears we need to upgrade to 3.0.
My question is does anyone know if migrating an application from .net 2 to 3 is a big task and would we need to undergo any major changes. Obviously at this stage we don't want to risk breaking the application too much and don't have the time to undergo any major reworking.
Thanks for your time
Darren Sim
|
|
|
|
|
.NET 3.0 is actually .NET 2.0 + WPF, WCF, and WF (WinWF). There should be no risk at all. Even going from .NET 1.x to 2.0 isn't a big risk. Very little gets removed or deprecated (deprecation is really only a problem for future Frameworks the currently desired version). The biggest thing to consider is the user experience of taking a new dependency that has little market penetration at the moment. For example, a reboot may be required before you can even set up your product.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath! It's been a long time since you've grace the forums with your presence! We've missed your infinite wisdom in everything Windows!
Welcome back!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
As you can see[^], I've been pretty busy.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
How many hours a day are you putting in?!
Looks like my life with the Fed Government! I swear, they go out of their way to break everything they can and still call it "Production Quality".
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Heath, here's a question for you. Does the /quiet switch tip also work for VS 2003 SP1?
|
|
|
|