|
Why do you say you cannot debug through your code?
I think you could use
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message + " " + ex.StackTrace);
}
|
|
|
|
|
I'm sorry, I meant I cannot step thru my code to see where my problem is at. Reason is this is socket app that requires a secured connection and that is on a network on the east coast.....I'm in the midwest.
Currently I am do the try and catch but putting it to a message box instead of the Trace function. I'll try that and see what the results are.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
When you use Trace you can have the code running without pressing the OK of the MessageBox and writing down the message on a piece of paper, while all the messages are going to be written in the Output window, so I would say it's more convenient.
I hope it helps.
Cheers
|
|
|
|
|
It is the most arduous but it really works when it has too.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Hi. I'm very new to Visual C#. I was wondering if someone could help me print the contents of a pictureBox.
I would like to be able to print just the image and be able to control the size of the image as well as the location of the image on the page.
Please help if you can.
|
|
|
|
|
Actually there are some very helpful tutorials on how to print bitmaps in C# available by searching google.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
...
PrintDocument printDoc = new PrintDocument();
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
printDoc.Print();
...
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
PictureBox picBox = new PictureBox();
picBox.Image = Image.FromFile(@"c:\mypic.jpg");
e.Graphics.DrawImage(picBox.Image, 5, 5);
}
|
|
|
|
|
Hello. I have the following function:
<br />
public BaseClass SpawnClass( ObjectType type )<br />
{<br />
BaseClass retval = null;<br />
<br />
float X = 5;<br />
float scale = 0.3429f;<br />
<br />
switch(type)<br />
{<br />
case ObjectType.Class1:<br />
{<br />
retval = new Class1(X,scale);<br />
break;<br />
}<br />
<br />
case ObjectType.Class2:<br />
{<br />
retval = new Class2(X,scale);<br />
break;<br />
}<br />
<br />
case ObjectType.Class3:<br />
{<br />
retval = new Class3(X,scale);<br />
break;<br />
}<br />
}<br />
<br />
return retval;<br />
}<br />
I have about 11 classes but I didn't want this to get too long. This works, but it's very ugly. Is there a better way to do this? I've thought about the "Gang of Four" design patterns, but I'm not sure if they would be less ugly. I noticed the TypeConverter class, but I don't know how to use it. Any suggestions?
I love to program!
|
|
|
|
|
Assuming the constructors are identical, I'd probably do something like:
public BaseClass SpawnClass(System.Type type)
{
float X = 5;
float scale = 0.3429f;
return (BaseClass) type.InvokeMember(type.FullName, System.Reflection.BindingFlags.CreateInstance, null, null, new object[] {X, scale});
}
That should work from what I remember, but it may need some tweaks to be work correctly.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
That function looks like it depends on System.type, however the function I have depends on a custom enumeration (ObjectType). Would this way still work? Would there be a way to create a type using a string?
I love to program!
|
|
|
|
|
allenmpcx wrote: Would there be a way to create a type using a string?
Activator.CreateInstance
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
nevermind on that. Your method worked perfect because I can call Type.GetType() and pass in a string to get the type, so thats exactly what I did. Thanks a lot.
I love to program!
|
|
|
|
|
Hey guyz! I have a question how do I change in C# a number from such B8B80C00 byte-ordering into such one: 000CB8B8
Any help would be appreciated..
Regards,
Pawel
-- modified at 14:24 Wednesday 2nd August, 2006
|
|
|
|
|
Try spelling it right. its "endian," referring to the end of the significant bit. A quick google search should do you just fine.
-- modified at 14:19 Wednesday 2nd August, 2006
|
|
|
|
|
"Mmmmmm. Juicy Fruit."
-- Big indian (Chief Bromden)
---
b { font-weight: normal; }
|
|
|
|
|
The IPAddress class provides methods with that functionality for several types.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
ok guyz thx for the answer I found on google what I was looking for.. before that I couldnt find because I spelt it incorrect ;] thx for help anyway
|
|
|
|
|
<br />
string str = "000CB8B8"; <br />
<br />
char[] ch=str.ToCharArray();<br />
<br />
string strev = "";<br />
for (int i = (ch.Length-1); i >= 0; i--)<br />
{<br />
strev += ch[i].ToString();<br />
}<br />
reversed string will be on strev<br />
|
|
|
|
|
Reversing the nibbles won't correctly change the endianess of the number. You have to reverse the bytes:
string number = "000CB8B8";
string swapped = string.Empty;
for (int i = number.Length - 2; i >= 0; i -= 2) {
swapped += number.Substring(i, 2);
}
---
b { font-weight: normal; }
|
|
|
|
|
I am looking for suggestions/pros/cons of using typed datasets vs. custom classes for my DAL/BLL.
Anyone have any thoughts on eXpress Persistance Objects from DevExpress or dOOdads from MyGeneration software?
Any other solutions?
|
|
|
|
|
Use both! Make the typed Datasets the DAL and some classes the BLL. Your presentation layer then makes calls to the BLL wich in turn makes a call to the typed datasets.
If you use the System.ComponentModel.DataObject and System.ComponentModel.DataObjectMethodAttribute attributes in your BLL then you can even use your classes as datasources for gridviews et al.
I do it this way because the database people make me do things I don't like to do, like a switch in the database has to be a char(1) with 'Y' or 'N' in it instead of a bit field, so I use the BLL to abstract it so I can just use bools in my code.
private char isActive;
public bool IsActive
{
get { return this.isActive == 'Y' ? true : false; }
set { this.isActive = value ? 'Y' : 'N'; }
}
|
|
|
|
|
I am looking to create an Data Access Layer and Business Logic Layer for a new web site. I am looking for suggestions on the best practice on how to handle the database connection from the DAL.
I have seen examples where every function in the DAL creates a connection, runs the query, and then closes the connection based on the connection string passed into the DAL. With connection pooling this doesnt seem to be a big issue. Is this the best method for a web application since it is stateless? Or, is it better for the BLL to create a connection and pass the connection into the DAL? How is the best way to get the connection string from the Web.config file to the DAL? Does the BLL pass the connection string into the DAL or is there a better way?
I am looking at using ASP 2.0 but I didnt want to use the table adapter wizard.
Any examples would be greatly appreciated.
|
|
|
|
|
All I can say is what I do... I keep ALL connection/database/sql out of the BLL. This way if my application moves to a different database all I have to do is rewrite the DAL and the rest of your application works fine. I also only use the presentation layer to do presentation; the BLL is what messes with the data.
|
|
|
|
|
Do you have each function in the DAL also handle the connection?
How do you recommend the best way to have the DAL get the connection string?
|
|
|
|
|
Recently I've been using typed datasets, I think they open a connection each time. In my older projects I did open a connection for each request. However, my apps are internal workflow applications though, so they are not serving 100,000 hits /sec or anything :p
I put the connection string in app.config.
|
|
|
|