Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Alien Arcana
Feb 14, 2012

You're related to soup, Admiral.

Night Shade posted:

This is correct behaviour.

Not handling exceptions - that's how the IAsyncResult pattern works. Your callback is guaranteed to be called, and the End... call will throw whatever exception you need to deal with.
In the case of listener socket shutdown which is what .Stop() does, it throws an ObjectDisposedException as documented on MSDN: http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.endacceptsocket.aspx

All you need to do is:
code:
private void AcceptNewClient(IAsyncResult ar)
{
  Socket inputSocket;
  try
  {
    inputSocket = Listener.EndAcceptSocket(ar);
  }
  catch( ObjectDisposedException )
  {
    return;
  }

  // do stuff with the socket

  BeginListening();
}
You may also want to process SocketExceptions in a few cases.

Belated thank you! That makes sense. I had assumed that an exception meant I was doing something wrong, but if it's the normal state of affairs here that's fine.

Adbot
ADBOT LOVES YOU

edmund745
Jun 5, 2010

Ithaqua posted:

... but there's no reason to not be using VS2012 Express, which does. ...
I tried to install it on my laptop a while back, it "downloaded" for 45 minutes on a cable connection and wasn't doing anything.
Right now I tried the "web instal" on my desktop and it's only 1/3 finished after ~45 minutes.... ??? What did manage to download and install before I cancelled out is all stuff for C++ and SQL. I may try the "CD" icon later I guess.....

Anyway--I made a new project (using the default VB.net location) and added in all the forms from the other one. I had used some lineshapes on one form and it had a bunch of errors about them?? So I commented them out in the designer file, and there is no errors at all now.
But when I run it, the immediates window only says this:
code:
A first chance exception of type 'System.IndexOutOfRangeException' occurred in Clockworks.exe
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
I have global variables and init subs on a module that get called on the main form load, and none of them appear to work now. At all.

I also cannot get breakpoints or messageboxes to work... if I put them in the main form's load event, they don't work anymore?

[edit]...... god dammit.

Nevermind, it works now. :|

I had a module with some global variables, and in the sub that inits them I had moved a loop to set the values to a default value. For some reason that was causing an error that the VB.net IDE would not halt on, or even give any info on. When I just tried running the plain EXE file, the OS gave an error message that says the files and line numbers where it occurred.

edmund745 fucked around with this message at 22:12 on Jun 15, 2013

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

So, what are you using for source control now?

edmund745
Jun 5, 2010

Ithaqua posted:

So, what are you using for source control now?
Nothing, really. I'd seen the bit about the version number thing in VB-Express 2010 but hadn't played with it.

At this point I'm just happy that the newer version (of my program) still works. Because of what I was changing I had to do a large amount of changes before the program could be test-run at all.

---

It is odd that it choked on the Lineshapes though. In all the imported forms that I had used lineshapes in, they were all identified as errors in the form designer file.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

edmund745 posted:

Nothing, really.

You should probably stop what you're doing and set up some source control. Right now. It will literally solve all your problems without you having to do hacky poo poo like what you're trying to do now. It will take less effort than what you're currently trying to do, and will work better. Why are you not using source control?

edmund745
Jun 5, 2010

Jabor posted:

... Why are you not using source control?
I didn't know about it, and didn't have any issues with working off one version until now.

I have an assoc degree in Comp sci that I got back in the year 2002, but never ended up working in the industry or going any farther. A lot of stuff I don't know about because I didn't have to do it in school. plus I learned on VB6... Some things are different now. Some easy things got difficult, and some things that were difficult back then are easy now.

----

Another question: is the exe in the bin\debug folder the same thing as what you get if you publish & install the same program?
More specifically, can the installed exe be copied to another computer and run, or is there anything inside it tying it to its original installed location?
(in this case I am only using the vb express publisher, that put it into { ... user\appdata\local\apps\2.0\ ... } ?)

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

edmund745 posted:

I didn't know about it,

Okay, fine. So why are you not using source control now?

edmund745
Jun 5, 2010

Ithaqua posted:

Okay, fine. So why are you not using source control now?
Because as a hobbyist working alone, the issue of rolling back to previous versions hasn't really been significant.

epswing
Nov 4, 2003

Soiled Meat

edmund745 posted:

the issue of rolling back to previous versions hasn't really been significant, yet

Fixed that for you.

