|
UberJumper posted:Does anyone know any sort of alternatives to PropertyGrid? I feel like i am fighting for every inch when using it. It matters what you want to do. The less editable you want the grid to be, the easier it is to implement. Reflection is awesome, but also requires a lot of typing. I haven't found a good control that handles it all well.
|
# ? May 31, 2011 04:11 |
|
|
# ? Apr 25, 2024 11:32 |
|
I have a WinForms application that runs and shuts down fine when launched within Visual Studio, but the standalone .exe throws an unhandled exception at shutdown. The program has quite a few backgroundworkers and timers going on so I suspect that a thread might not be getting shut down properly or some element is trying to update the UI after the main form has started closing. The text of the .exe error message box is totally useless, and no amount of try/catch blocks seem to capture the exception - any suggestions as to where to go next?
|
# ? May 31, 2011 14:01 |
|
Try attaching a handler to System.AppDomain.CurrentDomain.UnhandledException and log the entire exception.
|
# ? May 31, 2011 14:22 |
|
Debug the executable with Windbg.
|
# ? May 31, 2011 15:57 |
|
PDP-1 posted:I have a WinForms application that runs and shuts down fine when launched within Visual Studio, but the standalone .exe throws an unhandled exception at shutdown. The program has quite a few backgroundworkers and timers going on so I suspect that a thread might not be getting shut down properly or some element is trying to update the UI after the main form has started closing. What does the even viewer log say in application?
|
# ? May 31, 2011 17:19 |
|
And do you not get the option to debug when the app crashes? Unless you're using an Express version of visual studio it should be there I think.
|
# ? May 31, 2011 17:21 |
|
dwazegek posted:Try attaching a handler to System.AppDomain.CurrentDomain.UnhandledException and log the entire exception. Zhentar posted:Debug the executable with Windbg. Thanks, I'll give these a shot. The UnhandledException thing sounds easiest so I'll give that a go first. Most likely won't have a chance to try it until tomorrow however since that system is in another building. Sprawl posted:What does the even viewer log say in application? I don't get a log, just a pop-up window stating that "An Unhandled Exception occurred in ApplicationName.exe", plus buttons for 'OK' or 'Show Details'. The Show Details option brings up a textbox containing a bunch of gibberish that I assume is some kind of core dump or info that Windbg is supposed to parse through. I should look into what it is more and how to deal with it since it's obviously intended to help in just this kind of situation. rolleyes posted:And do you not get the option to debug when the app crashes? Unless you're using an Express version of visual studio it should be there I think. No option to debug, just the dialog window described above. This is the express version of C#. Thanks for the help all, it's at least given me a few leads to go on.
|
# ? May 31, 2011 18:19 |
|
Bozart posted:If I don't want to shell out for the full version of VS, what IDE should I use? I've been using Visual Studio Express, but it doesn't allow some of those plugins mentioned earlier - is #Develop better? What do people use? If you're a student (even at places without MSDN-AA) you can get VS Professional for free via DreamSpark. If you're a start-up business or developer then if you write a good-enough business case you can apply to BizSpark, which confers access to the fully-blown MSDN Subscriber Downloads section (sans VL keys). I applied twice and was rejected each time (however my business partner applied and got in first-time, which suits us fine). SharpDevelop was the original open-source C# IDE but wasn't cross-platform; MonoDevelop is a fork off SharpDevelop that switched from WinForms to GTK# so it would run better on Linux. SharpDevelop and MonoDevelop are both kind-of similar in terms of capabilities and usefulness for small to medium scale applications. I suppose you could develop a simple killer-app on it and then use the proceeds to license VS Professional properly...
|
# ? May 31, 2011 21:48 |
|
On the subject of DreamSpark I'm aware that people (I think mentioned here before for one) have been authorised for DreamSpark using alumni email addresses as they still have the all important academic TLD. I don't know what the legalities of this are, I guess you'd have to read the terms and conditions on the DreamSpark site if that was of concern to you.
|
# ? May 31, 2011 21:52 |
|
New to .net here and have a question. I'm redoing this .net site that using the razor syntax/template stuff. I have many .cshtml files etc. Whenever I go to edit a cshtml file and save and hit refresh on the browser, the changes don't show up. They only change whenever I do a rebuild. This is quite annoying. So I created a new project with the razor stuff and tested it and whenever I edited the cshtml file and refreshed in the browser, the changes would appear. I'm using the standard .net dev web server. It's not a caching issue on the browser either btw. Any tips on why this project would require me to rebuild all the time?
|
# ? May 31, 2011 22:09 |
|
As per the database thread, I'm asking this here; can anyone point me towards some good tutorials for working with Datasets and Databases in VS2010? I have an OK enough understanding of SQL (to the point where I can interact with databases in the abstract sense and 99% of the tutorials I can find are useless basic basic stuff or not at all related to what I want) but I'm having a hard time figuring out how to go about interacting with them via VS. Like what the IDE is doing automatically and what I need to do and what I don't need to do to prevent duplication etc. etc.
|
# ? May 31, 2011 22:15 |
|
Mr. Crow posted:As per the database thread, I'm asking this here; can anyone point me towards some good tutorials for working with Datasets and Databases in VS2010? How have you been setting them up? Are you using all the build in connectors? iirc if your using a Dataset and datatables into a DataView it should do everything with MSSQL automatically.
|
# ? May 31, 2011 23:05 |
|
I'm working on a Windows Phone 7 project using XNA. Part of this involves porting a library (a pure C# Lua runtime) not designed to run on the Compact Framework or with security-critical restrictions. The library uses several methods that you can't get away with on the phone, specifically for loading binary files, like Marshal.SizeOf(), GCHandle.Alloc(), Marshal.PtrToStructure(), and GCHandle.AddrOfPinnedObject(). Let's say I hack around using Marshal.SizeOf() since I know what types are going to be used, and just hardcode their sizes. Is there a way to take, say, an array of 4 bytes and call it an int, or some other arbitrary type?
|
# ? Jun 1, 2011 00:23 |
|
See if you can use the static methods on BitConverter and Buffer.
|
# ? Jun 1, 2011 03:58 |
|
I just fixed F# support on dotnetpad.net (it's been broken for ages). If you've been disappointed you couldn't write F# snippets and share them with folk, you're welcome! Sorry about leaving it broken for months though.
|
# ? Jun 1, 2011 05:37 |
|
Sedro posted:See if you can use the static methods on BitConverter and Buffer. If your library is using AllocHGlobal and PtrToStructure as a means of converting saved files to in-memory objects (and nothing else) then just load the file into a FileStream and read from the stream with a BinaryReader. Just add a new constructor to your structs with a BinaryReader argument and set each struct field explicitly by reading.
|
# ? Jun 1, 2011 12:56 |
|
Sedro posted:See if you can use the static methods on BitConverter and Buffer. BitConverter was exactly what I was looking for, thanks.
|
# ? Jun 2, 2011 00:58 |
|
Here's my weirdness for today, with a solution even! I was trying make a generic version of an existing method that acts on one specific object that implements an interface. Here's the problem condensed down to some classes and interfaces. Given a setup like this: code:
code:
Here's a solution that looks like it works (with due credit to one of my co-workers): code:
|
# ? Jun 2, 2011 01:38 |
|
The reason is that when you do this:code:
code:
npe fucked around with this message at 04:19 on Jun 2, 2011 |
# ? Jun 2, 2011 03:52 |
|
Funnily enough I've just been digging a bit further into covariance (and contravariance), in particular the use of the "in" and "out" keywords when defining a generic interface. In summary, it made my head hurt for a bit but once you understand the reasons behind it (and can remember which is which ) it is indeed cool.
|
# ? Jun 2, 2011 09:34 |
|
Thanks npe, that was very enlightening!rolleyes posted:Funnily enough I've just been digging a bit further into covariance (and contravariance), in particular the use of the "in" and "out" keywords when defining a generic interface. In summary, it made my head hurt for a bit but once you understand the reasons behind it (and can remember which is which ) it is indeed cool. Yeah, that's on my increasingly long list of things to really study.
|
# ? Jun 2, 2011 11:33 |
|
I'll add that anytime you are using a where clause in your generic declaration, you should probably reconsider if you should, in fact, be using a generic here. In this case, you should have left the generic off FooManipulator and pushed it over to FooArray at least.
|
# ? Jun 2, 2011 12:24 |
|
Question on best practices for writing a gui - winforms based. Say I have a class with events, and I have a gui that I want to show these events on. Should I: a) Write an event handler that triggers on the event, sending no event args, and read the properties of the class for the data I need. As far as I can see this has the risk that the data has changed since the event and when I read the property I am getting old data b) Write an event handler that triggers on the event, sending the interesting data in the event args. This seems like I would end up with a hell of a lot of custom event handlers. c) Bind everything by implementing the INotifyPropertyChanged interface into my class. d) Something else Typically I've done a), but it seems like a lot of typing and produces lots of code, turning small projects into large projects quickly. What are the best practices for writing a winforms gui? Cheers in advance!
|
# ? Jun 2, 2011 21:29 |
|
thebruce posted:Question on best practices for writing a gui - winforms based. Given that event handlers are executed synchronously with the code that triggered them then this scenario should never happen. If your code-with-events is executing on a separate thread then just use synchronous Control.Invoke rather than the asynchronous BeginInvoke, that way the values of your class at event-time will be used.
|
# ? Jun 2, 2011 21:59 |
|
thebruce posted:b) Write an event handler that triggers on the event, sending the interesting data in the event args. This seems like I would end up with a hell of a lot of custom event handlers. Not that defining a bunch of delegates is that much work, but there's a generic event handler precisely so that you don't have to this. System.EventHandler<T>, which is defined as delegate void EventHandler<T>(object sender, T e) where T : EventArgs
|
# ? Jun 2, 2011 22:39 |
|
I also define a generic EventArgs:code:
code:
code:
|
# ? Jun 3, 2011 03:06 |
|
I'm working on a new ASP MVC 3 website for analyzing data from an existing MySQL database. I've been working on getting Entity Framework 4 and LINQ to SQL to play nicely, but it seems there's a pretty bad bug in the MySQL connector that breaks group statements. Are there any good alternatives? Preferably I would like to use EF and/or LINQ, but if there are other good practices I'm not aware of (I'm new to .NET) I'd love to hear about them. Oh, and apparently our DBA won't let us use stored procedures and alternate connectors don't really work either.
|
# ? Jun 3, 2011 05:01 |
|
Sedro posted:As a side note, I wish there was a way to get the string name of an object/property/method at compile-time. While it's not exactly at compile-time, you can use expressions to get back member names. It's not performant compared to just using a string, but it's definitely useful. http://dotnetpad.net/ViewPaste/0dg9cAd8KUOkV7KR5NzrkA
|
# ? Jun 4, 2011 00:03 |
|
brainwrinkle posted:I'm working on a new ASP MVC 3 website for analyzing data from an existing MySQL database. I've been working on getting Entity Framework 4 and LINQ to SQL to play nicely, but it seems there's a pretty bad bug in the MySQL connector that breaks group statements. Are there any good alternatives? Preferably I would like to use EF and/or LINQ, but if there are other good practices I'm not aware of (I'm new to .NET) I'd love to hear about them. nHibernate is an option, but I've never done nHibernate to MySQL. There's also SubSonic, but I've never even used it and I have no clue about getting it to work with MySQL, so I'm leaving it up to you to evaluate it. Also, what the gently caress is wrong with your DBA that he won't let you use stored procedures? Are you supposed to use inline SQL if you can't get an ORM to work?
|
# ? Jun 4, 2011 00:05 |
|
PhonyMcRingRing posted:While it's not exactly at compile-time, you can use expressions to get back member names. It's not performant compared to just using a string, but it's definitely useful. It's not worth the performance hit to me, at least in a large project. You also can't use it in my switch statement example, because it's not a constant.
|
# ? Jun 4, 2011 00:15 |
|
Sedro posted:It's not worth the performance hit to me, at least in a large project. You also can't use it in my switch statement example, because it's not a constant. The performance hit can be evened out by caching the value elsewhere. But yeah, there's nothing you can do about the switch statement thing(unless you switch to an if statement).
|
# ? Jun 4, 2011 00:27 |
|
Ithaqua posted:Also, what the gently caress is wrong with your DBA that he won't let you use stored procedures? Are you supposed to use inline SQL if you can't get an ORM to work? A lot of off-site managed DBs are scared someone will write an sp that is DROP * or SELECT creditcardz FROM [notmydatabase] or something so they don't allow sp access because they're too lazy/stupid to secure it properly. Of course in the process removing a huge chunk of the functionality.
|
# ? Jun 4, 2011 00:45 |
|
Ithaqua posted:nHibernate is an option, but I've never done nHibernate to MySQL. There's also SubSonic, but I've never even used it and I have no clue about getting it to work with MySQL, so I'm leaving it up to you to evaluate it. Fortunately, there was a patch that worked with some tweaking, and I recompiled the connector and got around the problem. Thanks for the suggestions. I might still check those out because I'm having some difficulty translating these moderately complex SQL queries to LINQ.
|
# ? Jun 4, 2011 00:57 |
|
brainwrinkle posted:Fortunately, there was a patch that worked with some tweaking, and I recompiled the connector and got around the problem. Thanks for the suggestions. I might still check those out because I'm having some difficulty translating these moderately complex SQL queries to LINQ. At least with nHibernate, I've had good experiences with making a view that returns the exact data I'm looking for and working with that. Keep in mind, the ultimate goal here is to have the actual SQL be as simple as possible and let your code handle the logic. The thing I like about nHibernate is that it operates on plain C# classes without any need for attributes or anything nHibernate-specific. I could decide "gently caress nHibernate!" tomorrow and re-implement the data access part, and nothing else in my codebase would have to change.
|
# ? Jun 4, 2011 02:26 |
|
Question on VB/C# Async for ljw1004 or anyone else who's been using it yet: I'm working on a game (an RPG) as a hobby project and have been converting it to use Async for the ingame menus and such. This works really well and the logic for combat is really simplified. Here's the bit that gets a player's choice of action each turn in combat and performs it (from Encounter.vb): code:
The AI-controlled opponents use a different source which picks an action synchronously and returns it. Of course, this method is also marked Async so it can be awaited in the same way, so I get this compiler warning: quote:This async method lacks 'Await' operators and so will run synchronously. Consider using the 'Await' operator to await non-blocking API calls, or 'Await TaskEx.Run(...)' to do CPU-bound work on a background thread. I see what it's saying, but the method is only marked Async because its interactive counterpart is. Can I just ignore this warning or is there a better way to do this that I'm missing?
|
# ? Jun 4, 2011 14:18 |
|
I have an Active Directory question if anyone would be kind enough to give me some hints. I am trying to query active directory for all the users in a group. That part is fairly straight forward. I'm able to get the users, but unfortunately the object I get only has the user's real names, not their usernames. Here's what I'm doing: code:
code:
|
# ? Jun 7, 2011 00:26 |
|
MrHyde posted:I have an Active Directory question if anyone would be kind enough to give me some hints. If you're on .net 4 scrap whatever you've written and embrace System.DirectoryServices.AccountManagement if you're not, I don't have a clean way of getting what you want off the top of my head. Parse the CN or get DirectoryEntry objects for each object via the CN you have.
|
# ? Jun 7, 2011 03:14 |
|
Nurbs posted:If you're on .net 4 scrap whatever you've written and embrace System.DirectoryServices.AccountManagement 3.5 Active Directory stores group members by DN (the full CN=... form). Once you get the DN you can query for that user specifically (I believe there's a method on DirectorySearcher to look up something by DN) and the fields you want to read are the sAMAccountName or userPrincipalName.
|
# ? Jun 7, 2011 04:18 |
|
bear shark posted:3.5 Pardon me, my brain's not firing on all cylinders tonight
|
# ? Jun 7, 2011 05:21 |
|
|
# ? Apr 25, 2024 11:32 |
|
I have a stupid WPF question. I have this happy little grid here:code:
Now, most of you are probably thinking, "Bind to ActualWidth and ActualHeight." This occurred to me as well, but unfortunately, ActualWidth and ActualHeight always return 0 for this image and my border and image both disappear. Being as though the border is contained within a grid row, it fills the entire thing by default, so binding to the grid row's width and height won't change its current behavior in the slightest, unless I misunderstand how grid layout works.
|
# ? Jun 7, 2011 16:22 |