|
Someone please help me with this problem, it's driving me mental. I maintain and extend an old .net 3.5 Winforms app. It was created in VS 2008 but I recently updated the project to VS 2013. As part of the migration, it automatically switched the targeted framework to 4.5. I didn't want to force all my users to upgrade (they have some XP machines), so I switched the target back to 3.5. There was a warning that I might have to manually edit some project files to get it to build, but it built and run fine so I didn't worry about it after that, everything was running fine on the customer's machines. Recently I was asked to make some changes in part of the system that uses a bunch of stuff from Windows.Forms.DataVisualization.Charting. I can't open these forms up in the designer, I get a big page of errors and a warning that the designer might become unstable and I might lose some controls. The main errors are a bunch of failures to resolve the charting classes, stuff like this: "Could not find type 'System.Windows.Forms.DataVisualization.Charting.ChartArea'. Please make sure that the assembly that contains this type is referenced. If this type is part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU'. If I ignore them and open them in the designer, all those charts disappear. The thing is, all the references in the project are pointing to the 3.5 version of the assembles, the projects build and run fine, and if I add new charts, they work fine too. The only thing that doesn't work, is opening up the existing forms in the designer. I don't understand why the compiler can resolve the references, and build the project, but the designer can't. I've tried deleting and re-adding the references and it doesn't help. Although one thing I've noticed is that if I hover over the Chart control in the toolbox, it says version 4.0, even if I manually add those controls by adding the 3.5 version of the DLL onto the toolbox. I tried switching the project to 4.0 and was then able to open the forms in the designer (wtf), but then when I tried to add new charts, I got an error message about not being able to create a reference to the assembly, which also seems odd, since I already had one. I managed to fix this by deleting and re-adding the references, and then everything worked, but the project was targeting 4.0, which I'm really trying to avoid. Does anyone have any idea how I can get this working while still targeting 3.5?
|
# ¿ Jul 10, 2014 13:04 |
|
|
# ¿ May 4, 2024 16:13 |
|
chippy posted:Someone please help me with this problem, it's driving me mental. Further to this... On my work machine (probably because I hosed around with it so much yesterday, trying to clear out all .NET 4.0 versions of the charting DLLs), I'm no longer able to add the .NET 3.5 chart controls to my toolbox in VS 2013. If I drag the DLL on, nothing happens. If I choose "Add Items", browse to the DLL and select it, I'm told the file doesn't exist, which is clearly not true as I just browsed to it. And before that, if I add the chart DLLS from C:\Program Files (x86)\Microsoft Chart Controls\Assemblies, I'd get the massive page full of errors saying the types could not be found, but if I added the exact same files from a different location (C:\Charts), I'd get a single message saying the assembly couldn't be loaded. So last night I tried the project on VS 2013 on my machine at home. I was able to install the .3.5 Chart Controls, add them to my toolbox, and add a chart to the project, all with no issues. But then when I saved, closed and re-opened the project, I got the page full of errors saying the types couldn't be initialised, on the form that was previously working fine in the designer. Help
|
# ¿ Jul 11, 2014 08:51 |
|
Newf posted:I cannot help, but you have my sympathy. These are the parts of development that make me want to jump out of a plane. You're telling me. I can't even add the 4.0+ Chart Controls to my toolbox anymore in VS 2013. They're in my GAC and I can add references to the project but if I try and add them to my toolbox they're not in the list of available .NET components, I have to browse to the files or drag them onto the toolbar. The former produces a message telling me either the DLL is invalid or doesn't exist, depending on what version I try. The latter produces a default 'bing' sound and absolutely nothing else This is after completely uninstalling and reinstalling VS and the .NET Framework. Some of these chart widgets are on the main dashboard of the software so I can't even do any changes to that any more because even I changed something unrelated, the designer fucks the charts up. I've had to go back to an older branch of the project on VS 2008 for now, but the other migrated version has a couple of months of work on other features on it, including changes to various forms, so including designer files, and I've no idea if it'll even be possible to merge that into the unmigrated VS 2008 branch without buggering up everything.
|
# ¿ Jul 11, 2014 13:51 |
|
I sometimes scaffold a view or two and then customise it, just to get all the labels and displayfors and things in place first, but I generally do it manually. Controllers I always just write from scratch.
|
# ¿ Jul 12, 2014 14:06 |
|
Well, after my previous posts, I can no longer add chart controls of any version to my toolbox in Visual Studio, to the point where I've had to install Windows and VS 2013 on a VM today in order to do anything. Incidentally, on the VM, if targetting .NET 3.5, I can add chart controls to my toolbox and add them to a form in the designer and it seems but, but if I close and re-open the solution again, the designer freaks out in the same way as before, saying the types are undefined. Even though I added them in the same environment right before. Targeting .NET 4, I can add the controls. At this point I think I might just force an upgrade on my users.
|
# ¿ Jul 14, 2014 21:03 |
|
Newf posted:Ah, that clarifies. Bear in mind that it's also recommended that if you override Equals(), you should also override GetHashCode(), to ensure that in any case where Equals() returns true for a pair of objects, GetHashCode() would return the same hash, and vice versa. In Java at least, if you don't do this, you can get funky behaviour with Sets and other collections. I'm not 100% sure if this applies to C# too, but I would think it likely.
|
# ¿ Jul 16, 2014 15:40 |
|
RICHUNCLEPENNYBAGS posted:Yes, I know that. But that doesn't help me do things like visit expressions, modify them, etc. So what I would like to see is the equivalent, long-way-round code. I think maybe you can do this by compiling and then decompiling with the decompiler set to a lower version of .NET or something like that. Is this what you need? http://msdn.microsoft.com/en-us/library/bb397951.aspx
|
# ¿ Jul 26, 2014 15:06 |
|
Help a brother out with a simple Winforms problem. I want a ComboBox that you can type in, and it will autocomplete/suggest items from the list, but NOT allow free entry of something not in the list - it still has to be something from the list. Setting the ComboBoxStyle to DropDownList comes close, but it doesn't "walk along" search; pressing a key jumps to an item whose first letter matches the key you pressed, but pressing another key will do the same again instead of matching the second character. Is there a way of achieving this that doesn't involved hijacking OnKey or TextChanged events? This seems like something that should be easy without that much loving about.
|
# ¿ Oct 16, 2014 16:08 |
|
I'm working on a number of reporting widgets for a factory control system that I maintain. They show KPIs in a variety of formats. The boss wants to be able to resize them so he can have them nice and big on large displays in the factory, and he always wants to be able to make them small so he can open lots of them on one screen for his own benefit. I've got the charts themselves resizing nicely but the labels (not the chart labels, but other text labels on the form) are being a real pain. At the moment I'm having to just fiddle about and find optimum font sizes for different heights and weights of the form, and change them as appropriate by handling the resize event. Does anyone know if there's a less fiddly and soul destroying weight of doing this? Something a bit more automagic?
|
# ¿ Oct 22, 2014 12:31 |
|
Bognar posted:Why not make use of Ajax? The "link" is just an anchor tag that is bound to an event that fires an Ajax POST to your server. You could then register a callback on successful completion of that HTTP request to change that row, refresh the table, or do whatever you want to do. This is what I would do. Use Ajax.ActionLink. You can set the method to POST in the Ajax options so that you can't just approve users using the URL. It would be something like this (dependant on the name of your action methods and controllers): code:
e: If it's not referenced by default you can install it with NuGet: http://www.nuget.org/packages/jQuery.Ajax.Unobtrusive/ e: This might be worth a look too: http://haacked.com/archive/2009/01/30/simple-jquery-delete-link-for-asp.net-mvc.aspx/ e: This is also good reading, although it deals with delete links, a lot of these concepts apply still: http://stephenwalther.com/archive/2009/01/21/asp-net-mvc-tip-46-ndash-donrsquot-use-delete-links-because chippy fucked around with this message at 11:10 on Nov 11, 2014 |
# ¿ Nov 11, 2014 10:53 |
|
mortarr posted:In fact, I remember I got so cross with the whole thing I put the report up on the sql server and just called that from my mvc proj. This is what we do too.
|
# ¿ Dec 18, 2014 14:34 |
|
Can I use a List of Strings as a the key for a dictionary? Or, can anyone think of a neat solution to this? I've got a collection of Foos, each of which has a collection of Strings. I need to find each unique list of Strings, along with the Foos that share it. p.s. VB, not C#, if it makes any difference. p.p.s. I am aware that this is a somewhat remedial level question, but I am ill and sleep deprived and it is the end of the day. chippy fucked around with this message at 18:24 on Dec 22, 2014 |
# ¿ Dec 22, 2014 18:22 |
|
Sedro posted:You can, but the List in .NET doesn't implement equality/hash in terms of its items. So you should use a custom EqualityComparer when you construct the dictionary. Thanks, yeah I just tried it out in LINQPad and found that the standard equality operator won't work. I'll look into that.
|
# ¿ Dec 22, 2014 18:36 |
|
Thanks everyone. I ended up writing a custom IEqualityComparer and using GroupBy().
|
# ¿ Dec 23, 2014 12:44 |
|
DreamSpark is pretty great. You don't get quite as much stuff as is available with an MSDN subscription but there is plenty of stuff, including all versions of VS. I signed up for the Github student developer pack thing recently and was told they would email me about it in "a few weeks". Anyone know why there's such a long delay setting it up?
|
# ¿ Jan 28, 2015 16:04 |
|
For what it's worth, I've seen non-conflicting merges produce invalid XML in project files as well.
|
# ¿ Feb 10, 2015 17:08 |
|
I'm afraid I don't know the answer to your specific question but this looks to be a good starting point: https://msdn.microsoft.com/en-us/library/office/hh243703(v=office.14).aspx https://msdn.microsoft.com/en-us/library/office/hh243697(v=office.14).aspx edit: Looks like you would want to use the ConversationManager to get the Conversation that interests you, and then you can set the title via its 'Properties' Property dictionary, one of which is 'Subject', which I'm guessing is probably the title you want. https://msdn.microsoft.com/en-us/li...office.14).aspx chippy fucked around with this message at 17:59 on Feb 17, 2015 |
# ¿ Feb 17, 2015 17:52 |
|
In WinForms, if I've got a ListBox showing a list of entities, and I want to update this listbox with a fresh list I just pulled out of the database, what's the 'best practice' way of doing this? More specifically, I want to maintain the selection. If an item is selected in the list and is still in the list after the update, it should remain selected. It it's removed I guess the selection should jump back to the first in the list, or maybe the previous. Just changing the DataSource property to the new collection will reset the selected item as well. I'm guess I should be using a BindingSource or something like that? chippy fucked around with this message at 14:35 on Feb 25, 2015 |
# ¿ Feb 25, 2015 14:33 |
|
crashdome posted:
Thanks for this. When I used the List as the datasource for the ListBox directly, it didn't seem to update the display of the listbox as I added and removed items. I ended up creating a BindingSource with the list as its datasource, and then using that as the datasource for the listbox. Once I did it that way, it kept up with any items added or removed, and also took care of maintaining the selection automatically.
|
# ¿ Feb 26, 2015 09:45 |
|
crashdome posted:Yeah, BindingSource is great. A list doesn't have any INotify ....blah blah... so you'd have to call Suspend, Resume, Refresh on the listbox control manually during the update. Thanks for reminding me how much I don't miss WinForms. Yeah, it sucks balls. Really hoping to get some WPF work in my job come up so I have a chance to learn it - I don't have the time in my spare time in between doing my degree. I used to do 3 days a week on a MVC project and 2 days on the old Winforms nonsense but it's been 5 days a week on Winforms recently
|
# ¿ Feb 27, 2015 18:53 |
|
Another (VB) WinForms question for you. I found out yesterday that a custom control (a sort of file browser thing cobbled together out of a treeview) was throwing null reference exceptions in multiple places. However, none of the users had mentioned it to me. After some fiddling I realised that they are only thrown when I'm debugging, and when the app is running in deployment, something is swallowing them. The exceptions are being thrown by code in event handlers for drag and drop events, there is no Try/Catch block in the handlers... where exactly 'above' the form can they be being caught? My googling so far has suggested that they might be being caught by a Try/Catch in the 'Main' sub, but I haven't explicitly implemented one so it seems that in Winforms that means it would be getting injected by the compiler when built - or, that it could be being caught by global exception handling, but ApplicationEvents.vb is empty. Does anyone know where this exception could be going, or how I can found out? update: I placed a button on the form that holds the control that's throwing the exceptions, that does nothing but throw a new NullReferenceException. If I click this in deployment, the unhandled exception is being alerted and the program exits, so it's not that somethign is catching all such exceptions. What is the difference here? The custom controls are in a seperate project in the same solution, could this have anything to do with it? another update: I put a TreeView on the form next to the custom control and wrote drag-drop event handlers for it that just throw exceptions. They just disappear when running in deployment just like the custom control ones do. So I guess it's not to do with it being in a different project. Could it be something to do with it being a drag event? chippy fucked around with this message at 11:29 on Mar 4, 2015 |
# ¿ Mar 4, 2015 10:01 |
|
Ah. It's because it's in a drag drop event. Something to do with boundaries between managed and unmanaged code.
|
# ¿ Mar 4, 2015 12:15 |
|
Hughmoris posted:Is there a simple way to iterate through regex matches in C#? code:
|
# ¿ Mar 6, 2015 10:17 |
|
Does anyone know--- if you call a method that does ADO.NET stuff, from inside a 'using x as TransactionScope' block, does the stuff in the called method get done within the transaction scope too? e: Looks like yes. chippy fucked around with this message at 10:35 on Mar 13, 2015 |
# ¿ Mar 13, 2015 10:10 |
|
Scaramouche posted:Off the top of my head the &/&&/AndAlso and |/||/OrElse are probably the two biggest 'gotchas' about VB.net as compared to how other languages work. Actually bitwise operators too have a few quirks, maybe brain up on them: I know this was a couple of pages back but it's probably also worth mentioning that 'And' does not short-circuit whereas 'AndAlso' does, likewise 'Or' and 'OrElse'.
|
# ¿ Apr 2, 2015 10:42 |
|
Dapper performance question, if anyone can help: I'm using dapper in a Winforms project. At some point, I have to shove a load of Foo's (anything from 1 to probably around 100 at the top end) into the database. Dapper handles this pretty nicely, I can pass the SQL and the collection of Foos in to the Execute method and it deals with it. Previously it was fine to just shove them in the db and forget about them as that is the last time they were needed. Now, however, I need to populate their ID fields as they are updated as we need them for something afterwards. This is easier enough to do, I'll just add SELECT SCOPE_IDENTITY() on to the end of the SQL and use the Query() method instead. However, this does mean I can't just hand in the collection of Foos because I need to individually update the ID property of each one, so I'll have to loop through the collection and hand each into the Query method individually. Two questions here: Is there a better way of doing this with Dapper, and is this going to perform horribly compared to the batch insert I was doing before? If it makes any difference, I'm doing all of this wrapped in a TransactionScope. chippy fucked around with this message at 18:05 on Apr 13, 2015 |
# ¿ Apr 13, 2015 17:42 |
|
chippy posted:Dapper performance question, if anyone can help: p.s. I'm gonna test this myself, just hoping someone also happens to have a quick answer chippy fucked around with this message at 18:04 on Apr 13, 2015 |
# ¿ Apr 13, 2015 17:51 |
|
Mr Shiny Pants posted:For a 100 inserts? I would test it, I think you will be pleasantly surprised by the performance. Yeah, I'm not expecting it to take too long. I know that Dapper is pretty performant and this isn't a lot of data to be inserting, the problem is that this application is used at a factory where it's run on a lovely network. mostly on terminals with poor wireless connections, and all supported by a copy of SQL Server 2008 Express running on lovely old hardware. All of which they are very resistant to improving if it involves spending any money. There are hundreds of these inserts flying around all the time and they do have performance issues already, so I have to be very careful with anything that might make it worse.
|
# ¿ Apr 14, 2015 09:21 |
|
Piss, it takes about twice as long. e: No it doesn't, I'm a twat. chippy fucked around with this message at 10:12 on Apr 14, 2015 |
# ¿ Apr 14, 2015 09:55 |
|
I would absolutely love to be able to do something like that but I would never be given the time to do it. The application is a years-old hulking mess cobbled together by a non-programmer and most parts of it are too far gone for anything other than a major rewrite. There's no core application, just a load of WinForms clients throwing SQL at the database. I posted some code once in the Coding Horrors once and got a lot of condolences and "get out as soon as you can" type responses. It's just me, bolting on new features on my own, to unreasonably short timescales.
|
# ¿ Apr 14, 2015 17:15 |
|
gently caress me, ListViews in WinForms are the WORST thing.
|
# ¿ Apr 17, 2015 11:16 |
|
Does anyone know why Visual Studio would do this? I'm referring to the first incidence of panelProducts being highlighted like that. It's a local variable, passed in to the Sub as a parameter, and that's the first time it's references in the method. At first I thought I must have accidentally clashed with a class name or something, but as you can see, subsequent references aren't highlighted, and it does it no matter what I call it.
|
# ¿ Apr 28, 2015 15:15 |
|
loving help me goons before I kill someone. All I want to do is copy the client area of one form, and set it as the background of another form. I've tried a million things today, mostly nicked from SO, and I either get no background or some sort of stupid "General GDI error' exception. When I write the capture BitMaps to files they are just plain black rectangles. Here's what I have at the moment, as I say, mostly stolen code:
Someone save me? p.s. Winforms p.p.s Also tried this, similar results: code:
|
# ¿ May 7, 2015 16:30 |
|
Wait, no! The second bit is now getting *something*, but it's the wrong part of the screen. I am going to shoot myself. edit: OK, mostly there, except I'm getting the title and bar and minimize, restore, etc. controls. final edit: Don't worry goons, you can take me off suicide watch. Next time I'll just ask for help immediately instead of just struggling for hours, as Sod's Law dictates that this will cause me to immediately get it working. chippy fucked around with this message at 16:51 on May 7, 2015 |
# ¿ May 7, 2015 16:33 |
|
I loving give up. OK, so, Plexiglasss is just a borderless form with a blurred, faded image of the form it's given in its constructor set as its background. If I do this: code:
But if I do this in another method of the form: code:
I even tried sleeping for 5 seconds in case the work was just happening too quickly. Nothing. Someone help me before I actually do kill myself? e: Got it. Needed to call Refresh on the glass. Anyone know why calling it in its Shown event handler wasn't enough? ee: Putting it in the Activated handler worked. gently caress Winforms. chippy fucked around with this message at 17:47 on May 7, 2015 |
# ¿ May 7, 2015 17:38 |
|
Goons, help (Winforms). I have a textbox that needs to be able to accept a tab character. I can do this by making it MultiLine=True and AcceptsTab=False. However, I also need it to NOT accept/type a carriage return when Enter is pressed, as I need this to trigger an event. However, according to MSDN, AcceptsReturn=False only works if the form has a default Accept button, otherwise the Textbox will get a carriage return in it anyway. The form doesn't have a default OK button so what is happening currently is that the Enter key is triggering the event, but is also inserting a carriage return into the Textbox, which is only 1 line high so the 1st line is then disappearing. I need to trigger the event on the Enter key, and NOT have it insert a carriage return. I'm considering a hidden default Accept button but this seems hackish. Can anyone suggest a proper way of doing this? If anyone's wondering, these weird requirements are because the form is driven by a barcode scanner that emulates a keyboard. Operators need to be able to drive the whole thing with just the scanner, without using keyboard and mouse. Some of the barcodes use a tab character as a delimiter (I have no control over this), and the scanner automatically sends an 'Enter' keypress at the end of the scan (I have no control over this either). This was all working before but the tabs in barcodes are a new thing that's thrown a bit of a spanner into the works. Probably also worth mentioning that the handler for the Enter being pressed is a KeyDown event at the form level. I'm not sure why this was done rather than handling the keydown event for each textbox individually. I thought it might help to handle them at the textbox level but when I created a test form to try this out it didn't actually make any difference.
|
# ¿ May 20, 2015 17:53 |
|
SirViver posted:Just checked it and this should do it: Ahhh, thanks, I'll give this a go. I actually already tried pretty much exactly this, but I was using KeyDown, so taht explains why that wasn't working.
|
# ¿ May 21, 2015 08:49 |
|
Got a loving weird problem. As soon as I try and instantiate an SqlConnection, my application immediately exits, with nothing caught in my catch block. I'm literally just doing this in a simple C# console application:code:
Any idea, anyone? e: Saw someone on Stack Overflow with this problem, a using block fixed it for them (it doesn't for me). I also saw some people suggesting that his .NET installation was broken, but I have other projects that this is working fine in. chippy fucked around with this message at 17:42 on Jun 3, 2015 |
# ¿ Jun 3, 2015 17:39 |
|
No, not in release. The method that uses the connection is actually the callback for a Timer. I found that if I just call the method without using the timer it doesn't have this problem. Anyone know why that would stop it working? It should be pretty simple. It's just a service that needs to run a stored procedure every few seconds. Maybe my approach is all wrong, I'm not at work now bit I'll post some code tomorrow.
|
# ¿ Jun 3, 2015 22:18 |
|
|
# ¿ May 4, 2024 16:13 |
|
ljw1004 posted:https://msdn.microsoft.com/en-us/library/system.timers.timer.elapsed%28v=vs.110%29.aspx Hmm ok, well that solves one mystery, but the question is, why is just instantiating the SqlClient with its default constructor throwing an exception, and why is it not throwing the exception when the same method is run without using the timer?
|
# ¿ Jun 3, 2015 23:30 |