|
I have an exe file built in .Net 1.1
I use the System.Web.Mail class to send an email...
when i run the executable locally say by double clicking the file the program runs fine and i receive the email.
However the purpose of the exe is to be run from a website that i have developed by using ProcessStartInfo. Under this scenario i get the error
'Could not create CDO.Message object'
Now i did all the correct checks as having permission to cdosys.dll and making sure the user ASPNET and NETWORK SERVICE have full permissions to the exe. As stated before the code runs perfect when run by double clicking the exe but not when run by the web app im running on my localhost.
|
|
|
|
|
I found a Swedish article with someone running into a similar problem. I don't know the exact wording of the message - he only wrote something about the code "not being able to access the CDO.Message object" (in Swedish), which may or may not boil down to the same message.
In any case - he solved the problem by recursively looking at the InnerException of the exception thrown and so on. Turned out to be a really simple mistake (missing e-mail address), but the original exception was a bit misleading.
Try do something like this:
try
{
}
catch (Exception ex)
{
Response.Write(ex.ToString());
Response.End();
}
(note: written as if it were a web app, which your exe probably isn't. Response.Write won't do you any good then, of course - use whatever's appropriate)
Later,
--
Peter
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Text;
namespace WindowsApplication1
{
class Pupil
{
public int ID;
}
static void Main (string[] args)
{
Pupil Patrick = new Pupil();
Pupil Cathy = new pupli();
.....................................................................
using System;
using System.Collections.Generic;
using System.Text;
namespace WindowsApplication1
{
class Homework
{
public int numberofWork;
public string keyword;
}
static void Main (string[] args)
{
Homework Patr = new Pupil();
Homework Cath = new pupli();
.......................................................................
Am getting error message Expected class delegate,enum,interface or struct.
Any guidance on how I may rectify this?
|
|
|
|
|
Looks like you're missing closing curly braces.
Also you're headed for casting problems unless you fix the last 2 lines in your example.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
First code snippet:
Change pupli to Pupil.
Second code snippet:
Change Pupil to Homework.
Change pupli to Homework.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Angelinna,
How come you have two program entry points:
static void Main (string[] args)
Also, it's a good idea to use Properties, instead of public variables.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Your main method isn't in a class. It's just sitting there within the namespace. You need to have something like:
namespace myApp
{
class stuff
{
}
class Program
{
static void Main (string[] args)
{
}
}
}
So that everything is in a class.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Am totally confused. Not getting any where.
|
|
|
|
|
Your Main method just needs to be in a class, thats what the error is saying. The compiler expected a class or struct etc. but it found a method, so it gave you the error.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Am practising on writing classes from an exercise that requires hardcoding values into a program.
Task requires
1. defining a class Pupil and a class Homework
2. Containing data for two sample Pupils and their homeworks(hardcoded in the program)
3. Lets the user enter the keywords to be checked for
4. Let the user request to see the homework data of a pupil
Hard coded data/values like
John Kay
67890
initial sentence ;= There was a tiny little.....
Words; = 200
keyword; = overwhelming
Woul really appreciate your thoughts on the approach
Angelinna
modified on Tuesday, May 20, 2008 9:59 PM
|
|
|
|
|
1 - I think you had this OK, just define classes
2 - Create two pupils and their homework in your static void main, and pass in the values
3 - Accept user input and then check your items to see if they match
4 - accept user input to select a pupil, and output the contents of their homework.
Is this a console app or a windows one ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
What i understand from reading all the posts is
You can't initiate
Homework Patr = new Pupil(); //Simply can't do that
Homework is different type and Pupil is different type
it is same as doing
string Patr = new int();
You must derive your Homework class from Pupil or take a object of Homework in Pupil
|
|
|
|
|
I think you're a bit confused on classes here - you need to do some serious research and study.
I'll try to help a little but I'm not doing it for you - I'm sure you wouldn't want me to!
Let's look at a Pupil class.
There's many ways to create a class, but I find the easiest is to have four sections (or regions - you can actually use this word in your code!).
1. Member variables - declare these as private so only the class itself can modify them.
2. Properties - public so they can be accessed outside of the class.
One benifit of the above two over a single public variable is the property get and set methods can alter/filter/validate the data. There a many others but this isn't supposed to be an article!
3. Methods - these actually do stuff with the data and if necessary return a value of any type needed.
4. Constructors - these are used to create an instance of your class.
This is an example Pupil class - see if you can follow what's happening. When you understand *EVERY* line you may be ready to attempt the task you've posted. This code won't work fully without some work and understanding from you as it references 2 other classes - Homework and PupilHomework . I'm leaving it up to you to create those, make them interact with the Pupil class, and add any neccesary enhancements to the Pupil class.
public class Pupil
{
#region Member Variables
private int m_ID;
private string m_Name;
private List<PupilHomework> m_HomeworkList;
private static int lastID = 0;
#endregion
#region Properties
public int ID
{
get { return m_ID; }
}
public string Name
{
get { return m_Name; }
set { m_Name = value; }
}
public List<PupilHomework> HomeworkList
{
get { return m_HomeworkList; }
}
#endregion
#region Methods
public void AddHomework(Homework homework)
{
m_HomeworkList.Add(new PupilHomework(homework.ID));
}
#endregion
#region Constructors
public Pupil(string name)
{
m_Name = name;
m_ID = ++lastID;
m_HomeworkList = new List<PupilHomework>();
}
#endregion
}
Dave
|
|
|
|
|
Thanks Dave. You have been most helpful
|
|
|
|
|
No problem. Post back if you have any more problems
Dave
|
|
|
|
|
When I used to code console apps for C++, my program could take runtime arguments, like
int main ()
{
return 0;
}
How can I do something similar to this in C#? I am running a windows form application, and when I tried static void Main(string open) it gave me an error saying it wasnt a proper place for program entry.
How can I accomplish this?
Thanks in advance.
|
|
|
|
|
That Asian Guy,
static void Main(string[] args)
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Wow that was easy. Thanks :P
|
|
|
|
|
Yeah, what he said, plus
static int Main ( string[] args )
{
return 0;
}
|
|
|
|
|
Ah, somebody as pedantic as I am about Main returning an int.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
Vikram A Punathambekar wrote: as pedantic
If not moreso.
No reason not to and it's going to anyway, why not control it?
|
|
|
|
|
I am trying to set the following registration in my aspx so I can bind a wcf service to an AutoCompleteExtender:
]]>
However, the compiler returns the following error:
"The directive 'servicehost' is unknown"
I have added the following "using" directive to the codebehind:
using System.ServiceModel;
I have added servicehostingenvironment aspnetcompatibilityenabled="true" as a child element of system.servicemodel in Web.config.
What am I missing?
NOTE - This forum software automatically wraps the directive tag above with "CDATA"
|
|
|
|
|
Did you add a reference to System.ServiceModel?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
I am trying to return Count(*), cast to a String and assign the value to Label1.Text. I am a bit stuck on the C# syntax because I am new to C#. This is what my research has produced thus far:
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(ConnString))
{
//String newTagName = txtParm.Text;
int DOWcount = 0;
SqlCommand cmd = new SqlCommand("SELECT count(*)FROM RealTime WHERE DATEPART (d,CallStartTime) = DATEPART(d,getdate())", conn);
cmd.Parameters.Count;
conn.Open();
DOWcount = cmd.ExecuteNonQuery();
Label1.Text = DOWCount.ToString();
I know that I am not using the "cmd" correctly. Can anyone of the experts out there steer me in the right direction?
|
|
|
|
|
mreynol5 wrote: Can anyone of the experts out there steer me in the right direction?
No. No one knows how to do that. And if anyone did it certainly would not be Microsoft and they certainly would not document it.[^]
And you certainly would not be able to find the documentation using Google[^]
mreynol5 wrote: I am a bit stuck on the C# syntax because I am new to C#.
Ok, good luck
led mike
|
|
|
|