|
Hi ,
I am good at C# concepts, but i am looking gaining expertise on C# programming
(developing tools e.t.c)
Can any of you please share some links, which contains good basic programs and projects.
Thanks in advance.
Regards,
Anil kumar
|
|
|
|
|
Hi,
you can edit a post using the "Edit" widget at its bottom.
you can also delete a message of yours (with the "Delete" widget next to "Edit"), as long as no reply has been posted.
So now is the time to remove the other message, and maybe edit the remaining one ...
|
|
|
|
|
He's also good at ignoring advice!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I've been going around in circles trying to find some reliable (and understandable) information on this task. What I want to do is find a way to put a control inside a PowerPoint presentation.
Some background, a while ago I created a PowerPoint plug-in to allow a user to set some things to happen when a particular slide appears. This works well (after a lot of sweating and banging my head on the wall). I would like to be able to add similar functionality to objects (e.g. pictures or buttons) on a slide. However, Microsoft in their infinite wisdom decided not to expose click events for objects on slides in their API - so case closed, can't be done.
Then I thought, I ought to be able to add an ActiveX control to a PowerPoint presentation, but this is turning out to be more complicated than I hoped. Most ActiveX / C# tutorials I come across are from the perspective of using them in a web page (I've even done it myself in the past, it's easy and it works) but not from the perspective of using them in an Office application.
I tried the CSActiveXCtrl example from the All-In-One code framework and even the Microsoft Interop Forms Toolkit (in VB.NET), but they both act weird in PowerPoint. When they are added to a slide they appear at a default size which clips them. Then when you stretch them it just stretches (zomms) the clipped control. When you start the presentation it displays properly sized and unclipped, but once the presentation is over it disappears from the slide design and running the slide show again doesn't make it come back. Clearly I'm missing some interfaces from the ActiveX control that PowerPoint expects, but don't know what they are or how to implement them.
I saw a potentially related post here[^] which suggested this:
A less labor intensive approach would be to use the C++ MFC control project. This will do much of the heavy lifting for you and will greatly simplify your development effort. Once you have your control created, you could just use TLBIMP.EXE to generate an interop assembly containing the RCW's for you to interop with. I would recommend this approach.
Which sounds promising, but doesn't elaborate on what exactly I need to do to make it work.
I'm pretty much lost here - any pointers or suggestions would be welcomed!
|
|
|
|
|
I have a a multi-purpose application that I am working with. 3 Different forms, one form has log in validation and the another has DateTimePickers. I threw a button on the parent form just to compare saved settings, when I set a Time in DTP say for 11:30 PM and the close that form and go back to the parent form, the DTP Value that I saved doesn't actually get saved till I close my application and re-open it, so I can't compare my alarm times unless I close the application and re-open it. How can I get the form to refresh to the most updated variable that is being stored in my settings?
|
|
|
|
|
Herboren wrote: How can I get the form to refresh to the most updated variable that is being stored in my settings?
Doesn't the settings-class provide a Reload[^]-method? How did you bind to the ApplicationSetting?
Bastard Programmer from Hell
|
|
|
|
|
Could you please clarify:
1. are you working in WinForms, WPF ... or ?
2. what strategy for saving the DateTime(s) you pick are you using now: Serialization ? Application.Settings ? Registry ?
3. you imply you are setting "alarm:" could you say a bit more about the purpose of your application and its 3-form design ?
best, Bill
"Beauty is in the eye of the beholder, and it may be necessary from time to time to give a stupid or misinformed beholder a black eye." Miss Piggy"
modified 22-Sep-11 11:53am.
|
|
|
|
|
Greetings Gurus...
If you could spare a moment..?
The following code is an attempt to retrieve the contents of the Windows Application event log and upload the data to a SQL server.
I am getting 2 errors though and was hoping someone could tell me why the errors are occurring.
Error 1: "A namespace does not directly contain members such as fields or methods" at the line that reads
" SysMonConn.Open();" in bold
Error 2: "Type or namespace definition, or end-of-file expected" at the closing bracket.
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Data.SqlClient;
namespace ConsoleApplication3
{
class Program
{
public static void Main();
string logType = "Application";
EventLog ev = new EventLog(logType, System.Environment.MachineName);
EventLogEntry Entry = ev.Entries;
SqlConnection SysMonConn = new SqlConnection(@"Provider = sqloledb.1" +
"Source = 192.168.x.y,1433" +
"Database = EventLogs" +
"Trusted_Connection=yes;" +
"user id=a;" +
"password=b;" +
"connection timeout=30;");
}
SysMonConn.Open();
SqlCommand SMCommand = SysMonConn.CreateCommand();
SMCommand.CommandText = "INSERT INTO dbo.EventTable(Category, ComputerName," +
"Message, SourceName, TimeWritten,Type, UserName)";
SMCommand.Parameters.Add("@Category", System.Data.SqlDbType.NVarChar, 50) = Entry.Category;
SMCommand.Parameters.Add("@ComputerName", System.Data.SqlDbType.NVarChar, 50) = Entry.MachineName;
SMCommand.Parameters.Add("@Message", System.Data.SqlDbType.NVarChar, 250) = Entry.Message;
SMCommand.Parameters.Add("@SourceName", System.Data.SqlDbType.NVarChar, 50) = Entry.Source;
SMCommand.Parameters.Add("@TimeWritten", System.Data.SqlDbType.NVarChar, 50) = Entry.TimeWritten;
SMCommand.Parameters.Add("@Type", System.Data.SqlDbType.NVarChar, 50) = Entry.EntryType;
SMCommand.Parameters.Add("@UserName", System.Data.SqlDbType.NVarChar, 50) = Entry.UserName;
ev.Close();
}
}
Any assistance greatly appreciated
|
|
|
|
|
your curly brackets are all wrong, you need one when opening Main (rather than a semi-colon), and the matching one is below ev.Close(); , so the one in front of SysMonConn.Open() should be removed.
If you put the curlies right, the right indentation of your code would ensue automatically (at least in real IDE's such as Visual Studio); if it looks almost right at the moment, it tells me you have been adding/removing tabs yourself.
|
|
|
|
|
Um - perhaps I'm missing something, but you have an extraneous } directly before the bolded line which is closing Main()....what follows is therefore outside a method and hence will not fly - I'd have thought you'd have spotted that though!
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Your declaration of Main() is terminated with a semi-colon so becomes a null method. You also have a spurious closing brace '}' just before SysMonConn.Open(); .
|
|
|
|
|
Hi Luc, RichardG & RichardM,
Thank you for the quick responses.
I had tried the fixes you suggested but get (mainly) 2 other errors when I reformat the code:-
public static void Main()
{
string logType = "Application";
EventLog ev = new EventLog(logType, System.Environment.MachineName);
EventLogEntry Entry = ev.Entries;
SqlConnection SysMonConn = new SqlConnection(@"Provider = sqloledb.1" +
"Source = 192.168.x.y,1433" +
"Database = EventLogs" +
"Trusted_Connection=yes;" +
"user id=a;" +
"password=b;" +
"connection timeout=30;");
SysMonConn.Open();
SqlCommand SMCommand = SysMonConn.CreateCommand();
SMCommand.CommandText = "INSERT INTO dbo.EventTable(Category, ComputerName," +
"Message, SourceName, TimeWritten,Type, UserName)";
SMCommand.Parameters.Add("@Category", System.Data.SqlDbType.NVarChar, 50) = Entry.Category;
SMCommand.Parameters.Add("@ComputerName", System.Data.SqlDbType.NVarChar, 50) = Entry.MachineName;
SMCommand.Parameters.Add("@Message", System.Data.SqlDbType.NVarChar, 250) = Entry.Message;
SMCommand.Parameters.Add("@SourceName", System.Data.SqlDbType.NVarChar, 50) = Entry.Source;
SMCommand.Parameters.Add("@TimeWritten", System.Data.SqlDbType.NVarChar, 50) = Entry.TimeWritten;
SMCommand.Parameters.Add("@Type", System.Data.SqlDbType.NVarChar, 50) = Entry.EntryType;
SMCommand.Parameters.Add("@UserName", System.Data.SqlDbType.NVarChar, 50) = Entry.UserName;
ev.Close();
}
}
}
I now get:
Error 1 "Cannot implicitly convert type 'System.Diagnostics.EventLogEntryCollection' to 'System.Diagnostics.EventLogEntry'" on the bold line ev.Entries
Errors 2,4,6,8,10,12,14 "The left-hand side of an assignment must be a variable, property or indexer" on all the lines
SMCommand.Parameters.Add("@xxxxx", System.Data.SqlDbType.NVarChar, 50)
Errors 3,5,7,9,11,13,15 "Cannot implicitly convert type 'string' to 'System.Data.SqlClient.SqlParameter'" on all the lines Entry.xxxxx
Please pardon my ignorance but I learning by example, trial-and-error and looking through other's code so I don't always understand why these errors occur.
Thanks for your patience...
|
|
|
|
|
I have a number of suggestions for you:
1.
Read the error messages carefully, most of the time they make perfect sense, however each word counts.
2.
Focus on the first message first; oftentimes the other ones are a result of the earlier mistakes in your code.
3.
If you're new to something, start with the smallest amount of code that could compile and run (and maybe do nothing much); once it compiles and runs, start adding stuff; keep compiling and running, never just enter lots of code, then feel completely lost when tons of errors appear.
4.
The best way to learn some new language or technology, is by choosing, buying and studying a book on the subject; you can and should add some experimentation to it, but experiments alone are no substitute for studying a real book.
|
|
|
|
|
Hi Luc,
In response,
1. I have read the messages, Googled them, and been through dozens of webpages, blog pages and forums trying to find a solution. The reason I posted to this esteemed forum is because I had still not been able to find an answer to my problem
2. See 1) above. If you don't know and can't find the meaning of the first message it won't help resolve the second message
3. I have been through the c# (and c++) tuts a few times, informative as they are they can't prepare you for everything you may need/want to do. My "Hello World" code runs perfectly.
4. I agree, but even if you buy and study hundreds of "Teach Yourself French" books eventually you are going to have to talk to a Frenchman. D'accord?
|
|
|
|
|
I should have included:
-1. keep an open mind; this includes: the compiler is probably right, the programmer most likely made a mistake.
0. apply logic reasoning.
example:
Entry = ev.Entries;
even when the compiler would agree (it doesn't), I as a reader would protest, as the LHS is singular and the RHS is plural.
|
|
|
|
|
Thank you for your patience and somewhat cryptic answers Luc but,
-1. It is (almost) always safe to assume that the programmer has made a mistake. If however he does not know where the mistake is he cannot fix it. Thus he turns to better programmers.
0. Logic is great as long as you can think like the compiler does. I can think in vba but c# is still a learning process. Unfortunately they don't use the same logic<>syntax.
example:
EventLogEntry Entry = ev.Entry; = 'System.Diagnostics.EventLog' does not contain a definition for 'Entry' (same applies to Entries = Entries)
Thank you for your advice Luc but I am just not understanding what you are trying to tell me.
|
|
|
|
|
Look again (closely) at this message: Error 1 "Cannot implicitly convert type 'System.Diagnostics.EventLogEntryCollection' to 'System.Diagnostics.EventLogEntry'"
What is it saying in the most basic terms: cannot convert a [System.Diagnostics.EventLog]EntryCollection (the return value of ev.Entries ) to [System.Diagnostics.EventLog]Entry - OK, you are trying to convert an EntryCollection (a collection is obviously plural) to an Entry (singular). So by changing the destination of your assignment to be some type of Collection (probably an EntryCollection) would maybe get rid of that error. Recompile and see how many of the other errors still exist and follow the same process again. This can be done quite easily without the use of Google just by checking the documentation[^].
You may like to reread Luc's previous suggestion as his logical approach to problem solving will serve you well.
|
|
|
|
|
Maybe it's just a basic misunderstanding of the assignment operator ("="). It assigns the return value of the right hand expression to the return value of the left hand expression. Let's put it in symbols: Target <- Source .
Further down, the lines SMCommand.Parameters.Add() = Entry.Category each call a method Add() and immediately replace its return value by Entry.Whatever . I can only guess, but maybe you want it to behave the other way round.
Add() returns an SqlParameter . Maybe you want to store that via
Entry.Message = Add("@Message", System.Data.SqlDbType.NVarChar, 250).ToString(); But even then, I doubt that EventLogEntry.Category and EventLogEntry.EntryType would accept a string . In this case, you would have to create some kind of conversion.
Ciao,
luker
|
|
|
|
|
i have one issue
whenever selecting radio button ,print option should come by using java script. if any one having solution please let me know.
|
|
|
|
|
You might have better luck posting a JavaScript question in the JavaScript forum. This is C#, and the similarities are superficial.
|
|
|
|
|
this code not sending email Why? please help me
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Web11
{
public partial class WebSendMail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
MailMessage Mail = new MailMessage();
Mail.To.Add("AotherEmail@hotmail.com");
Mail.From = new MailAddress("MyEmail@hotmail.com");
Mail.Subject = "ASp.net";
Mail.Body = " hi I want Help";
SmtpClient smt = new SmtpClient("smtp.hotmail.com");
smt.Send(Mail);
Response.Write("Email Was Send");
}
catch (Exception ex)
{
Response.Write(" Email Invalid"+ex.Message );
}
}
}
}
|
|
|
|
|
I dont know.
Why dont you
1) Try and debug the code yourself
2) Check the Host name and credentials are correct
3) Post error messages
|
|
|
|
|
Use network cardentials
NetworkCredential authinfo = new NetworkCredential("id", "password");
smtp.UseDefaultCredentials = false;
smtp.Credentials = authinfo;
|
|
|
|
|
Unless they've changed it Hotmail doens't allow relaying, so you can't use it to send emails. You'll need a server that does permit relays.... IIRC, none of the big web-mail providers allow it for obvious reasons
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Enterprise Library ExecuteDataSet method not setting Output parameter value.
The value of output parameter is always null.
using (DbCommand cmd = db.GetStoredProcCommand("s_sProcName"))
{
DataSet ds = new DataSet()
db.AddInParameter(cmd, "@p_sFoo", DbType.String, "Bar");
db.AddOutParameter(cmd, "@po_iOut", DbType.Int32, 4)
ds = db.ExecuteDataSet(cmd);
}
How can i get value of Output parameter?
Can any one please !!
|
|
|
|
|