I realize as a lone developer (even a hobbyist), the benefits might not be obvious to you yet, but you've already started copying and renaming entire projects. As you can see, instead of trying to solve your weird project renaming issue, we're pointing out that you wouldn't have the issue in the first place if you were using source control.

I found http://hginit.com a good read when I was jumping into distributed version control. Read that, and it should shed some light on how you can use source control to help you in the long run.

crashdome
Jun 28, 2011
Thanks for that link. I'm an SVN user and also generally a hobbyist that's pretty stubborn about changing and that guide really excited me to try out Mercurial.

To edmund745, don't take things too deeply that you are ALL WRONG. I grew up using arcane ways of doing my own source control prior to SVN and what you are doing is not bad if you are a hobbyist only or just learning. Put it this way: By doing what you are doing now, you are learning why source control was created and why it is better. It's a tool plain and simple. It will make your life way easier though and you'll laugh at the times before you were using it. quick edit: In a nutshell, source control is management of your project versions/files/etc. It isn't magic programming stuff like I used to think. It's just a way to maintain a "working directory" with "copies" or "versions" available to switch between or branch off of. A Visual Studio project likes to be organized and have a home. The moment you start toying with it's home or things inside it's home without it's express permission or supervision you risk making it very angry. By using source control you can keep it's home where it is and it will be comfy. Source control gives you the ability to time travel and the project will never know you are leaping through time and alternate universes totally playing God with it's life. muhahahaha - (obligatory laugh when saying "playing God")

That said, learn the difference between debug builds and production/release builds and why there are the extra files in the debug folder (hint: "build /debug"). Then learn how you can make your own build folders for different purposes even if you will not be doing anything beyond the standard debug or release versions with your projects. Then, learn how publishing in VS is more than just a 'build' (hint: think "packaging" or "distribution") and why it is in the local user apps folder instead of somewhere else. Get this crap out of the way before you start any more projects. Otherwise you'll face the same regret I did.

crashdome fucked around with this message at 04:51 on Jun 17, 2013

Dietrich
Sep 11, 2001

Any time you're working with a project that you aren't planning on deleting immediately, you should be using source control.

Personally, I recommend git.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Dietrich posted:

Any time you're working with a project that you aren't planning on deleting immediately, you should be using source control.

Personally, I recommend git.

I still find Git confusing, and I haven't had a need to get over that hurdle yet. For someone just getting started with source control, something that integrates seamlessly with the IDE might be better.

Git, TFS, SVN, even (*shudder*) CVS or VSS. Any of those are better than nothing.

Dietrich
Sep 11, 2001

Ithaqua posted:

I still find Git confusing, and I haven't had a need to get over that hurdle yet. For someone just getting started with source control, something that integrates seamlessly with the IDE might be better.

Git, TFS, SVN, even (*shudder*) CVS or VSS. Any of those are better than nothing.

VSS is worse than nothing.

edmund745
Jun 5, 2010
GREAT NEWS!! I finally got VS 2012 Express installed. It only took three tries, too. :)
You (may) know how the web installer downloads for a long time, and then it installs [stuff], and then says "reboot to finish installation"? Well when I rebooted, the installer wouldn't start up again. And I couldn't figure out any way to find the file to try restarting it myself. But on the third attempt (at web installing) it skipped downloading all the stuff (unlike the second time, that it spend ~2 hours re-downloading ~700 megs) and it also skipped saying "you need to reboot your sh!t". It just said "installation finished". Also VB Express 2010 is still there, I was kinda afraid it would remove that.

I think when I downloaded VB Express, there was no free version of VisStudio posted at the time. I do recall searching for it, but there was only links to the versions you had to pay for.

VS2012: the 'white look' is too drat white for my monitor, and the 'black look' is better but makes me feel like an extra on "CSI". :| oh well.

Source control, nope. Maybe some other time.

---------

If you are particularly knowledgeable about VB: where should a public variable on a module be initialized? Does it need to be in the main form load() event?
I am using a few globals. Well, more than a few really. Quite an astonishing amount, quite frankly. Yea I know. But anyway. (Mostly) works for me.

I declared them on a module, and then made init subs on the module, and called the init subs in the form load event. This has worked 100% perfectly, up until now.

Out of several hundred global variables, there is (now) ONE that will not init correctly! One f*cking array. One array that is declared in the middle of 100 others, and init'd in the middle of 100 others in the init() sub.... I have verified this issue, by using messageboxes that get the ubounds during runtime.
So, I copied that ONE redim line for that ONE array, and pasted it onto the actual form_load() event,,,,,,, and from there it works perfectly fine.

