Loki

Loki

  • NA
  • 1
  • 0

passing data between components

Jun 7 2009 2:34 PM
Hello, I have a question about passing data between components

What I have is a solution with two projects, a forms project (the exe) and a class library (a dll).  I have a reference to the class library from the forms project, I can access items from it and I'm convinced I'm doing it correctly.  My question is, is it possible to access items on the exe from the dll project?  For example, I'm passing in a form from the exe to the dll using a mutator method.  This seems to work, but when I try to access any properties I've made on the form from a method in the dll, I don't see them on the intellisense list.  Furthermore, I can't seem to set the object type to anything more specific that Form, or 'cast' it to the proper Form that lives in the exe.  I've also tried to reference the exe project from the dll, but I get a circular reference error.  I've pasted a code example below, any help you would be willing to provide would be greatly appreciated.  I am happy to provide a compilable solution via email if it helps you, please email at [email protected] if interested.  Thank you in advance!

 // form code, this is in the exe portion of the project

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;



namespace MainApp

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

       

        private bool _rflag;





        public bool RetryFlag

        {

            get { return _rflag; }

            set { _rflag = value; }

        }



        private void button1_Click(object sender, EventArgs e)

        {

            ClassLibrary1.Class1 _class = new ClassLibrary1.Class1();

            _class.SetForm(this);

            _class.ChangeScreenStatus();

 



        }

    }

}



// Class library portion

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 



namespace ClassLibrary1

{

    public class Class1

    {

        private Form _form;



        public void SetForm(Form pVal)

        {

            _form = pVal;

        }



        public void ChangeScreenStatus()

        {

            // THIS IS THE CODE THAT I WANT TO WORK BUT IT DOESN'T

            _form.RetryFlag = true;



            //  ****   other things I've tried that don't work-

            // Can't cast it to the type I think I need to

            //(MainApp.Form1)_form.RetryFlag = true;

           

            // Can't convert it either

            //Convert. 





        }



    }

}