Loading ...
Sorry, an error occurred while loading the content.

Re: System.Reflection.Emit.AssemblyBuilder exception under Windows Phone 7

Expand Messages
  • geniali74
    Hi Charles Thanks for your answer. I ve a project if it works. Only the deserials of the request data not work. It is a Windows Phone 7 project. ... internal
    Message 1 of 12 , Jun 18, 2011
    View Source
    • 0 Attachment
      Hi Charles

      Thanks for your answer.
      I've a project if it works. Only the deserials of the request data not work.

      It is a Windows Phone 7 project.

      Code:
      -----
      internal class PartyPartyProxy : XmlRpcClientProtocol
      {
      private static object[] _Domain = {new object()};
      private static object[] _Field = new object[] {};
      private static object[] _Order = new object[] {};
      private Setting _Setting;

      #region async SearchRead

      public PartyPartyProxy(Setting setting)
      {
      Url = string.Format("{0}://{1}:{2}/{3}", setting.UrlProtocol, setting.Domain, setting.Port, setting.Database);
      UseIntTag = true;
      _Setting = setting;
      }

      public IAsyncResult BeginSearchRead(AsyncCallback callback)
      {
      return Begin(_Domain, 0, int.MaxValue, _Order, _Field, callback);
      }


      #region XML RPC

      [XmlRpcBegin("model.party.party.search_read")]
      private IAsyncResult Begin(object[] domain, int offset, int limit, object[] order, object[] field,
      AsyncCallback callback)
      {
      return BeginInvoke(MethodBase.GetCurrentMethod(), new object[] { domain, offset, limit, order, field, _Setting.Context },
      callback, null);
      }

      [XmlRpcEnd]
      private XmlRpcStruct[] End(IAsyncResult iasr)
      {
      XmlRpcStruct[] ret = (XmlRpcStruct[])EndInvoke(iasr);
      return ret;
      }

      public static XmlRpcStruct[] EndSearchRead(IAsyncResult iasr)
      {
      XmlRpcAsyncResult rpcAsyncResult = iasr as XmlRpcAsyncResult;

      if (rpcAsyncResult != null)
      {
      PartyPartyProxy partyProxy = rpcAsyncResult.ClientProtocol as PartyPartyProxy;

      if (partyProxy != null)
      {
      XmlRpcStruct[] resutl = partyProxy.End(iasr);

      return resutl;
      }
      }

      return null;
      }

      #endregion XML RPC

      #endregion async SearchRead

      private static void SetBasicAuthHeader(WebHeaderCollection headers, string user, string password)
      {
      string authInfo = user + ":" + password;
      authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo));
      headers["Authorization"] = "Basic " + authInfo;
      }

      protected override WebRequest GetWebRequest(Uri uri)
      {
      WebRequest webRequest = WebRequest.Create(uri);
      SetBasicAuthHeader(webRequest.Headers, _Setting.UserName, _Setting.Passwort);

      return webRequest;
      }
      }

      Call:
      -----
      PartyPartyProxy partyProxy = new PartyPartyProxy(this.Setting);
      partyProxy.BeginSearchRead(SetResult);


      private void SetResult(IAsyncResult ar)
      {
      XmlRpcStruct[] resutl = PartyPartyProxy.EndSearchRead(ar);

      foreach (XmlRpcStruct xmlRpcStruct in resutl)
      {
      PartyModel partyModel = new PartyModel();
      partyModel.Id = (int)xmlRpcStruct["id"];
      partyModel.Name = (string)xmlRpcStruct["name"];

      Partys.Add(partyModel);
      }
      }

      Exception:
      ----------

      In this Method.

      XmlRpcResponse ReadResponse(XmlRpcRequest req, WebResponse webResp, Stream respStm)
      {
      HttpWebResponse httpResp = (HttpWebResponse)webResp;
      if (httpResp.StatusCode != HttpStatusCode.OK)
      {
      // status 400 is used for errors caused by the client
      // status 500 is used for server errors (not server application
      // errors which are returned as fault responses)
      if (httpResp.StatusCode == HttpStatusCode.BadRequest)
      throw new XmlRpcException(httpResp.StatusDescription);
      else
      throw new XmlRpcServerException(httpResp.StatusDescription);
      }
      var deserializer = new XmlRpcResponseDeserializer();
      deserializer.NonStandard = _nonStandard;
      Type retType = req.mi.ReturnType;
      XmlRpcResponse xmlRpcResp= deserializer.DeserializeResponse(respStm, req.ReturnType);
      return xmlRpcResp;
      }

      In the Line:
      else
      throw new XmlRpcServerException(httpResp.StatusDescription);

      XML Request (Fiddler):
      ----------------------
      <?xml version="1.0"?>
      <methodCall>
      <methodName>model.party.party.search_read</methodName>
      <params>
      <param>
      <value>
      <array>
      <data>
      <value>
      <array>
      <data />
      </array>
      </value>
      <value>
      <array>
      <data>
      <value>
      <string>id</string>
      </value>
      <value>
      <string>in</string>
      </value>
      <value>
      <array>
      <data>
      <value>
      <int>1</int>
      </value>
      <value>
      <int>2</int>
      </value>
      </data>
      </array>
      </value>
      </data>
      </array>
      </value>
      </data>
      </array>
      </value>
      </param>
      <!-- deltet params-->
      </params>
      </methodCall>

      XML Response (Fiddler):
      -----------------------
      <?xml version='1.0'?>
      <methodResponse>
      <params>
      <param>
      <value>
      <array>
      <data>
      <value>
      <struct>
      <member>
      <name>code</name>
      <value>
      <string>2</string>
      </value>
      </member>
      <member>
      <name>create_date</name>
      <value>
      <dateTime.iso8601>20110516T08:38:07</dateTime.iso8601>
      </value>
      </member>
      <member>
      <name>addresses</name>
      <value>
      <array>
      <data>
      <value>
      <int>2</int>
      </value>
      </data>
      </array>
      </value>
      </member>
      <member>
      <name>payment_term</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>write_uid</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>full_name</name>
      <value>
      <string>Foo & Bar AG</string>
      </value>
      </member>
      <member>
      <name>vat_number</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>id</name>
      <value>
      <int>2</int>
      </value>
      </member>
      <member>
      <name>receivable</name>
      <value>
      <double>0.0</double>
      </value>
      </member>
      <member>
      <name>create_uid</name>
      <value>
      <int>1</int>
      </value>
      </member>
      <member>
      <name>receivable_today</name>
      <value>
      <double>0.0</double>
      </value>
      </member>
      <member>
      <name>account_payable</name>
      <value>
      <int>83</int>
      </value>
      </member>
      <member>
      <name>code_length</name>
      <value>
      <int>1</int>
      </value>
      </member>
      <member>
      <name>vat_code</name>
      <value>
      <string></string>
      </value>
      </member>
      <member>
      <name>email</name>
      <value>
      <string>info@...</string>
      </value>
      </member>
      <member>
      <name>website</name>
      <value>
      <string></string>
      </value>
      </member>
      <member>
      <name>rec_name</name>
      <value>
      <string>Foo & Bar AG</string>
      </value>
      </member>
      <member>
      <name>fax</name>
      <value>
      <string></string>
      </value>
      </member>
      <member>
      <name>account_receivable</name>
      <value>
      <int>35</int>
      </value>
      </member>
      <member>
      <name>customer_tax_rule</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>payable</name>
      <value>
      <double>0.0</double>
      </value>
      </member>
      <member>
      <name>contact_mechanisms</name>
      <value>
      <array>
      <data>
      <value>
      <int>1</int>
      </value>
      <value>
      <int>2</int>
      </value>
      </data>
      </array>
      </value>
      </member>
      <member>
      <name>write_date</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>active</name>
      <value>
      <boolean>1</boolean>
      </value>
      </member>
      <member>
      <name>categories</name>
      <value>
      <array>
      <data>
      </data>
      </array>
      </value>
      </member>
      <member>
      <name>lang</name>
      <value>
      <int>3</int>
      </value>
      </member>
      <member>
      <name>supplier_tax_rule</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>name</name>
      <value>
      <string>Foo & Bar AG</string>
      </value>
      </member>
      <member>
      <name>phone</name>
      <value>
      <string>0318452659</string>
      </value>
      </member>
      <member>
      <name>mobile</name>
      <value>
      <string></string>
      </value>
      </member>
      <member>
      <name>supplier_payment_term</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>vat_country</name>
      <value>
      <boolean>0</boolean>
      </value>
      </member>
      <member>
      <name>payable_today</name>
      <value>
      <double>0.0</double>
      </value>
      </member>
      </struct>
      </value>
      </data>
      </array>
      </value>
      </param>
      </params>
      </methodResponse>

      Why i've this exception?
    • Charles Cook
      What are the status code and description of the response? ... [iPad] ... [Non-text portions of this message have been removed]
      Message 2 of 12 , Jun 20, 2011
      View Source
      • 0 Attachment
        What are the status code and description of the response?

        :Charles

        [iPad]

        On Jun 18, 2011, at 6:19 AM, "geniali74" <genialireloaded@...> wrote:

        >
        >
        > Hi Charles
        >
        > Thanks for your answer.
        > I've a project if it works. Only the deserials of the request data not work.
        >
        > It is a Windows Phone 7 project.
        >
        > Code:
        > -----
        > internal class PartyPartyProxy : XmlRpcClientProtocol
        > {
        > private static object[] _Domain = {new object()};
        > private static object[] _Field = new object[] {};
        > private static object[] _Order = new object[] {};
        > private Setting _Setting;
        >
        > #region async SearchRead
        >
        > public PartyPartyProxy(Setting setting)
        > {
        > Url = string.Format("{0}://{1}:{2}/{3}", setting.UrlProtocol, setting.Domain, setting.Port, setting.Database);
        > UseIntTag = true;
        > _Setting = setting;
        > }
        >
        > public IAsyncResult BeginSearchRead(AsyncCallback callback)
        > {
        > return Begin(_Domain, 0, int.MaxValue, _Order, _Field, callback);
        > }
        >
        >
        > #region XML RPC
        >
        > [XmlRpcBegin("model.party.party.search_read")]
        > private IAsyncResult Begin(object[] domain, int offset, int limit, object[] order, object[] field,
        > AsyncCallback callback)
        > {
        > return BeginInvoke(MethodBase.GetCurrentMethod(), new object[] { domain, offset, limit, order, field, _Setting.Context },
        > callback, null);
        > }
        >
        > [XmlRpcEnd]
        > private XmlRpcStruct[] End(IAsyncResult iasr)
        > {
        > XmlRpcStruct[] ret = (XmlRpcStruct[])EndInvoke(iasr);
        > return ret;
        > }
        >
        > public static XmlRpcStruct[] EndSearchRead(IAsyncResult iasr)
        > {
        > XmlRpcAsyncResult rpcAsyncResult = iasr as XmlRpcAsyncResult;
        >
        > if (rpcAsyncResult != null)
        > {
        > PartyPartyProxy partyProxy = rpcAsyncResult.ClientProtocol as PartyPartyProxy;
        >
        > if (partyProxy != null)
        > {
        > XmlRpcStruct[] resutl = partyProxy.End(iasr);
        >
        > return resutl;
        > }
        > }
        >
        > return null;
        > }
        >
        > #endregion XML RPC
        >
        > #endregion async SearchRead
        >
        > private static void SetBasicAuthHeader(WebHeaderCollection headers, string user, string password)
        > {
        > string authInfo = user + ":" + password;
        > authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo));
        > headers["Authorization"] = "Basic " + authInfo;
        > }
        >
        > protected override WebRequest GetWebRequest(Uri uri)
        > {
        > WebRequest webRequest = WebRequest.Create(uri);
        > SetBasicAuthHeader(webRequest.Headers, _Setting.UserName, _Setting.Passwort);
        >
        > return webRequest;
        > }
        > }
        >
        > Call:
        > -----
        > PartyPartyProxy partyProxy = new PartyPartyProxy(this.Setting);
        > partyProxy.BeginSearchRead(SetResult);
        >
        > private void SetResult(IAsyncResult ar)
        > {
        > XmlRpcStruct[] resutl = PartyPartyProxy.EndSearchRead(ar);
        >
        > foreach (XmlRpcStruct xmlRpcStruct in resutl)
        > {
        > PartyModel partyModel = new PartyModel();
        > partyModel.Id = (int)xmlRpcStruct["id"];
        > partyModel.Name = (string)xmlRpcStruct["name"];
        >
        > Partys.Add(partyModel);
        > }
        > }
        >
        > Exception:
        > ----------
        >
        > In this Method.
        >
        > XmlRpcResponse ReadResponse(XmlRpcRequest req, WebResponse webResp, Stream respStm)
        > {
        > HttpWebResponse httpResp = (HttpWebResponse)webResp;
        > if (httpResp.StatusCode != HttpStatusCode.OK)
        > {
        > // status 400 is used for errors caused by the client
        > // status 500 is used for server errors (not server application
        > // errors which are returned as fault responses)
        > if (httpResp.StatusCode == HttpStatusCode.BadRequest)
        > throw new XmlRpcException(httpResp.StatusDescription);
        > else
        > throw new XmlRpcServerException(httpResp.StatusDescription);
        > }
        > var deserializer = new XmlRpcResponseDeserializer();
        > deserializer.NonStandard = _nonStandard;
        > Type retType = req.mi.ReturnType;
        > XmlRpcResponse xmlRpcResp= deserializer.DeserializeResponse(respStm, req.ReturnType);
        > return xmlRpcResp;
        > }
        >
        > In the Line:
        > else
        > throw new XmlRpcServerException(httpResp.StatusDescription);
        >
        > XML Request (Fiddler):
        > ----------------------
        > <?xml version="1.0"?>
        > <methodCall>
        > <methodName>model.party.party.search_read</methodName>
        > <params>
        > <param>
        > <value>
        > <array>
        > <data>
        > <value>
        > <array>
        > <data />
        > </array>
        > </value>
        > <value>
        > <array>
        > <data>
        > <value>
        > <string>id</string>
        > </value>
        > <value>
        > <string>in</string>
        > </value>
        > <value>
        > <array>
        > <data>
        > <value>
        > <int>1</int>
        > </value>
        > <value>
        > <int>2</int>
        > </value>
        > </data>
        > </array>
        > </value>
        > </data>
        > </array>
        > </value>
        > </data>
        > </array>
        > </value>
        > </param>
        > <!-- deltet params-->
        > </params>
        > </methodCall>
        >
        > XML Response (Fiddler):
        > -----------------------
        > <?xml version='1.0'?>
        > <methodResponse>
        > <params>
        > <param>
        > <value>
        > <array>
        > <data>
        > <value>
        > <struct>
        > <member>
        > <name>code</name>
        > <value>
        > <string>2</string>
        > </value>
        > </member>
        > <member>
        > <name>create_date</name>
        > <value>
        > <dateTime.iso8601>20110516T08:38:07</dateTime.iso8601>
        > </value>
        > </member>
        > <member>
        > <name>addresses</name>
        > <value>
        > <array>
        > <data>
        > <value>
        > <int>2</int>
        > </value>
        > </data>
        > </array>
        > </value>
        > </member>
        > <member>
        > <name>payment_term</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>write_uid</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>full_name</name>
        > <value>
        > <string>Foo & Bar AG</string>
        > </value>
        > </member>
        > <member>
        > <name>vat_number</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>id</name>
        > <value>
        > <int>2</int>
        > </value>
        > </member>
        > <member>
        > <name>receivable</name>
        > <value>
        > <double>0.0</double>
        > </value>
        > </member>
        > <member>
        > <name>create_uid</name>
        > <value>
        > <int>1</int>
        > </value>
        > </member>
        > <member>
        > <name>receivable_today</name>
        > <value>
        > <double>0.0</double>
        > </value>
        > </member>
        > <member>
        > <name>account_payable</name>
        > <value>
        > <int>83</int>
        > </value>
        > </member>
        > <member>
        > <name>code_length</name>
        > <value>
        > <int>1</int>
        > </value>
        > </member>
        > <member>
        > <name>vat_code</name>
        > <value>
        > <string></string>
        > </value>
        > </member>
        > <member>
        > <name>email</name>
        > <value>
        > <string>info@...</string>
        > </value>
        > </member>
        > <member>
        > <name>website</name>
        > <value>
        > <string></string>
        > </value>
        > </member>
        > <member>
        > <name>rec_name</name>
        > <value>
        > <string>Foo & Bar AG</string>
        > </value>
        > </member>
        > <member>
        > <name>fax</name>
        > <value>
        > <string></string>
        > </value>
        > </member>
        > <member>
        > <name>account_receivable</name>
        > <value>
        > <int>35</int>
        > </value>
        > </member>
        > <member>
        > <name>customer_tax_rule</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>payable</name>
        > <value>
        > <double>0.0</double>
        > </value>
        > </member>
        > <member>
        > <name>contact_mechanisms</name>
        > <value>
        > <array>
        > <data>
        > <value>
        > <int>1</int>
        > </value>
        > <value>
        > <int>2</int>
        > </value>
        > </data>
        > </array>
        > </value>
        > </member>
        > <member>
        > <name>write_date</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>active</name>
        > <value>
        > <boolean>1</boolean>
        > </value>
        > </member>
        > <member>
        > <name>categories</name>
        > <value>
        > <array>
        > <data>
        > </data>
        > </array>
        > </value>
        > </member>
        > <member>
        > <name>lang</name>
        > <value>
        > <int>3</int>
        > </value>
        > </member>
        > <member>
        > <name>supplier_tax_rule</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>name</name>
        > <value>
        > <string>Foo & Bar AG</string>
        > </value>
        > </member>
        > <member>
        > <name>phone</name>
        > <value>
        > <string>0318452659</string>
        > </value>
        > </member>
        > <member>
        > <name>mobile</name>
        > <value>
        > <string></string>
        > </value>
        > </member>
        > <member>
        > <name>supplier_payment_term</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>vat_country</name>
        > <value>
        > <boolean>0</boolean>
        > </value>
        > </member>
        > <member>
        > <name>payable_today</name>
        > <value>
        > <double>0.0</double>
        > </value>
        > </member>
        > </struct>
        > </value>
        > </data>
        > </array>
        > </value>
        > </param>
        > </params>
        > </methodResponse>
        >
        > Why i've this exception?
        >
        >


        [Non-text portions of this message have been removed]
      • geniali74
        Hi Charles I was on the verge of resignation. I can no longer produce the error. :-( I can send you the solution with a correct login for the service? I see
        Message 3 of 12 , Jun 20, 2011
        View Source
        • 0 Attachment
          Hi Charles

          I was on the verge of resignation. I can no longer produce the error. :-(
          I can send you the solution with a correct login for the service? I see the response XML in fiddler. But i can't deserialize the XML. 99% works. But the deserialize will not work. :-(

          What's your email? My email is info[at]geniali.ch.
          Many thanks

          --
          Roland Schumacher alias GENiALi
          http://blog.geniali.ch/
        • geniali74
          Hi Charles I think I ve found the error. I ve reference to the xmlrpcsilverlight assembly and change this code. File: XmlRpcDeserializer.cs Line: 915 // TODO:
          Message 4 of 12 , Jun 21, 2011
          View Source
          • 0 Attachment
            Hi Charles

            I think I've found the error.
            I've reference to the xmlrpcsilverlight assembly and change this code.

            File: XmlRpcDeserializer.cs Line: 915

            // TODO: following to return Array?
            object CreateArrayInstance(Type type, object[] args)
            {
            #if (!COMPACT_FRAMEWORK && !SILVERLIGHT)
            return Activator.CreateInstance(type, args);
            #else
            Object Arr = Array.CreateInstance(type.GetElementType(), (int)args[0]);
            return Arr;
            #endif
            }

            I added the '&& !SILVERLIGHT' and now works fine. I have my data.
          • Charles Cook
            Hi Roland: thanks for this fix. I ll check it in when I get back from vacation. I need to work out how to run NUnit tests in Silverlight to provide
            Message 5 of 12 , Jun 23, 2011
            View Source
            • 0 Attachment
              Hi Roland: thanks for this fix. I'll check it in when I get back from
              vacation. I need to work out how to run NUnit tests in Silverlight to
              provide satisfactory testing for the Silverlight build.

              :Charles

              On Tue, Jun 21, 2011 at 3:55 PM, geniali74 <genialireloaded@...>wrote:

              > **
              >
              >
              > Hi Charles
              >
              > I think I've found the error.
              > I've reference to the xmlrpcsilverlight assembly and change this code.
              >
              > File: XmlRpcDeserializer.cs Line: 915
              >
              > // TODO: following to return Array?
              > object CreateArrayInstance(Type type, object[] args)
              > {
              > #if (!COMPACT_FRAMEWORK && !SILVERLIGHT)
              > return Activator.CreateInstance(type, args);
              > #else
              > Object Arr = Array.CreateInstance(type.GetElementType(), (int)args[0]);
              > return Arr;
              > #endif
              > }
              >
              > I added the '&& !SILVERLIGHT' and now works fine. I have my data.
              >
              >
              >


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.