Should all those init/redim statements be put onto the form load? I can't find anywhere online that says this. Lots of people ask how to make a global in VB, and lots of places give the "public variable on a module" answer, but I can't find anything about where the variable's initialization should be.

Dietrich
Sep 11, 2001

At this point, I'm starting to think you're trolling us. On the off chance that you aren't.

Modules should not be used. Use classes instead.

Global variables should not be used. Ever.

Arrays should only be used if you're never going to resize them. If you need array like access via index/key then consider a dictionary(of int, whatever).

You should be using source control.

This isn't VB6. While you can work with it as though it is, there are much better ways to do things now. You will save yourself time and money, and save the sanity of the person who works on your poo poo after you move on by not trying to treat vb.net as though it is vb6.

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug
edmund745 I'll make the suggestion of stop learning VB.NET. Like Dietrich said you are trying to treat VB.NET like it's VB6, but VB.NET is a whole new beast to work with that has it's own patterns and ways of doing things. I'd suggest re-working your code in C# and learning C#. The different syntax should help your brain from not writing VB6 code in .NET to some degree. Are you using any outside help (tutorials, books, etc) to help pickup .NET programming?

If you want help with you current program try sharing your code someplace so people can see what you mean. All I can tell from your explanation is that your architecture is "wrong" but it's hard to give direction without seeing it. This is another place source control can be useful. Posting it on Github as a public repo can let other people see it.

crashdome
Jun 28, 2011
I take my earlier comment back. Also, drop VB6 from your memory as quickly as you can. Take it from someone who is used to converting VB6 apps to C#. VB6 is old, disgusting, and I wish I never had to see another VB6 source file again. If you are trying to convert an app, you'll have to start ground up. It's the only way to stay sane.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Dietrich posted:

This isn't VB6. While you can work with it as though it is, there are much better ways to do things now.

