[Mono-devel-list] problem execution exe files with mono

rosier_a@oreka.com rosier_a at oreka.com
Wed Jul 28 10:11:31 EDT 2004


hello,

I try to execute this code :

using System;
using System.Net;
using System.Text;

namespace ExchangeSDK.Snippets.CSharp
{
   class CreatingAnAppointmentWebDAV
   {
      [STAThread]
      static void Main(string[] args)
      {
         // Variables.
         string strExchSvrName = "";
         string strMailbox = "";
         string strCalendarUri = "";
         string strApptItem = "";
         string strDomain = "";
         string strUserName = "";
         string strPassword = "";
         string strApptRequest = "";
         string strMailInfo = "";
				 string strMailInfoVal = "";
         string strCalInfo = "";
         string strXMLNSInfo = "";
         string strHeaderInfo = "";
				 string strDate = "";
         System.Net.HttpWebRequest PROPPATCHRequest = null;
         System.Net.WebResponse PROPPATCHResponse = null;
         System.Net.CredentialCache MyCredentialCache = null;
         byte[] bytes = null; 
         System.IO.Stream PROPPATCHRequestStream = null;

         try
         {
				 
				
						 strDate= "2004-07-17";
						 
						 strMailInfoVal = args[0];
						// strDate = args[1];
						 
            // Exchange server name;
            strExchSvrName = "100.100.1.10";

            // Mailbox folder name.
            strMailbox = "toto.titi";

            // Appointment item.
            strApptItem = "testappointment.eml";

            // URI of the user's calendar folder.
            strCalendarUri = "http://" + strExchSvrName + "/exchange/"
            + strMailbox + "/Calendrier/";
						
						Console.WriteLine(strCalendarUri);

            // User name and password of appointment creator.
            strUserName = "titi.toto";
            strDomain = "Domainname";
            strPassword = "paswd";

            // XML namespace info for the WebDAV request.
            strXMLNSInfo = "xmlns:g=\"DAV:\" "
            + "xmlns:e=\"http://schemas.microsoft.com/exchange/\" "
            + "xmlns:mapi=\"http://schemas.microsoft.com/mapi/\" "
            + "xmlns:mapit=\"http://schemas.microsoft.com/mapi/proptag/\" "
            + "xmlns:x=\"xml:\" xmlns:cal=\"urn:schemas:calendar:\" "
            + "xmlns:dt=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" "
            + "xmlns:header=\"urn:schemas:mailheader:\" "
            + "xmlns:mail=\"urn:schemas:httpmail:\"";

            // Set the appointment item properties.  See the documentation on the properties
	    // in the urn:schemas:calendar: for more information.
            strCalInfo = "<cal:location>meetappt Location</cal:location>"
            + "<cal:dtstart dt:dt=\"dateTime.tz\">"+ strDate +"T23:00:00.000Z</cal:dtstart>"
            + "<cal:dtend dt:dt=\"dateTime.tz\">"+ strDate +"T23:30:00.000Z</cal:dtend>"
            + "<cal:instancetype dt:dt=\"int\">0</cal:instancetype>"
            + "<cal:busystatus>BUSY</cal:busystatus>"
            + "<cal:meetingstatus>CONFIRMED</cal:meetingstatus>"
            + "<cal:alldayevent dt:dt=\"boolean\">0</cal:alldayevent>"
            + "<cal:responserequested dt:dt=\"boolean\">1</cal:responserequested>";

            // Set the required attendee of the appointment.
            strHeaderInfo = "<header:to>" + strMailbox + "</header:to>";

            // Set the subject of the appointment.
            strMailInfo = "<mail:subject>"+ strMailInfoVal +"</mail:subject>"
            + "<mail:htmldescription>Let's meet here</mail:htmldescription>";

            // Build the XML body of the PROPPATCH request.
            strApptRequest = "<?xml version=\"1.0\"?>"
            + "<g:propertyupdate " + strXMLNSInfo + ">"
            + "<g:set><g:prop>"
            + "<g:contentclass>urn:content-classes:appointment</g:contentclass>"
            + "<e:outlookmessageclass>IPM.Appointment</e:outlookmessageclass>"
            + strMailInfo
            + strCalInfo
            + strHeaderInfo
            + "<mapi:finvited dt:dt=\"boolean\">1</mapi:finvited>"
            + "</g:prop></g:set>"
            + "</g:propertyupdate>";

            // Create a new CredentialCache object and fill it with the network
            // credentials required to access the server.
            MyCredentialCache = new System.Net.CredentialCache();
            MyCredentialCache.Add( new System.Uri(strCalendarUri),
                                   "NTLM",
                                   new System.Net.NetworkCredential(strUserName, strPassword, strDomain)
                                  );

            // Create the HttpWebRequest object.
            PROPPATCHRequest = (System.Net.HttpWebRequest)HttpWebRequest.Create(strCalendarUri + strApptItem);

            // Add the network credentials to the request.
            PROPPATCHRequest.Credentials = MyCredentialCache;

            // Specify the PROPPATCH method.
           PROPPATCHRequest.Method = "PROPPATCH";

            // Encode the body using UTF-8.
            bytes = Encoding.UTF8.GetBytes((string)strApptRequest);

            // Set the content header length.  This must be
            // done before writing data to the request stream.
            PROPPATCHRequest.ContentLength = bytes.Length;

            // Get a reference to the request stream.
            PROPPATCHRequestStream = PROPPATCHRequest.GetRequestStream();

            // Write the message body to the request stream.
            PROPPATCHRequestStream.Write(bytes, 0, bytes.Length);

            // Close the Stream object to release the connection
            // for further use.
            PROPPATCHRequestStream.Close();

            // Set the content type header.
            PROPPATCHRequest.ContentType = "text/xml";

            // Create the appointment in the Calendar folder of the
            // user's mailbox.
            PROPPATCHResponse = (System.Net.HttpWebResponse)PROPPATCHRequest.GetResponse();

            // Clean up.
            PROPPATCHResponse.Close();

            Console.WriteLine("Appointment successfully created.");

         }
         catch(Exception ex)
         {
            // Catch any exceptions. Any error codes from the PROPPATCH
            // method request on the server will be caught
            // here, also.
            Console.WriteLine(ex.Message);
         }

      }
   }
}

I compile with mono in windows 2000.
If i execute test.exe --> OK
But if  I execute
	Mono test.exe, an excetion occured : Request Started
			Unhandled Exception: System.InvalidOperationException: request started
in <0x00033> System.Net.HttpWebRequest:CheckRequestStarted ()
in <0x0004c> (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:Chec
kRequestStarted ()
in <0x00011> System.Net.HttpWebRequest:set_ContentType (string)
in <0x004fb> ExchangeSDK.Snippets.CSharp.CreatingAnAppointmentWebDAV:Main (strin
g[])

the problem provides of the lines :                
               PROPPATCHRequest.ContentType = "text/xml";

can you help me ?


////////////////////////////////////////////////////////////
// Webmail Oreka : http://www.oreka.com
////////////////////////////////////////////////////////////





More information about the Mono-devel-list mailing list