|
Prefect Six posted:I don't know what a method is yet A method is a labelled unit of work that can typically be called repeatedly* or combined with other methods to produce a more complex program *One method you can't call repeatedly is Environment.Exit() since that forces the currently running program to exit.
|
# ? Aug 27, 2012 00:46 |
|
|
# ? May 10, 2024 20:53 |
|
SirViver posted:Really? Where in the specs does it say that? Yeah, I should have ed Ithaqua, but I was worried that Prefect Six would miss it.
|
# ? Aug 27, 2012 08:43 |
|
I have a really strange error. My Visual Studio 2010 just exits entirely on its own. If I debug my application in Visual Studio and just leave it there, all of a sudden Visual Studio asks if I want to stop debugging. If I click "No", it will still exit on its own. It behaves just like an unhandled exception in that the process just dies, but there's no crash handler like you would expect. What the christ? Edit: Now running an instance of Visual Studio in another Visual Studio and debugging it. Edit edit: Results are in! This is what the non crashing Visual Studio reports. A first chance exception of type 'System.InvalidOperationException' occurred in JetBrains.Platform.dotTrace.Util.dll A first chance exception of type 'System.InvalidOperationException' occurred in JetBrains.Platform.dotTrace.Util.dll The above exceptions happen sporadically long before any crashes, so they may not be related. 'devenv.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Shell.StartPage\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Shell.StartPage.dll' The thread 'ExecutionMode - Thread 1' (0x1034) has exited with code 0 (0x0). The thread '<No Name>' (0xf0c) has exited with code 0 (0x0). 'devenv.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Windows.Design.Host\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.Windows.Design.Host.dll' A first chance exception of type 'System.ObjectDisposedException' occurred in Microsoft.VisualStudio.Shell.10.0.dll A first chance exception of type 'System.Runtime.InteropServices.InvalidComObjectException' occurred in VSLangProj.dll Above exception repeated 36 times A first chance exception of type 'System.Runtime.InteropServices.InvalidComObjectException' occurred in EnvDTE.dll A first chance exception of type 'System.Runtime.InteropServices.InvalidComObjectException' occurred in EnvDTE.dll The program '[4832] devenv.exe: Managed (v4.0.30319)' has exited with code 0 (0x0). Mongolian Queef fucked around with this message at 14:10 on Aug 27, 2012 |
# ? Aug 27, 2012 13:41 |
|
I had something like that happen when my application was talking to another process via remoting. If my application's actions caused a problem in the remote process an exception would get generated 'outside' my program and VS would terminate my program without providing any useful info. Try using the AppDomain.CurrentDomain.UnhandledException event to log the exception message and stack trace somewhere. That should pinpoint the code that's initiating the crash.
|
# ? Aug 27, 2012 14:18 |
|
I'm sorry, I completely forgot to mention that the above crash just happened even when my application wasn't running. The solution is loaded but all editor windows were closed. I wasn't using VS at the time, it just died. Edit: Tried the old "delete solution.sdf and solution.suo", but it still crashed while I was coding. Started VS with /Log now, will see if it finds anything funny. Mongolian Queef fucked around with this message at 15:56 on Aug 27, 2012 |
# ? Aug 27, 2012 14:39 |
|
Ithaqua posted:I said a method! But that's okay. So I hit a brick wall with methods using this tutorial. I'm trying to make two different methods to get a string input and then use stringbuilder to reverse the order of the strings. Here is my awful code: code:
|
# ? Aug 27, 2012 20:37 |
|
Well, you have most of it right, you're just missing a couple things. You know how to call a method, because you are calling it correctly for getWord(). For some reason you aren't doing that for reverseWord -- make sure you add parentheses to invoke (call) a method. Finally, the Console.WriteLine method accepts a string as an argument, you should be passing the result of your function--reverseWord--into it. Console.WriteLine(reverseWord). Edit: Oops, I didn't read the entire thing. You have a couple more problems. You should modify your reverseWord function to accept a string as an argument. code:
Orzo fucked around with this message at 20:49 on Aug 27, 2012 |
# ? Aug 27, 2012 20:46 |
|
tunah posted:I'm sorry, I completely forgot to mention that the above crash just happened even when my application wasn't running. The solution is loaded but all editor windows were closed. I wasn't using VS at the time, it just died. You did try sending a crash report to Microsoft, right?
|
# ? Aug 27, 2012 20:48 |
|
Orzo posted:Well, you have most of it right, you're just missing a couple things. You know how to call a method, because you are calling it correctly for getWord(). For some reason you aren't doing that for reverseWord -- make sure you add parentheses to invoke (call) a method. Ugh, good catch. I guess my only problem then is that StringBuilder has to be var type? And you can't return a var?
|
# ? Aug 27, 2012 20:52 |
|
Prefect Six posted:Ugh, good catch. I guess my only problem then is that StringBuilder has to be var type? And you can't return a var? Var is not a type. Var is a command to the compiler to infer the type. It doesn't work on method return signatures. It probably could, but it doesn't. So code:
code:
code:
Dietrich fucked around with this message at 21:10 on Aug 27, 2012 |
# ? Aug 27, 2012 21:05 |
|
Prefect Six posted:Ugh, good catch. I guess my only problem then is that StringBuilder has to be var type? And you can't return a var? Var isn't a type. It's just an implicit way to declare the type of the variable. These two lines of code are identical when compiled: code:
You might be asking why you can't just use var everywhere, but you'll get different answers to that question. I don't mind it because I know my development environment well enough to guess what methods will return, and in a pinch I can always just hover over a method name or property to figure out what the type is. I also hate typing long type names like IDictionary<string, IEnumerable<string>>. Opponents of var say it's harder to read code littered with vars, and don't like being able to change a return type of a method without compilation breaking at every point the method was used. Either way, you pretty easily rig something up to replace all of those vars if it becomes a problem, so do whatever you prefer.
|
# ? Aug 27, 2012 21:10 |
|
GrumpyDoctor posted:You did try sending a crash report to Microsoft, right? I would if it would have shown up. Like I said, the process just disappears.
|
# ? Aug 27, 2012 21:16 |
|
Prefect six: another thing, you need to call the ToString() function on your StringBuilder when you're done with it. That 'extracts' the contents of the StringBuilder into a string. Then you can return that string.
|
# ? Aug 27, 2012 21:18 |
|
Prefect Six posted:So I hit a brick wall with methods using this tutorial. I'm trying to make two different methods to get a string input and then use stringbuilder to reverse the order of the strings. I went through and put some comments in your code above.
|
# ? Aug 27, 2012 21:21 |
|
I'm still getting an error that tells me I can't implicitly convert type StringBuilder to string on the return and method call.
|
# ? Aug 27, 2012 21:37 |
|
Prefect Six posted:I'm still getting an error that tells me I can't implicitly convert type StringBuilder to string on the return and method call. Call a .ToString() on it!
|
# ? Aug 27, 2012 21:41 |
|
You need to return reverseWord.ToString()
|
# ? Aug 27, 2012 21:42 |
|
tunah posted:I would if it would have shown up. Like I said, the process just disappears. Oh, right. Do you get a crash report if you attach a debugger and then detach it?
|
# ? Aug 27, 2012 21:50 |
|
Funking Giblet posted:You need to return reverseWord.ToString() That did it, thanks guys!
|
# ? Aug 27, 2012 22:02 |
|
This is kind of a dumb question, but I've never made a class that inherits from another control before. Using some code I found online, I've made a property grid subclass that enables tab-key navigation. What I'm curious about is how does Visual Studios know to display this custom control in the Toolbox automatically?
|
# ? Aug 27, 2012 22:12 |
|
GrumpyDoctor posted:Oh, right. Do you get a crash report if you attach a debugger and then detach it? I'll check next time I'm working from home. Luckily this doesn't happen in the office.
|
# ? Aug 27, 2012 22:42 |
|
Sab669 posted:This is kind of a dumb question, but I've never made a class that inherits from another control before. Using some code I found online, I've made a property grid subclass that enables tab-key navigation. What I'm curious about is how does Visual Studios know to display this custom control in the Toolbox automatically? Because you're inheriting from a control, so it knows your class is a control and adds it as a user control. Visual Studio is just smart like that. If you want to disable it, there's an option in VS to do so.
|
# ? Aug 28, 2012 02:57 |
|
I'm trying to get a vb.net program to be able to type into another program using Sendkeys. So far I can't even get a VB program to grab any foreground window other than itself, however. What is the secret here? So far I cannot find one easy-to-understand, working example of this (written in vb.net) online. The example below works, but not really, because it only works when the VB program itself has focus--which is no help. When the vb program isn't in the foreground, the timer event doesn't seem to trigger at all, and yet everything I've read says that it should. What is wrong with it? code:
|
# ? Aug 28, 2012 14:27 |
|
edmund745 posted:I'm trying to get a vb.net program to be able to type into another program using Sendkeys. So far I can't even get a VB program to grab any foreground window other than itself, however. What is the secret here? So far I cannot find one easy-to-understand, working example of this (written in vb.net) online. There has to be more code than that. The code you pasted shows literally nothing.
|
# ? Aug 28, 2012 14:29 |
|
Ithaqua posted:There has to be more code than that. The code you pasted shows literally nothing. Well,,, the timer event is set to Button6_Click. I forgot to comment that on there. That should be all it takes.... And it does work, when the vb program is in the foreground. The timer just doesn't work when its in the background. So maybe this is more of a timer question? I have also tried putting timer1.start and timer1.stop in the buttons with the timer enable/disable, and it still does(n't) do the same thing. :\
|
# ? Aug 28, 2012 14:35 |
|
Where is the sending keys bit supposed to be happening?
|
# ? Aug 28, 2012 14:41 |
|
Jabor posted:Where is the sending keys bit supposed to be happening? Here is another example I tried: http://www.vbforums.com/showthread.php?281243-Get-Active-Control-Resolved&highlight=active (the example code given in post #10) It works fine when the VB program has foreground, but when its in the background it raises an error about an "unbalanced stack". A number of the others I tried said the same thing.
|
# ? Aug 28, 2012 14:53 |
|
well nuts. I been trying to find ONE working example of this for about three days now. I finally come on here and ask, and about two minutes later find one that actually works: http://www.vbforums.com/showthread.php?494477-Get-foreground-window-text The code given in post #10 there does actually work. And doesn't crash the program or anything. ------ This has been a pain I think because a lot of examples aren't concerned with finding ANY foreground window,,, they just have a bunch of child windows, and are trying to find out which one the user is in.
|
# ? Aug 28, 2012 15:02 |
|
Well I've had to do this before so you get lucky! There is probably a better way of doing this, but maybe not sending keys between different programs is pretty much always a kludge.code:
adaz fucked around with this message at 15:49 on Aug 28, 2012 |
# ? Aug 28, 2012 15:43 |
|
PROBLEM: Someone's birthday is in a datagridview cell in yyyy/mm/dd format. I want to get a copy of it in mm/dd/yyyy format in a masked text box in case it's wrong and needs to be edited. After all, I'm pretty sure his birthday isn't 19/81/1028. SOLUTION: code:
|
# ? Aug 28, 2012 20:01 |
|
Personally I'd do proper date parsing instead of just shuffling strings around, but both gets the job done. Using a StringBuilder wouldn't make this more elegant nor perform better, btw.C# code:
E: Though the whole thing smells like a badly designed application. Stuff like date formats should be handled by the controls black-box style, i.e. displaying and reading them according to the current user's culture settings. All you should ever see is DateTime instances, not having to mess around with string manipulation. SirViver fucked around with this message at 20:26 on Aug 28, 2012 |
# ? Aug 28, 2012 20:21 |
|
adaz posted:Well I've had to do this before so you get lucky! There is probably a better way of doing this, but maybe not sending keys between different programs is pretty much always a kludge. The vb program loses focus when the timer tics, but nothing appears in the target window (in this case, notepad--the only other window open).
|
# ? Aug 28, 2012 21:30 |
|
edmund745 posted:
This doesn't do what you think it does. Form.ActiveForm gives you the currently active form in your application. It knows nothing about any outside application.
|
# ? Aug 28, 2012 22:04 |
|
PhonyMcRingRing posted:This doesn't do what you think it does. Form.ActiveForm gives you the currently active form in your application. It knows nothing about any outside application. Most of what I find is using C#, and using code that doesn't have an equivalent in vb.net. Of the 3 or 4 examples of on-screen keyboards that were written in vb, they were all for earlier versions of VB and none of them will work now.
|
# ? Aug 28, 2012 22:13 |
|
Anybody an expert in System.Configuration? I have an API which has tons of configurable values. First obstacle was getting ConfigurationManager to open the library's app.config rather than the executing assembly's. Workaround was easy enough, use ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location). Furthermore, I have a custom configuration section: code:
This has previously worked fine in every context. Now, however, I have a consumer that wants to use Powershell to work with the API. For some reason, in the context of Powershell, System.Configuration totally shits itself and can't find the binary with CommonConfiguration: code:
Here's someone else who had the same problem but there's no answer. Anyone encountered this before or have a suggestion? Is there some way to explore exactly where .NET is looking to load the assembly from? I'm having trouble even getting a breakpoint to trigger when I attach to powershell.exe. To clarify, the correct config file is being located just fine, it's locating the assembly which contains my custom configuration class while parsing the config file that is failing. Edit: Problem solved. The issue is that even though the assembly is already loaded, the configuration library still tries to load the assembly a second time in order to bind the configuration. Since the assemblies were manually loaded they're not in the GAC or anywhere else the AppDomain knows where to look, so they don't get found. Since AppDomain.AppendPrivatePath is deprecated, the solution is to add an event handler which returns the executing assembly before your configuration is accessed. Eggnogium fucked around with this message at 00:26 on Aug 29, 2012 |
# ? Aug 28, 2012 23:25 |
|
edmund745 posted:Most of what I find is using C#, and using code that doesn't have an equivalent in vb.net. Of the 3 or 4 examples of on-screen keyboards that were written in vb, they were all for earlier versions of VB and none of them will work now. Almost everything in C# has an equivalent in VB. (the only things which don't are "unsafe" and imports-alias). Post the C# code you're struggling to translate and I'll write out the VB equivalent.
|
# ? Aug 29, 2012 00:54 |
|
ljw1004 posted:Almost everything in C# has an equivalent in VB. (the only things which don't are "unsafe" and imports-alias). Post the C# code you're struggling to translate and I'll write out the VB equivalent. Or he could just use this tool: http://www.developerfusion.com/tools/convert/csharp-to-vb/ It's not perfect but I've had pretty good luck with it.
|
# ? Aug 29, 2012 03:32 |
|
Or tell us what you're actually trying to accomplish, and you may get more help.
|
# ? Aug 29, 2012 05:13 |
|
edmund745 posted:So do you call the method with a timer? I tried that and it doesn't work. In that particular case I invoked the method by creating a new Task from the TPL and put like a second delay in there before it fired. For the record, it's an application that is just OK'ing the box the certificate import wizard gives warning about importing root certificates. SO yeah, it is an different application which is why you have to use the 'ol windows api stuff code:
adaz fucked around with this message at 06:01 on Aug 29, 2012 |
# ? Aug 29, 2012 05:58 |
|
|
# ? May 10, 2024 20:53 |
|
Zhentar posted:Or tell us what you're actually trying to accomplish, and you may get more help. The sendkeys target will be ANOTHER totally-separate application, that I don't know any info on in advance. So it has to find it the way that an on-screen keyboard does--by identifying the previously-active window, of a separate application. ,,,,,,, There is reasons it may not be workable with the target app anyway. I didn't expect it to be so difficult though. When I said there may be "no way to do it", I meant no officially-supported way. While trying to figure out other versions of on-screen keyboards written in c# or C++, frequently there is calls they make that appear to have no VB equivalent (at least none given on the MSDN site). I think I tried three different on-screen keyboards that were written in earlier versions of VB, and none of them will compile/run on vb.net at all. -And of the ones posted online, nobody seems to have written newer ones or updated older ones in a long time. Also I noticed that a lot of the C# and C++ ones go into details about how to prevent the on-screen keyboard from stealing focus, by intercepting mouse messages. None of the (old) VB ones seem to bother with this, so that is another reason I think this isn't supported in VB anymore. Something seems to have changed between then and now... ? One example (discussing focus-stealing and how to prevent it): http://www.yortondotnet.com/2006/11/on-screen-keyboards.html edmund745 fucked around with this message at 13:28 on Aug 29, 2012 |
# ? Aug 29, 2012 13:23 |