Spread.NET on Fedora with MONO

Posted by: tpot on 8 September 2017, 12:29 pm EST

  • Posted 8 September 2017, 12:29 pm EST

    I have made a sample app. using fpSpread in C#.NET with VS2005.
    I have just put a spread control onto a form so the application has a spread control on a form. It is so simple and was executed well on MS Windows.
    However, I copied it onto Fedora with MONO and executed but it failed although a message (ActiveRow= '$1:$1') was displayed.
    Do you suppose it should work or it is that you expect.?

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;


    namespace xxxxxxxAppC
    {
        public partial class fmTestSpreadObj : Form
        {
            public fmTestSpreadObj ()
            {
                MessageBox.Show("Start InitializeComponent");
                InitializeComponent();
                MessageBox.Show("End InitializeComponent");
            }


           
            private void fmTestSpreadObj_Load(object sender, EventArgs e)
            {
                try
                {
                    <font color="#ff0000">MessageBox.Show("ActiveRow= " + fpSpread1.Sheets[0].ActiveRow.ToString());</font>
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
    }
  • Replied 8 September 2017, 12:29 pm EST

    If you take out all the code, will the exe run?
  • Replied 8 September 2017, 12:29 pm EST

    Hello,


    You say the executable failed on a different Operating System. What error did you receive?

  • Replied 8 September 2017, 12:29 pm EST

    No error message came back and just Spread object was gone somewhere.
  • Replied 8 September 2017, 12:29 pm EST

    Hello,


    The results you are seeing, $1:$1, is not the result I would expect. You are probably getting 0 when running this in Windows, which is the correct result. Either Mono has some probelms with their implementation of the .NET framework, or the Form_Load event is too early for querying the object. Try moving that code to a Button_Click event to see if you get better results.


     

  • Replied 8 September 2017, 12:29 pm EST

    Hello,


    What line of code is causing the exception to fire? Try querying the ActiveRowIndex and ActiveColumnIndex instead of ActiveRow and ActiveColumn.

  • Replied 8 September 2017, 12:29 pm EST

    Hello

    "this.Controls.Add(sp);" causes this exception!
  • Replied 8 September 2017, 12:29 pm EST

    Hello,


    We do not have MONO here to test with. And I am not finding any information online what may cause an error like this. I looked at the online documentation and it does not give any information at all. Here is what I see from the documentation.


    Determines the number of bytes required to encode the characters in the specified System.String as a UTF8Encoding.



    <TABLE class=MemberSignatureTable cellSpacing=0 bgColor=#c0c0c0>

    <TR>
    <TD>
    <TABLE class=MemberSignatureInnerTable cellSpacing=0 cellPadding=10>

    <TR>
    <TD>public override int <B>GetByteCount</B> (string s)</TD></TR></TABLE></TD></TR></TABLE>


    <H4>Parameters</H4>
    <BLOCKQUOTE>

    <I>chars</I>
    A System.String to encode as a UTF8Encoding.
    <I>s</I>
    Documentation for this section has not yet been entered. </BLOCKQUOTE>
    <H4>Returns</H4>
    <BLOCKQUOTE>A System.Int32 that specifies the number of bytes necessary to encode <I>chars</I> as a UTF8Encoding. </BLOCKQUOTE>
    <H4>Exceptions</H4>
    <BLOCKQUOTE>
    <TABLE class=ExceptionsTable cellPadding=6>

    <TR>
    <TH>Type</TH>
    <TH>Condition</TH></TR>
    <TR>
    <TD>ArgumentNullException</TD>
    <TD><I>chars </I>is null. </TD></TR>
    <TR>
    <TD>ArgumentException</TD>
    <TD>Error-checking is turned on for the current instance and <I>chars</I> contains an invalid surrogate sequence.</TD></TR>
    <TR>
    <TD>ArgumentOutOfRangeException</TD>
    <TD>The return value is greater than System.Int32.MaxValue.</TD></TR></TABLE></BLOCKQUOTE>
    <H4>Remarks</H4>
    <BLOCKQUOTE>

    If error-checking is turned off and an invalid surrogate sequence is detected, the invalid characters are ignored and do not affect the return value, and no exception is thrown.



    <P><I>Note: </I>This method overrides Encoding.GetByteCount(System.Char[]).

    </BLOCKQUOTE>

    From this documentation, I can not see what 's' is. The documentation states this exception means that chars is null, but you posted a problem with s and not chars.The documentation goes on to say if you have error-checking turned off, then the invalid characters are ignored.


    Are you able to test adding other .NET controls using the Controls.Add method? Are you required to give the control a NAME before adding it to the Controls collection?

  • Replied 8 September 2017, 12:29 pm EST

    Hello

    Adding other standard .NET controls is fine!
    Then  giving NAME for spread control is NOT related to this problem.
  • Replied 8 September 2017, 12:29 pm EST

    Hello,


    I do not have any other suggestions. We do not support Spread in this development environment. It looks like there is a problem, but without being to debug, there is not a way to see if this is a problem with MONO or the FarPoint Spread. I would suggest going to the company that makes MONO and ask if they can get a trial version of the Spread to debug the issue in their IDE. We do not have a way to test MONO on Fedora here, so I think that would be the best way to proceed.

  • Replied 8 September 2017, 12:29 pm EST

    <img alt="" height="190" width="190">I rewrote the code as shown below and get the following message;
    Source:   mscorlib
    Method:   int32 GetByteCount(System.String)
    Message:   Atgument cannot be null. Parameter name: s



    <font face="Arial" size="2">using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;


    namespace AgoraTestAppC
    {
        public partial class fmThirdPirtyObj : Form
        {
            public fmThirdPirtyObj()
            {
                try
                {
                    InitializeComponent();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

           

            private void button1_Click(object sender, EventArgs e)
            {
                FarPoint.Win.Spread.FpSpread sp = new FarPoint.Win.Spread.FpSpread();

                try
                {
                    FarPoint.Win.Spread.SheetView s = new FarPoint.Win.Spread.SheetView();
                    s.ColumnCount = 4;
                    s.RowCount = 4;
                    sp.Sheets.Add(s);
                    sp.TabStripPolicy = FarPoint.Win.Spread.TabStripPolicy.AsNeeded;
                    sp.Location = new Point(0, 0);
                    this.Controls.Add(sp);
                    MessageBox.Show("ActiveRow= " + sp.Sheets[0].ActiveRow.ToString());
                    MessageBox.Show("ActiveCol= " + sp.Sheets[0].ActiveColumn.ToString());
                }
                catch (Exception ex)
                {
                    <font color="#ff1493">MessageBox.Show("Source: " + ex.Source + Environment.NewLine + "Method: " + ex.TargetSite + Environment.NewLine + "Message: " + ex.Message);</font>
                }
            }
        }
    }</font>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels