Newbee question, regarding a couple of syntaxes in c#



  • 1. Pin Down Cause of A/V Crash? (Not JIT)
    I have an application that builds and runs just fine on my PC. It's pure C#, no P/Invoke, no Win requirements or anything. I built the app, stuck the dependcies in the same DIR, and copied it to another PC. When I run it, it AVs right away, without any details or dialogs. The event viewer is of no help. How can I pin down the source of this crash? If it were a JIT error, I can grab the stack trace and figure it out.... But here? The other machine has .NET 2.0 installed and has no problem with any other programs I've written before. Where do you suggest I start in debugging this?
  • 2. Missing System.IdentityModel
    Hi, I'm deploying a clickonce application and encounter an error when user try to install it. The popup form says assembly System.Identity Model version be installed in GAC first. But the user has already installed .net framework 3.0 runtime. What's happening here? -- Thanks. Daniel
  • 3. Why doesn't this string reverse work with the space for this particular string?
    Hi all, I just wrote this up real quick, and it seems to work with a bunch of input strings (with and without spaces) except for the one in the code below: string input = "this is a string"; int length = input.Length-1; char [] reverseMe = input.ToCharArray(); char temp; for (int i = 0; i<length / 2; i++) { temp = reverseMe[i]; reverseMe[i] = reverseMe[length - i]; reverseMe[length - i] = temp; } string done = new string(reverseMe); MessageBox.Show(done); Expected output: gnirts a si siht Actual output: gnirts asi siht What's with the missing space between the "is" and the "a"? thanks in advance, cdj
  • 4. How to access the ServiceHost object from the WCF service
    Hi all. I created a custom ServiceHost object and did a bunch of initialization there. Now I need to access an object in it from the actual WCF service class. How can this be done? Thanks!!!

Re: Newbee question, regarding a couple of syntaxes in c#

Postby Peter Jausovec » Sat, 20 Nov 2004 06:37:59 GMT


You don't need to create new namespace (therefore there is no xxx = new xxx 
:)), but you get the namespace from the outlook application object you 
created. Same goes with MailItem -> you call method CreateItem with 
parameter which descibes the item you are creating (olMailItem) and because 
CreateItem returns object you have to cast that to Outlook.MailItem.

Hope this helps..

Re: Newbee question, regarding a couple of syntaxes in c#

Postby Anders Nor » Sat, 20 Nov 2004 06:47:15 GMT

> Outlook.Application oApp = new Outlook.Application();


GetNamespace is a factory method. A factory is a method that creates an 
object instance for you based on parameters or other stimuli.
On the inside the GetNamespace method could do something like this:
public NameSpace GetNamespace(string ns) {
    if (ns=="mapi") return new MapiNamespace();
    else return new OtherNamespace();

The CreateItem is another factory method. This method creates the item type 
you ask for, in your example an olMailItem. Because the return type of the 
factory is a base class you have to cast it to the more specific type 

Same as above. The Recipients property is casted to a Recipients type.

Anders Nor
blog:  http://www.**--****.com/ 

Similar Threads:

1.Q: Newbee question, regarding a couple of syntaxes in c#


I was testing an application that is writing a mail and sends it to a
recieptiens. I then came across
a couple of ??? in my head, coul anyone briefly tell me what the difference
is between this and where in the help i can read more about it

First out...

Outlook.Application oApp = new Outlook.Application();
My guess is that this create a new object oApp from this
Outlook.Application? Right?

Then the following, i just don't get, what they do and what it is called...

Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
(Why not xxx = new xxx)

Outlook.MailItem oMsg =

Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;

Thanx in advance for any help


Martin Arvidsson

2.A couple of questions regarding TextBox

Howdy.  I'm a bit new to C# and got a couple of quick questions that perhaps
someone can help me answer.  First, is there a property that you set on a
TextBox control that will force the control to accept only numerical data
(i.e. - only numbers 0 to 9, a decimal and the negative sign)?  So far, I've
had to do the validation manually on either a key down or OnValidate event.
Secondly, is there any way to preview a key stroke for a given control and
then either accept or toss the value of the key stroke depending on some
sort of pre-defined rule?  So for example, if a user were to enter hit the
"a" key while in a text box, what I would like to have happen is to have the
application eat the keystroke and not have the "a" character ever show up in
the text control.  Is this possible?  Any assistance provided would be
greatly appreciated.


3.Newbee question, regarding database (SQL)

4.Newbee question regarding ADO

5.couple questions regarding marshaling

How are the Marshal.GetManagedThunkForUnmanagedMethodPtr,
Marshal.GetUnmanagedThunkForManagedMethodPtr methods used?

How is the SignatureHelper class used to get a pointer to a method

I am trying to use a function pointer returned from GetProcAddress.

I know that you can use System.Reflection.Emit to emulate dynamic loading of
dll's. So please do not reply by telling me to use emit.


6. Q: Couple of quiz regarding custom components.

7. Couple of quiz regarding custom components.

8. newbee question about listbox

Return to C#


Who is online

Users browsing this forum: No registered users and 1 guest