There were much better ways of doing things in VB6, too. Not as many, not as good, but nonetheless, lots of modules and globals were still bad in VB6. (I've only ever encountered one scenario where globals and modules were outright required, with WinAPI window handler hooks).

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
If you were using version control, it would be trivial to find out which change suddenly made your program stop working.

RICHUNCLEPENNYBAGS
Dec 21, 2010

I've wondered about this for a while. Is this genuinely useable for a real project or is it just a toy? I mostly use C# at work but I have a Mac at home; it'd probably be easier to get myself writing more C# if I had the motivation of being able to use what I'm writing at home.

Dietrich
Sep 11, 2001

RICHUNCLEPENNYBAGS posted:

I've wondered about this for a while. Is this genuinely useable for a real project or is it just a toy? I mostly use C# at work but I have a Mac at home; it'd probably be easier to get myself writing more C# if I had the motivation of being able to use what I'm writing at home.

Oh, it's quite serious.

Stobbit
Mar 9, 2006
I'm using WPF and adding a bunch of controls to a window dynamically using C#.

I've discovered that in Windows 8, ComboBox controls do not render properly. For example, if I set each control's BorderBrush property to Brushes.Red, it works fine in Windows 7 and below (i.e. the controls all have a red border), but in Windows 8, every control except a ComboBox has a red border (for what it's worth, the ComboBox's IsEditable property is true, but that's not a problem for Windows 7 ...).

Has anyone encountered anything like this, or know of a workaround? I found one website that said "Simply extracting the template for the combobox ... WITHOUT making any changes and set it as style fixes the issue on windows8", but whenever I do that, the combobox's template is null. :(

Cat Plus Plus
Apr 8, 2011

:frogc00l:

RICHUNCLEPENNYBAGS posted:

I've wondered about this for a while. Is this genuinely useable for a real project or is it just a toy? I mostly use C# at work but I have a Mac at home; it'd probably be easier to get myself writing more C# if I had the motivation of being able to use what I'm writing at home.

It implements nearly all of .NET 4, with most noticeable missing feature being WPF. http://www.mono-project.com/Compatibility

wwb
Aug 17, 2004

RICHUNCLEPENNYBAGS posted:

I've wondered about this for a while. Is this genuinely useable for a real project or is it just a toy? I mostly use C# at work but I have a Mac at home; it'd probably be easier to get myself writing more C# if I had the motivation of being able to use what I'm writing at home.

To pile on here -- very much so yes. Especially in mobile, Miguel and his guys have done an awesome job of building native quality tools in much cleaner languages without having any of the horrors of other wrappers. They are writing some games using monotouch -- and games are typically the last thing you see in emulators.

Dirk Pitt
Sep 14, 2007

haha yes, this feels good

Toilet Rascal

RICHUNCLEPENNYBAGS posted:

I've wondered about this for a while. Is this genuinely useable for a real project or is it just a toy? I mostly use C# at work but I have a Mac at home; it'd probably be easier to get myself writing more C# if I had the motivation of being able to use what I'm writing at home.

I have followed Miguel de Icaza ever since he was on This Developer's Life and I enjoy his work. His latest project, xamarin, is quite useful. I am writing an iOS and Android app on my MacBook Air using c# for my church, and already have offers for contract work when I finish this rinky dink church app.

This video made me smile, c# really is a satisfying language to use:

http://xamarin.com/evolve/2013#session-umfpnw90c9

Dirk Pitt fucked around with this message at 14:37 on Jun 18, 2013

Sab669
Sep 24, 2009

I have a method that iterates over the controls within a group box and does a particular function based on the control's type (ie combobox / textbox). However, some of the textboxes represent a range of data. I don't want to have to hardcode the method to do something like this;

code:
if (c.Name == 'txtCostLower') {do something}
I was wondering if there's some way to incorporate a SQL "like" feature so I could do something more along the lines of
code:
if (c.Name like '%Lower') { do something}
There's a number of textboxes I'd specifically have to check for, I'd really rather not have to specifically list every option.

I found this Like operator on the MSDN, but it doesn't seem to exist in my application's .NET version :saddowns:

edit; I suppose I could use some sort of LastIndexOf witchery to see if Upper/Lower is part of the control name?

Sab669 fucked around with this message at 16:45 on Jun 18, 2013

ether
May 20, 2001

Sab669 posted:

I have a method that iterates over the controls within a group box and does a particular function based on the control's type (ie combobox / textbox). However, some of the textboxes represent a range of data. I don't want to have to hardcode the method to do something like this;

code:
if (c.Name == 'txtCostLower') {do something}
I was wondering if there's some way to incorporate a SQL "like" feature so I could do something more along the lines of
code:
if (c.Name like '%Lower') { do something}
There's a number of textboxes I'd specifically have to check for, I'd really rather not have to specifically list every option.

I found this Like operator on the MSDN, but it doesn't seem to exist in my application's .NET version :saddowns:

if (c.Name.EndsWith('Lower')) or even .Contains('Lower') is probably your best bet. (C#, but guessing the VB string class has similar functionality)

Not the fanciest design though, I'ld probably pick a less arcane way and errorprone way to do stuff like this (like a Dictionary<Control,Action> mapping and iterate across that)

Sab669
Sep 24, 2009

Well that's embarassing, I forgot Contains even exists :doh: I don't use it much. Definitely not the cleanest though, as you said.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
I'd make an IActionable interface and set each Actionable control's action when it's initialized. Then I can just get all of my IActionables and run their actions.

off the top of my head:
code:
    public interface IActionable
    {
        Action Action { get; set; }
    }

    public class ActionableTextBox : TextBox, IActionable
    {
        public Action Action { get; set; }
    }

    public class ActionableComboBox : ComboBox, IActionable
    {
        public Action Action { get; set; }
    }
code:
var actionableControls = groupBox1.Controls.OfType<IActionable>().Where(a=>a.Action != null);
foreach (var actionableControl in actionableControls)
{
     actionableControl.Action();
}

New Yorp New Yorp fucked around with this message at 17:30 on Jun 18, 2013

JawnV6
Jul 4, 2004

So hot ...
I did something similar with a SetFloat Delegate and a Dictionary<TextBox, SetFloat> dict. Common controls for all the TextBoxes, but if any of them need their own specific handler that doesn't match the Delegate template it's more clunky code to check for particulars like you noted.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

Cat Plus Plus posted:

It implements nearly all of .NET 4, with most noticeable missing feature being WPF. http://www.mono-project.com/Compatibility

It's missing a bunch of WCF parts as well though that's rapidly becoming a moot point with Web API being the new MS thing. I've also found MonoDevelop/Xamarin Studio to be pretty rough around the edges but there's basically nothing in the IDE universe that compares to VS so that's not particularly surprising. Given your alternative on OS X is Xcode and Objective-C/C/C++ it's certainly not a bad way to go.

Their strengths are really in cross-platform and mobile and that's where most of their attention lies. I've found it to be just an ok replacement for the complete Windows .NET toolchain regarding desktop or web services.

Dr Monkeysee fucked around with this message at 19:41 on Jun 18, 2013

raminasi
Jan 25, 2005

a last drink with no ice
Can someone point me to a good guide on using a Canvas to actually do useful things? Every trivial little introduction I can find pretty much just shows how to use static XAML to draw stick figures having sex, but I want my Canvas content to actually depend on real things. I guess this means I need to data-bind it to something? But what! And how!

Pseudo-God
Mar 13, 2006

I just love oranges!
Is there any way you can override the mouse click event in Windows? I want to make an app that will sit in the taskbar and give me the coordinate of the current location of the mouse cursor when clicked, but without activating whatever is beneath the cursor. I suppose if this is not possible, I could make a full screen transparent app that will sit on top of every other window, and will prevent clicks from going through.

Sedro
Dec 31, 2008

Pseudo-God posted:

Is there any way you can override the mouse click event in Windows? I want to make an app that will sit in the taskbar and give me the coordinate of the current location of the mouse cursor when clicked, but without activating whatever is beneath the cursor. I suppose if this is not possible, I could make a full screen transparent app that will sit on top of every other window, and will prevent clicks from going through.
You should be able to do that easily with a low-level mouse hook.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Longshot question: I'm transitioning some folks from VS2005 (!!!) web deployment projects (.wdproj) to VS2012 publishing profiles. Anyone ever integrate publishing profiles with MSBuild before?

Dietrich
Sep 11, 2001

This is how we do it in team city.

/p:VisualStudioVersion=11.0
/p:Configuration=Test
/p:OutputPath=bin
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceURL=https://{WEBSITE ADDRESS}/msdeploy.axd
/p:username={SOME ACCOUNT NAME HERE}
/p:password={SOME PASSWORD HERE}
/p:AllowUntrustedCertificate=True
/p:DeployIisAppPath={IIS APP NAME}
/p:MSDeployPublishMethod=WMSVC

glompix
Jan 19, 2004

propane grill-pilled
Does anyone know of a good, dead-simple replacement for Crystal Reports or SQL Server Reporting Services to service a web farm hosting an MVC app? We need to generate PDF and Excel files for invoices, faxes and so on. We're using Crystal Reports for VS2008 (only 2 !!s, but still lol) right now and only one person on our team knows how to use it and hates it, (not me) so that's out.

I remember a surface level discussion in this thread and liking the idea of writing HTML to generate reports. I'm not sure how to get that to various formats though. Parameterization is another problem I figure is already solved as well. Any tool suggestions?

Dietrich
Sep 11, 2001

There are many .net PDF creation libraries (PDFSharp, ITextSharp) which will take html and turn it into a PDF. I would recommend that approach for the PDF reports.

Excel is kinda a different question, do you want .xls or .xlsx? Most of the libs I've found support either one or the other, but not both. I've had good experiences with MyXls.SL2 for .xls documents.

Ochowie
Nov 9, 2007

Dietrich posted:

There are many .net PDF creation libraries (PDFSharp, ITextSharp) which will take html and turn it into a PDF. I would recommend that approach for the PDF reports.

Excel is kinda a different question, do you want .xls or .xlsx? Most of the libs I've found support either one or the other, but not both. I've had good experiences with MyXls.SL2 for .xls documents.

Any experience with .xlsx? Is there any reason to use it aside from specifically targeting newer version of Excel?

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004

Dear god yes.

The excel file format is a nightmare at best -- see this blog post for some details*. From a managed code point of view you are looking at either expensive libraries or using some nightmare of Excel running on your web server to generate files.

XSLX is a more modern format in many ways. From a managed code perspective the key feature is that .XSLX, like all the ???x office formats, is just a zipped set of XML files and assets which means they are easily accessible from purely managed code without a need for 3rd party extensions or running client apps on your server. At this point they have been out since 2007 so just about everyone either has upgraded office or at least installed the compatibility pack so they can read the formats.

* I would typically never endorse anything Splosky wrote, but this happens to be one of the few good blog posts in the sea of poo he has written. I'll add he might well be partially responsible for the nightmare of the file formats as he was PM of Excel in 1991 or so.

  • Locked thread