|
Seeking a file vs copying it to memory is probably not that big of a difference. The OS is loading the file to memory and reading from there anyway whether you tell it to or not.
|
# ? Sep 21, 2011 06:29 |
|
|
# ? Apr 23, 2024 14:56 |
|
Rahu posted:Really easy question because I can't figure out what to type into the google. Create your options form and then show it using OptionsForm.ShowDialog() to get that effect. You can also assign buttons on the options form to have a DialogResult property that will be returned when the OptionsForm is closed to help you decide what to do with the result. Something like code:
|
# ? Sep 21, 2011 06:43 |
|
The form's ShowDialog method should do it http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx edit: snap
|
# ? Sep 21, 2011 08:23 |
|
PDP-1 posted:
Forms aren't automatically garbage collected, so you really should put the form in a using statement. Otherwise you have a memory leak as more and more options windows are opened/closed. code:
|
# ? Sep 21, 2011 14:54 |
|
Is there a better way to do this?code:
|
# ? Sep 21, 2011 20:08 |
|
I think my dual mode WPF/console attempt may be proving too ambitious. I'm trying to use a BackgroundWorker and when operating in console mode the ProgressChanged and RunWorkerCompleted event handlers I've subscribed to the events are never triggered and, while the DoWork event handler is triggered, the BackgroundWorker's IsBusy property is never set to false so the parent thread gets stuck in a loop waiting for it to finish. I wondered if the fact that this is really just a WPF application with its output type set to Console could be causing my events to get swallowed by the WPF event loop or something like that, so I went back to basics. If I simply copy and paste this into a new console application it works as expected. If I copy and paste it into a new WPF application (with the code from Main() transposed into the MainWindow constructor), set the output type to console and run it then I get the same problematic behaviour. Am I screwed?
|
# ? Sep 21, 2011 21:30 |
|
Help, WCF wizards! The dto objects I've been passing to/from the client/server do not have [DataContract] decorating the classes and do not have [DataMember] decorating the members. What's the point of all those extra lines, because if I just leave those off, all public properties are considered for serialization. This has worked great for months. Now, I need to send an object graph with cyclical references. This means (post .NET 3.5) I need to decorate dto classes with [DataContract(IsReference = true)]. So I guess I have to start using [DataContract] and [DataMember] everywhere after all. Adding these attributes, however, causes WCF to spit out a NullReferenceException. I can't seem to find where it happens, I'm beginning to suspect the stack track is bogus and I'm looking in the wrong place. Here is everything: http://pastebin.com/bpvU1AAq
|
# ? Sep 21, 2011 22:01 |
|
I'm looking to use an Access DB to store a small amount of data in a C# program I'm working on, but I'm having issues getting data out of it. Currently, my code looks like so:code:
Suggestions? Canine Blues Arooo fucked around with this message at 22:13 on Sep 21, 2011 |
# ? Sep 21, 2011 22:08 |
|
Canine Blues Arooo posted:I'm looking to use an Access DB to store a small amount of data in a C# program I'm working on, but I'm having issues getting data out of it. Currently, my code looks like so: I'm pretty sure the problem is your Console.Write(...) statement. If you call it like that, it interprets the first parameter as a format string. You should either just concatenate the string ("this data..." + reader.GetValue(0) + ...) or correctly use the format string ("this data... {0} {1} {2}", reader.GetValue(0), ...). And another thing: while your select statement works, it's a very, very bad idea to do it like that. You should always use parameters instead of concatenating string, to avoid string injection vulnerabilites in your code.
|
# ? Sep 21, 2011 23:02 |
|
epswing posted:Help, WCF wizards! Also, you don't have a [DataMember] modifier on the IsEdited bool in your BaseDto class. Finally, I don't really understand how/why you have uneditableProperties. Is that just for the IsEdited property? Can you not just set the Set to protected/private? Or is there a use case where you want the user to be able to change a property but not have the change propagate? Come to think of it, I don't even know why you call RaisePropertyChanged in the IsEdited property, you'll never actually do anything in the handler because it's in the uneditable list...
|
# ? Sep 21, 2011 23:40 |
|
Canine Blues Arooo posted:I'm looking to use an Access DB to store a small amount of data in a C# program I'm working on, but I'm having issues getting data out of it. Currently, my code looks like so: You didn't ask it to do anything with the variables. You should probably parameterized the sqlquery like this the . code:
|
# ? Sep 21, 2011 23:51 |
|
uXs posted:I'm pretty sure the problem is your Console.Write(...) statement. If you call it like that, it interprets the first parameter as a format string. You should either just concatenate the string ("this data..." + reader.GetValue(0) + ...) or correctly use the format string ("this data... {0} {1} {2}", reader.GetValue(0), ...). quote:You should probably parameterized the sqlquery like this Thanks a lot guys! I would have been looking at that for some time before recognizing that as a mistake. Works perfectly now! Canine Blues Arooo fucked around with this message at 23:58 on Sep 21, 2011 |
# ? Sep 21, 2011 23:54 |
|
genki posted:It looks a lot like it has to do with the INotifyPropertyChanged implementation. If you take out all of the Raise calls, does it work as expected? Fair questions. Adding [DataMember] to IsEdited doesn't help. The uneditableProperties are those which, when changed, will not set IsEdited to true. I still need such a property to update the UI (via NotifyPropertyChanged("TheProperty")), but I don't consider the change to have "changed the object" by my own definition. When any other property is set, then IsEdited is set to true, and NotifyPropertyChanged("IsEdited") is called so that I can update the UI to say "this record is unsaved!" If IsEdited wasn't in uneditableProperties then, after a record is saved, setting IsEdited back to false, wouldn't work (BaseDto would consider that a "changed property" and set IsEdited back to true). If anyone has a better way to do this, I'm open to suggestion. But that's a tangent off my original question. epswing fucked around with this message at 14:56 on Sep 22, 2011 |
# ? Sep 22, 2011 14:25 |
|
epswing posted:Help, WCF wizards!... code:
You'll have the same problem again in BaseDto.NotifyPropertyChanged because your hashset will also be null. Both of these are easily fixed with null checks and/or lazy loading, but you can also use the OnSerializingAttribute, OnSerializedAttribute, OnDeserializingAttribute and OnDeserializedAttribute (all in System.Runtime.Serialization) to mark methods which are run at the appropriate time during (de)serialization. dwazegek fucked around with this message at 14:57 on Sep 22, 2011 |
# ? Sep 22, 2011 14:53 |
|
dwazegek posted:PropertyChanged is null dwazegek posted:magic fuckery Holy poo poo.
|
# ? Sep 22, 2011 14:58 |
|
Hmm, I remember having the same issue a while back, but I can't reproduce it by serializing and deserializing the objects locally. So either it's been fixed, or WCF uses the serializers differently than I'm using them. So maybe it's not the problem you're having at all
|
# ? Sep 22, 2011 15:10 |
|
code:
VVVVV Right. My .Net is a bit rusty vv Pollyzoid fucked around with this message at 15:22 on Sep 22, 2011 |
# ? Sep 22, 2011 15:17 |
|
It does, but after it goes over the wire, it's null. Because the class now has [DataContract], it's not being serialized. Also, the idea of serializing an event doesn't make sense anyways. So this IS necessary:code:
Much thanks, dwazegek
|
# ? Sep 22, 2011 15:21 |
|
epswing posted:As for the hashset, it's also null after the object goes over the wire. Adding [DataMember] to it solves that. Now that your hashset is being serialized with the rest of your object, a mischievous person might alter the serialized data and inject a couple of other property names into your list of uneditable properties (or remove them), causing all sorts of weird behavior when events are or aren't raised when they should
|
# ? Sep 22, 2011 15:35 |
|
dwazegek posted:a mischievous person might inject... At that point I've got bigger problems But I'm using https so...
|
# ? Sep 22, 2011 16:26 |
|
I was thinking more along the lines of a client (deliberately) sending data so that the behavior of your objects is altered. Not some sort of MITM attack. It's probably not a big deal, but if you don't want anyone to be able to alter the contents of that hashset, you shouldn't give them the means to do so. Just because your client is (probably) using the same objects as the server, doesn't necessarily mean that everyone who will consume your WCF service will do so, so there's really no way of telling what kind of data they'll be sending you. Of course, you're in a better position to determine if this will be an issue or not.
|
# ? Sep 22, 2011 17:35 |
Possibly the wrong thread, but I need help with subdomains in IIS7. I want m.mysite.com to redirect to https://www.mysite.com/mobile.aspx. I'm currently getting redirect loop errors. Would appreciate any insight to this problem.
|
|
# ? Sep 22, 2011 19:59 |
|
dwazegek posted:
epswing posted:The uneditableProperties are those which, when changed, will not set IsEdited to true. I still need such a property to update the UI (via NotifyPropertyChanged("TheProperty")), but I don't consider the change to have "changed the object" by my own definition. Are you tying this object directly to your UI then? And even then, I think it would make more sense to expose the PropertyChanged event so the UI code could test/handle changes, rather than having the object handle it internally to set an edited flag...
|
# ? Sep 22, 2011 21:29 |
|
A MIRACLE posted:Possibly the wrong thread, but I need help with subdomains in IIS7. I want m.mysite.com to redirect to https://www.mysite.com/mobile.aspx. I'm currently getting redirect loop errors. Would appreciate any insight to this problem. There's two ways to do this: 1) In IIS: Set up another web project with a header value of m.mysite.com that listens on port 80. Under the home directory property there should be an option to 'redirect to another url' instead of the the 'this is a directory on this computer' option. Enter https://www.mysite.com/mobile.aspx as the destination (you might have to make a folder on your new site that uses a default document, e.g. /mobile instead). Choose whether it's a permanent or temporary redirect. This is taken from memory for iis6 but 7 shouldn't be that different. 2) In code: in the global.asa for your application put code into OnSession_Start or somewhere similar. Read the requested URL; if it's m.mysite.com response.redirect to the other URL. EDIT-obviously there's more than two ways to do it but that's what I thought of off the top of my head.
|
# ? Sep 22, 2011 21:38 |
Thanks.
|
|
# ? Sep 22, 2011 21:59 |
|
Issue with Visual Studio 2010 Pro for those of you more seasoned vets of the product. If I open Visual Studio, close it, put my computer in stand by, wake it up and try to reopen anything in Visual Studio, it's incredibly laggy and nothing gets rendered. The usual start page doesn't show up. If I open a project, switching between a design tab and a coding tab freezes the IDE and if/when I finally get to coding tab, none of the text gets rendered. This is remedied by restarting my computer, but will pop up again the second I put it in Stand by. Is there a fix for this?
|
# ? Sep 22, 2011 23:02 |
|
Canine Blues Arooo posted:Issue with Visual Studio 2010 Pro for those of you more seasoned vets of the product.
|
# ? Sep 23, 2011 00:05 |
|
fankey posted:Make sure you have the latest version of your graphics driver. VS2010 uses WPF which leans heavily on the driver. In WPF apps I've written getting the latest driver would sometimes fix issues like these. Yeah, I've updated the drivers. Issue persists. I lied, it doesn't even need to sleep. It's just the second time I load VS and every time after that that poo poo hits the fan and effectively dies. Canine Blues Arooo fucked around with this message at 03:15 on Sep 23, 2011 |
# ? Sep 23, 2011 01:22 |
|
There goes my theory that Microsoft deliberately made the Express versions of VS buggy and inconsistent in order to get people to get the full version. (Seriously have you ever tried installing Web Developer Express 2010 on a machine that already has C++ Express 2010 and/or Visual Studio SP1 on it? loving nightmare).
|
# ? Sep 23, 2011 04:43 |
|
I'm now working in an environment that uses TFS and VS2010. Previously I just used SVN. What I want to know, is what the best practice for references is. With the old way of doing things I'd copy the build output of a referenced project into a 'shared binary' folder in the parent project folder, and then add the reference in the parent project to the 'shared binary' folder. This enabled me to keep specific versions of dlls related to projects with each development cycle. Should I continue this practice, or switch to project references and use visual studio to get the latest version from tfs?
|
# ? Sep 23, 2011 05:38 |
|
Alright, I actually have a question about a thing other than the IDE: So, as a "You need to learn more about C# and do something kinda of fun" project, I'm building a Modeler for League of Legends, which in itself is unimportant at the moment. However, I'm trying to rebuild the talent trees in a talent tree calculator and after wrestling with a few design options, I decided to just take a screenshot of their talent trees and put panels over the buttons on the PNG thus creating a transparent 'button', but still capable of capturing a click. However, there are like 60 panels as a result and loading of this tab on the program takes a long time. Like 2 seconds long. In my little world, this seems pretty unacceptable and looks like crap. On top of this, I want to put about 120 labels on this page yet to track current points in talent and max points in talent. I can't imagine this will do the performance any favors. Is there a better way to do this that doesn't bog down the rest of it so badly? If you wish to look at it, it can be found here sans-DB: http://www.mediafire.com/?objiwiwdurrvqld Canine Blues Arooo fucked around with this message at 07:11 on Sep 23, 2011 |
# ? Sep 23, 2011 07:09 |
|
Canine Blues Arooo posted:I need an Image Map. Never used this before and I'm not sure about its performance but it might be worth trying out: ImageMap Control. Other ideas would be to have a still image (PictureBox control) that handles the Click event, whose behavior would be based on what the mouse coordinates are when clicked (this could be what that ImageMap control does, I don't know). As for the text, you could look into TextBlock, which is supposedly lighter weight and more appropriate for displaying text on its own than a label. You could also look into Graphics.DrawString, which will let you draw directly onto the canvas. It looks like that would require you to handle a Paint event(a good one to use is probably going to be the control that's displaying your big image). This is probably cheaper than a berjillion text controls.
|
# ? Sep 23, 2011 08:55 |
|
Nurbs posted:switch to project references and use visual studio to get the latest version from tfs? This.
|
# ? Sep 23, 2011 12:19 |
|
Che Delilas posted:Never used this before and I'm not sure about its performance but it might be worth trying out: ImageMap Control. This is awesome. I'll be trying this for sure!
|
# ? Sep 23, 2011 18:15 |
|
What's the best way display a list of links from whatever data source. I want a list that displays whatever number of records that are pulled from the query, like: <li class="someclass"><a href="xxx">name</a> - record number - date modified - <a href="call_to_delete_method">delete record</a></li> I guess I could do it writing a bunch of HTML markup in the code, but is there a better way of doing this?
|
# ? Sep 23, 2011 18:30 |
|
^^^^^ Web Forms: check out the repeater MVC: Loop through, make html in the view. If the line item is horrendously compex you might want to consider a partial view to render it.
|
# ? Sep 23, 2011 19:44 |
|
wwb posted:^^^^^ Ah repeater is what I was looking for, thanks. No MVC as this is some lovely inherited code. Hopefully going to get a chance to completely remake the thing in the next month or two.
|
# ? Sep 23, 2011 20:06 |
|
Hehe. Well, if you want to make yourself feel better you can do it MVC style in webforms -- just expose the collection as a protected property and you can access it directly from CodeBehind.
|
# ? Sep 23, 2011 22:10 |
|
I've got a problem with ASPNETMVC DataBinding that I don't understand.code:
code:
code:
What am I doing wrong?
|
# ? Sep 23, 2011 22:53 |
|
|
# ? Apr 23, 2024 14:56 |
|
Smugdog Millionaire posted:What am I doing wrong? I'm just guessing, but your properties don't have an access modifier, so they default to private, and databinding probably doesn't work on private fields or properties.
|
# ? Sep 23, 2011 23:36 |