|
Hi All,
Greetings. When I am tring to send mails from my domain using System.Web.Mail.
System.Web.HttpException: The transport failed to connect to the server. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040213): The transport failed to connect to the server. --- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at _Default.Button1_Click(Object sender, EventArgs e)
This is the error I am getting. Please help me on this issue. Thanks in advance...
JIJO BABY - Lets Play C#
|
|
|
|
|
|
|
|
My program uses multiple threads to do something, and i want to make a progress bar to show the process status, the problem is that i can't update the progressbar from the thread (gives an exception..not the thread it was created on).
what can i do?
|
|
|
|
|
Use the standard technique (InvokeRequired/Invoke) explained over and over in CP articles;
both of my articles contain a simple example.
|
|
|
|
|
Uhh...well...I read a bit and it seems to be really confusing...a small simplified example would be nice :\
|
|
|
|
|
Hi, the last code snippet in my Sokoban article shows the simplest example possible:
executing a method with one argument on the UI thread (it is an excerpt from file
MainForm.cs)
|
|
|
|
|
Uhh...i don't get it (especially cause I'm not very familiar with delegates...so can you explain what this does:
Invoke(new MovePaster(pasteOneMove), new object[]{c});
You send a function into a delegate? but the function is void and has a char as a parameter (And so does the delegate)...so...uhh...I'm confused :\
|
|
|
|
|
Hi, whenever you create a Win app in .NET you use delegates; how else would you connect
an event handler (e.g. myButton_Click) to the corresponding event ?
When you write
myButton.Click+=new EVentHandler(myButton_Click);
you pass a method to the handler's constructor; this does not call myButton_Click,
it tells the button that when clicked it will have to run myButton_Click for this object.
This is fundamental to .NET, whether using C# or not.
Invoke is similar, the line
Invoke(new MovePaster(pasteOneMove), new object[]{c});
will cause the execution of the specified method (with specified argument list), so it
logically corresponds to a simple pasteOneMove(c);
but it does not execute the method on the calling thread, it sends a message to the
message pump and that message causes pasteOneMove(c); to be executed on the UI thread.
A delegate is used gfor this; it is an object used to combine the relevant object and
method in a structured (type-safe) way.
I recommend you read more about this in any .NET programmers book, then have a look at
some of the many examples around.
|
|
|
|
|
So if i want to update my progress bar...i need to do something like this?
private delegate void SetPrecentage(int p);
<br />
private int DoOperation(int p)<br />
{<br />
if (this.InvokeRequired){<br />
Invoke(new SetPrecentage(DoOperation),new object[]{p});}<br />
}<br />
but then...how do i like, update the progress bar?
|
|
|
|
|
Do that in the else block.
private int DoOperation(int p)
{
if (this.InvokeRequired)
{
Invoke(new SetPrecentage(DoOperation),new object[]{p});}
}
else
{
}
|
|
|
|
|
but i mean, it will never run on a UI thread, so how do i update the progressbar? what will invoking p do? :\
|
|
|
|
|
The else code runs on the UI thread. When you call BeginInvoke or Invoke and pass it a delegate, .NET calls the delegate on the UI thread. In your example, you passed the same function as the delegate. When .NET calls the function on the UI thread, InvokeRequired will be false and the else code will run on the UI thread.
Have a look at What's up with BeginInvoke[^] to know more about this.
|
|
|
|
|
hi
i have sql server 2000 personal in server, and i want connect to it from client by vc#2005, but the following error shown me :
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
how to solve my problem ??
thanks
-- modified at 18:58 Friday 2nd March, 2007
|
|
|
|
|
|
I am working on a POS application that needs to run once, and then when called again it will just activate the current instance. So I have the run once code working but now I need to be able to pass params to the running instance. I am trying to implement a way to save the params to my properties.settings.default.param1, so when the exe is called the second time, I check for an existing instance by name, and if I find it I restore it. before I restore it I save the value of my params, and in the activated event of my form, I grab that data and present it to the user. Well this is not working all the time, sometimes it works sometimes it does not...I'm totally open to new ideas on this process...
Christopher J. Thornburg
Senior Systems Analyst
Ideal Card
|
|
|
|
|
Hi,
I dont know enough about settings files, I am not sure how it would behave when
more than one app instance exists, and how you could use them to communicate
(the first instance needs to reread once the second one changes the settings?).
Also I want solutions that would work on older .NET versions (1.1)
I have an app that wants to run as a singleton. My implementation works fine on
.NET 1.1 and 2.0
If it can create a named mutex, it knows it is the first instance, and it creates
a named pipe (sounds like the mutex is not really needed, could just try and create the
pipe right away I guess).
Otherwise, it connects to the pipe, sends the command line thru it, and exits.
The first instance has a separate thread that reads on the pipe, and acts on it
when something is received.
I use PInvoke to call CreateFile, WriteFile, ReadFile, CreateNamedPipe, ConnectNamedPipe
and CloseHandle.
|
|
|
|
|
Hello,
I have size problem! he hehe hehehe .. What I mean is that I wish to have the maximum working area available to me while I am developing. I realise that I can set the MainForm size but as the result the loaded window size is also going to be the same size.
Is there anyway that I can have the maximum working area during developing but once the application is built, if the maximum size is not chosen there are going to be horizantal and vertical scroller for accessing the entire application window.
I hope I managed to make sense out of my silly question. Once again, thank you very much guys for your help and I hope you have a great day.
Khoramdin
-- modified at 15:06 Friday 2nd March, 2007
|
|
|
|
|
I think you mean can you get the form to resize but keep the relative positions of various components. Have you looked at the Anchor property? Eg you can anchor a panel (for example) to stick to the right hand edge and resize with the form. You can also anchor most other visual components (buttons, text boxes etc...)
My apologies if this was not what you were intending.
|
|
|
|
|
Hi,
I have maintained html formatted text(help information) in XML file. like the following
eg.
<pre><Help>
<Page1>
<b>Login: </b> Press login button to login into the page
<page2>
<b>View: </b> Press View button to view the configuration details.
...
<Help></pre>
So iam taking the contents of Node Page1 using XML document to display the help for Page1 in Richtext box. But Richtext box not recognizing HTML tags. It simply display the contents.. How to present this content. Is it possible with RTB or is there any controls to display this HTML formatted text.
Thanks
Srini
-- modified at 14:46 Friday 2nd March, 2007
|
|
|
|
|
You can use the WebBrowser control to display html formatted text.
|
|
|
|
|
I can't use webbrowser..... since i am will only the text from XML. for displaying it in Webbrowser...we need to put into a separate HTML file.. and have to direct the webbrowser to that file path.... that is tedious job... and the webbrowser is not a stable component..
Any other solution here.
|
|
|
|
|
The RichTextBox control does not support HTML formatting. In order to display the formatted text, you need to convert the HTML to RTF, then set the RichTextBox.Rtf property to the converted text. The slick way to do it would be to create your own ICustomFormatter object that converts HTML markup to RTF, then pass it, along with your HTML string to StringBuilder.AppendFormat.
I don't know of any other way to tackle this problem. I'm sure there is a myriad of conversion tools out there and quite possibly an article or two on that topic on CP.
Sorry I don't have a better solution. Perhaps someone else does?
Ian
|
|
|
|
|