|
No you are right, "idiots" was a little over the top.
The idiots were the designers who thought it would be a good idea in the first place! I had no problem with On Error Goto , it was the inclusion of resume next as a specific way to ignore any problem which did occur which got my back up.
Having been raised with FORTRAN compilers which had a default On Error Resume Next in that they did no error checking whatsoever (and would allow you to declare a character variable and use it as a four dimensional array of floats) I saw what damage a lack of error checking can do. It was a retrograde step to allow novices in particular to easily disable error checking with a single line of code.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
No problem.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Couldn't you have used on error goto instead?
|
|
|
|
|
eg_Anubhava wrote: As you know In vb.net or vb6 the On Error Resume Next is use to error handling
Just a tip: that was not "error handling"; that was "error swallowing". Error handling was achieved with "On Error Goto"
|
|
|
|
|
If you can narrow down the affected code to a line or two, then the following VB code:
On Error Resume Next
Foo()
can be converted to:
try
{
Foo();
}
catch
{
}
For longer code blocks, you'll have to use a separate try/empty catch for each single line of code.
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
modified on Tuesday, January 18, 2011 4:42 PM
|
|
|
|
|
Hey there,
I've created a component which renders a menu onto the form it's attached to. However, whenever I place controls in the region where the extension is (i'm extending the glass non-client area using the DWM API methods), it causes the designer to crash and the application itself crashes.
Naturally, I need to be able to adjust the boundaries of where controls can be placed at design and run-time. I've considered using the non-client area API methods to increase the height of the caption at design-time, but I was wondering if there's an alternate way of doing this? I've also considering changing the form's padding to suit the height of the glass extension, but this would be modifiable at design time by the user.
Thank you.
|
|
|
|
|
So here is my dilemma, rather then describe it I will show you it.
Let say we take back a certain amount of records records from the DB Called Inventory Count and they have a corresponding number attached to them indicating if they are an opening Count (1) or a closing count (2)
Date-Product-Quantity-Opening/Closing
1. 1/1/2010, Ice Cream Cones, 10, 1
2. 1/1/2010, Bananas, 8, 1
3. 1/1/2010, Chocolate Bars, 9, 1
4. 2/1/2010, Ice Cream Cones, 5, 2
5. 2/1/2010, Bananas, 4, 2
6. 2/1/2010, Chocolate Bars, 3, 2
7. 4/1/2010, Ice Cream Cones, 12, 1
8. 4/1/2010, Bananas, 8, 1
9. 4/1/2010, Chocolate Bars, 9, 1
10. 5/1/2010, Ice Cream Cones, 1, 2
11. 5/1/2010, Bananas, 2, 2
12. 5/1/2010, Chocolate Bars, 3, 2
I need to build a dictionary that will take the first group (Openings = 1) and do the subtraction of quantity for closing(Closing 2), This will make up Session 1, Session 2 will be the next corresponding groups of Opening = 1 - Closing = 2
Thanks for the help in advance, hopefully this is understandable
|
|
|
|
|
Ive used sorteddictionary to now group the different dates.. <datetime, object="">
|
|
|
|
|
You say that you want to build a dictionary. Are you under instruction to use a Dictionary? It seems, from what you have posted that this should all be done in the database.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
This is for generic usb devices (3 of same usb devices)
I'm not sure if it is possible to do this scenario...
With all 3 usb devices are on and loaded in the application...
When device B is disconnected, the device B handle/instance is disposed.
When device B comes back on (reconnected), the system detects device B (using the wndproc messaging), the handle/instance) is being established, without changing the intptr handle of the device A & C.
Is this possible?
Right now, when the application detects Device B is reconnected and powered up, the application re-scan all of usb devices (and filters out specific Product ID & Vendor ID), all of 3 devices gets new handle/instance.
|
|
|
|
|
I'd guess (a wild guess) that the handle for A and C wouldn't change if it's being used when B is disconnected/reconnected.
(maybe google how multiple USB TV-tuners keep using the ones that arent dis-/re-connected)
|
|
|
|
|
|
I'm using Compact Framework 3.5 on a phone to contact a WCF-service, but I think my question is more related to this message board.
When the code below is called a second time, from a class that is implemented as a singleton, it ends in som really unexpected errors.
It works fine the first time it's run.
MaintenanceService svc = new MaintenanceService();
List<Assignment> assignments = svc.GetAssignments().ToList<Assignment>;
The second time, it randomly throws 2 different exceptions (only one each time):
- Sometimes it's a TimeOutException
(System.Net.HttpWebRequest... - in VS-generated code).
- And Other times it's a ObjectDisposedException
(system.threading.timer for the WCF-TimeOut - in VS-generated code).
If I use the same code from a Button_Click in a Form, it works every time, so I know it's not the service that are causing the error.
I really need som help on this one?
|
|
|
|
|
Michael9000 wrote: from a class that is implemented as a singleton, Is it your intent to reuse an existing client proxy?
/ravi
|
|
|
|
|
Not necessarily.
I'm using a static Maintenance-class (where the previously posted code is called from a static method), because it has to make the same list of objects available throughout the entire app (Gui+Backend).
Edit: svc.dispose don't make any difference after the code in opening-post.
(Performance doesn't really matter - time does (my deadline is in approximately 48 hours).)
Any ideas are welcome. I'm stuck (I'm probably thinking about this i a wrong way) ?
|
|
|
|
|
OK, I was just concerned you were reusing a cached client proxy. I tried the same thing a while ago (in the interests of not having to recreate the proxy) and ended up getting burned by (a) disposed objects and (b) the channel being in a faulted state if an uncaught exception occured on the server.
Can you confirm that your static class is in fact using (or serving up) a new instance of the proxy every time it's used?
/ravi
|
|
|
|
|
What you described is exactly whay I'm getting (a and b).
Not entirely sure what you mean, but I create a new for each call
public static class
{
public static List<Assignment> Test()
{
MaintenanceService svc = new MaintenanceService();
List<Assignment> assignments = svc.GetAssignments().ToList<Assignment>;
svc.Dispose();
return assignments;
}
}
|
|
|
|
|
Does this help?
public static List<Assignment> Test()
{
MaintenanceService svc = new MaintenanceService();
svc.InnerChannel.OperationTimeout = new TimeSpan (1, 0, 0);
List<Assignment> ret = svc.GetAssignments().ToList<Assignment>();
Debug.Assert (ret != null);
List<Assignment> assignments = new List<Assignment>();
foreach (Assignment a in ret) {
assignments.Add (a);
}
return assignments;
}
/ravi
|
|
|
|
|
Did you just read my offline code or my mind!? That's 99,9% the original code except 'svc.innerC...' and my out-commented 'Debug.' Now that's thougths that I like
It's getting a little late in the evening here, so I'll have to try it tomorrow morning.
But it seems you like you know the "little thing" I need to change
|
|
|
|
|
Thanks. I couldn't find InnerChanel on the svc, so I'll see if I can find another way around it.
|
|
|
|
|
Crap - I forgot you're using the CF. The property may be missing for that version of .NET.
/ravi
|
|
|
|
|
Some more thoughts:
- Have you tried setting the timeout of the client proxy (at run-time) to a comfortably high value?
- Is there an uncaught exception occuring on the service end?
- Is the returned list guaranteed to be not-
null ?
/ravi
|
|
|
|
|
You think like me , that was som of the first things I tried - without success.
Ravi Bhavnani wrote: Have you tried setting the timeout of the client proxy (at run-time) to a comfortably high value?
Yes, tried that as the first thing. Changed timeout to 180 seconds (server responds in less than 4 seconds).
Ravi Bhavnani wrote: Is there an uncaught exception occuring on the service end?
Not likely. The server always responds with, at least, a empty List within 4 seconds.
(same for another test-method that simply takes a string and returns the same string).
Ravi Bhavnani wrote: Is the returned list guaranteed to be not-null?
Yes. (at minimum it's a empty List of objects).
modified on Monday, January 17, 2011 6:54 PM
|
|
|
|
|
I am researching a job position and was curious if anyone deals with Dynamics GP on the regular? I am basically wondering if this is a new language that I will have to learn or can I utilize C# and/or vb.net to work with it? I viewed a project that was created in this a few months ago and looked like really ugly code.
I am weighing the pro's and con's of this and deciding if it would be worth leaving a job using c#/vb.net to go exclusively to developing GP. Is it a great pain or nice to work with? Can you use c# or vb to code or do I have to use the ugly code I viewed sometime ago?
Thanks,
|
|
|
|
|
Thanks, but I finally figured it out.
I am fairly new to VB.net but I am getting by. I am almost clueless about C# though. I have managed to find a C# function that does what I need
and have converted it with the online code converter. It runs in VB and works but two of the four calculations are not working. (I had hoped to get it
working in C# to test the formulas.) It takes a string (a mapping Tile Quadkey, 02311102221333130 for example) and calculates the bounding box for that
map tile(Lat/Lon) corner positions coordinates of the four corners). The calculated values W (West Longitude) N (North Latitude) E (East Longitude) and
S (South Latitude). I have set up a new C# project, a console app. I have used the code at bottom and created a new class in that program. On the form Program.cs
I don't have a clue about how to make use of that class. The test value would be Quadkey = "02311102221333130"
It appears that it returns a string of the array bounds, values separated by commas.
If someone wanted to convert this to working VB.net that would really great, but I hardly expect that.
The corrected, working calling procedure. I guess that I knew even less than I thought.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
WMSHandler outCl = new WMSHandler();
double N = 0;
string MyString = outCl.QuadKeyToBBox("02311102221333130");
Console.WriteLine(MyString);
Console.ReadLine();
}
}
}
But that is not working. Any help would be appreciated.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
using System;
using System.Math;
using System.IO;
public class WMSHandler
{
public const int TILE_HEIGHT = 256, TILE_WIDTH = 256;
public string QuadKeyToBBox(string quadKey)
{
int zoom = quadKey.Length;
int x = 0, y = 0;
for (int i = zoom; i > 0; i--)
{
int mask = 1 << (i - 1);
switch (quadKey[zoom - i])
{
case '0':
break;
case '1':
x |= mask;
break;
case '2':
y |= mask;
break;
case '3':
x |= mask;
y |= mask;
break;
default:
throw new ArgumentException("Invalid QuadKey digit sequence.");
}
}
double W = (float)(x * TILE_WIDTH) * 360 / (float)(TILE_WIDTH * Math.Pow(2, zoom)) - 180;
double N = (float)Math.Asin((Math.Exp((0.5 - (y * TILE_HEIGHT) / (TILE_HEIGHT) / Math.Pow(2, zoom)) * 4 * Math.PI) - 1) / (Math.Exp((0.5 - (y * TILE_HEIGHT) / 256 / Math.Pow(2, zoom)) * 4 * Math.PI) + 1)) * 180 / (float)Math.PI;
double E = (float)((x + 1) * TILE_WIDTH) * 360 / (float)(TILE_WIDTH * Math.Pow(2, zoom)) - 180;
double S = (float)Math.Asin((Math.Exp((0.5 - ((y + 1) * TILE_HEIGHT) / (TILE_HEIGHT) / Math.Pow(2, zoom)) * 4 * Math.PI) - 1) / (Math.Exp((0.5 - ((y + 1) * TILE_HEIGHT) / 256 / Math.Pow(2, zoom)) * 4 * Math.PI) + 1)) * 180 / (float)Math.PI;
double[] bounds = new double[] { W, S, E, N };
return string.Join(",", Array.ConvertAll(bounds, s => s.ToString()));
}
}
}
modified on Monday, January 17, 2011 11:18 AM
|
|
|
|
|