|
Thank you and if you can , please give some idea about the same
|
|
|
|
|
Hi
i paste a png image folder in soloution explorer.now how can i give path.
This time my png path is
btn_select_folder.BackgroundImage=System.Drawing.Image.FromFile(Application.StartupPath+@"\dbxpngs\001.png");
pashant
|
|
|
|
|
put directly it into bin\debug
while publishing make sure you put/include those it in the application folder
and for bin \ debug files you do not need to refer for a path
btn_select_folder.BackgroundImage=System.Drawing.Image.FromFile("001.png");<br />
|
|
|
|
|
i would add it as a resource
|
|
|
|
|
but the size of resourse file may dumpen the performance
if the image is small better use it as resource object
but on ther other hand if it is large it may cause performance issue
because it will consume ram even when it is not in use
|
|
|
|
|
Hey!
I have looked allover the internet after a way to do unit testing against a database with rollback as easy and flexible as possible.
I found this article:
http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/[^]
(http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/default.aspx?loc=&fig=true#fig5[^])
And I have tried to do the exact thing that roy Osherove shows.
I have two projects(dbContextTest(class library) and dbContextTest_Test(Test project))
The following class are placed within the dbContextTest class and is that class that I want to test:
public class userHandler<br />
{<br />
private databaseHandler dbHandler = new databaseHandler();<br />
<br />
public bool createUser(string inFirstName, string inLastName)<br />
{<br />
try<br />
{<br />
if(dbHandler.createUser(inFirstName, inLastName) > 0)<br />
return true;<br />
<br />
return false;<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine("Error in " + this.ToString() + ".createUser : " + ex.Message);<br />
return false;<br />
}<br />
}<br />
}
As you can see, I am here contacting the DAL(Database handler(dbHandler)) to add a user to the database.
In my test project I have a userTest class where I have my test methods:
[ClassInitialize()]<br />
public static void MyClassInitialize(TestContext testContext)<br />
{<br />
ServiceConfig config = new ServiceConfig();<br />
config.Transaction = TransactionOption.RequiresNew;<br />
ServiceDomain.Enter(config);<br />
}<br />
<br />
[ClassCleanup()]<br />
public static void MyClassCleanup()<br />
{<br />
if (ContextUtil.IsInTransaction)<br />
ContextUtil.SetAbort();<br />
<br />
ServiceDomain.Leave();<br />
}<br />
<br />
[TestMethod()]<br />
public void createUser()<br />
{<br />
string firstName = "Olle";<br />
string lastName = "Svensson";<br />
<br />
userHandler tmpUSHandler = userFactory();<br />
<br />
Assert.AreEqual(tmpUSHandler.createUser(firstName, lastName),true,"User not created");<br />
}<br />
<br />
private userHandler userFactory()<br />
{<br />
return new userHandler();<br />
}
I am here trying to make the userHandler class work with in a serten context that I have the possiblility to rollback.
I know that there is nothing wrong with my TestMethod.
When the SqlConnection.open is executed in the DAL I get the following exception:
Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool.
What am I doing wrong? And is this the way to solve the problem?
|
|
|
|
|
when a create a mdi child and open it, i found it behind the controls in the parent form
is there anyway to bring it in the fornt
|
|
|
|
|
No. Or atleast I do not think so. In MDI application you should not place controls in the client area of the main application form. If you do, then you will need to hide and show them as and when you have an MDI form open or not.
|
|
|
|
|
thanks i think that mean i should place all controls in client erea in the main form in another mdi form
|
|
|
|
|
you better dock the control on mdi
and for sending it back
right click the control and use send to back
if control is independent else do same for its container you can also do it in code
|
|
|
|
|
I have a program that needs to connect with another program developed by somebody else that currently will run on the same computer (by later that might change). The connection is being done using TCP/IP and the TcpClient class (on my side). The problem is that the other guy has his program rather rudely close every connection after receiving only one TCP/IP message and this is really annoying me.
Does anybody have a feel for what the additional overhead is with having to reconnect every damn time versus having a connection that will stay open until my app quits? We'll need to send messages probably only every few seconds (maybe every 5 seconds tops), but I want the response when the message is sent to be as quick as possible.
Thanks.
|
|
|
|
|
Creating a connection is causing the overhead of having a three-way handshake. So basically, if you don't close and re-open the connection you will not have this overhead.
I don't know if you use an IP-address to connect or a DNS name, if you're using DNS, this is causing more overhead too, because you have to query for the IP-address too.
You're right when you are saying that it is annoying having to reconnect, plus it costs more time and memory to reconnect at every request.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi,
I would like to add some shortcuts to my application in which multiple keys can be pressed to do some action or another. This wors fine for single button or ctrl/alt/shift combinations, but how can I handle other keys, like a combination of 'A' and 'Y' for example? Do I have to keep track of this manually in the key up / key down events? I'd expect there's some convenient way of handling this, but can't seem to find any info on this on msdn or google...
Cheers,
Benny
|
|
|
|
|
i was trying to change the tempo of a midi file while playing
but was unable to find a way
can you help
thanks
|
|
|
|
|
Hello
I´ve got a string and i would like to convert into an int but the problem is that when i don´t have an int an exception is throw (FormatException). How can i catch this expceion? The try{catch(Exception e) doen´t work.
I use System.Convert.ToInt32(string).
Thank you in advance,
Borja Riesgo Juan
|
|
|
|
|
Hello,
Try catch should work in this case, but is not recommended.
Instead you should use the int.Parse Method.
All the best,
Martin
|
|
|
|
|
Martin# wrote: Instead you should use the int.Parse Method.
I think that you mean the int.TryParse method, as the int.Parse method doesn't offer anything over Convert.ToInt32.
For framework 1.x you use double.TryParse with NumberStyles.Integer and then cast the value to int.
---
b { font-weight: normal; }
|
|
|
|
|
Hello Guffa,
Thank you for your info.
I normaly work with double.TryParse(), but I never tried the NumberStyles.Integer.
So I guess you would also recommend using double.TryParse plus cast to int, instead of try catch with Convert.ToInt32.
So I think I'm going to change some of my code.
So once again thanks for your help.
All the best,
Martin
|
|
|
|
|
Martin# wrote: So I guess you would also recommend using double.TryParse plus cast to int, instead of try catch with Convert.ToInt32.
Yes. Exceptions are mainly for unexpected situations. If you expect something to happen, you should try to stop it before it happens.
Another alternative is to use a regular expression to validate the string before you convert it. If you have verified that a string only contains digits and not more than fits in the range of an int, you can safely convert it to an int.
---
b { font-weight: normal; }
|
|
|
|
|
hi
can i use C++ program function in c#.Net2003 application
Thanks
|
|
|
|
|
do u want to run it from C# or embeded it in the application
|
|
|
|
|
hi,
thanks for reply
i have one program that contains some functions,
i want to use that function in my c#.net2003
it's is possible or not
plz give suggestion
or send any help full links for that .
u know how top write serialport programming in C#.net2003 and framework 1.1
using win32 API's
plz send sample code for that
Thanks
|
|
|
|
|
Hi, why doesn't my code work? I have two forms in my windows application, I want the user to click on a button called btnCustomize and the other form (called frmCustomize) to open. The first form is called reminder.
Here is the code that I have tried :
private void btnCustomize_Click(object sender, EventArgs e)
{
frmCustomize.Show();
}
I have also tried variations on this like .ShowDialog(); and such.
Can you help?
|
|
|
|
|
Wolf92 wrote: why doesn't my code work?
What exactly does that mean? Are you getting any exceptions?
Did you eventually forget to create an instance of the form and assign it to the frmCustomize field.
"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
|
|
|
|
|
I think I am typing in the wrong code? I want that when the user clicks 'btnCustomize' the form 'frmCustomize' displays.
What is the code for this?
This is the error message I get when I type in :
private void btnCustomize_Click(object sender, EventArgs e)
{
frmCustomize.Show();
}
It says :
Error 1 An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()' D:\Documents and Settings\Sophie\My Documents\Programming\Programs\C#\Reminder\Reminder\reminder.cs 66 13 Reminder
|
|
|
|