0

I have 2 wpf applications. I need to send as parameter to one of them and in that one to change the parametr and in the other wpf application to use the new value of the variables.

My code :

1 WPF :

Forms.CreatRadar creatRadarWPF = new Forms.CreatRadar(azimuthStart,AzimuthEnd,Long,Lat,numOfRadars,listRadars);
            creatRadarWPF.Show();

2 WPF :

public partial class CreatRadar : Window
{
    private double AzimuthStart;
    private double AzimuthEnd;
    private double Long;
    private double Lat;
    private int numOfRadars;
    private List<Radar> ListRadars;

    public CreatRadar(double AzimuthStart, double AzimuthEnd, double Long, double Lat, int numOfRadars, List<MapSample.Radar> ListRadars)
    {
        InitializeComponent();
    }

    private void CreatRadarBtn_Click(object sender, RoutedEventArgs e)
    {
        this.AzimuthStart = double.Parse(txt_AzimuthStart.Text.ToString());
        this.AzimuthEnd = double.Parse(txt_AzimuthEnd.Text.ToString());
        this.Long = double.Parse(txt_Long.Text.ToString());
        this.Lat = double.Parse(txt_Lat.Text.ToString());
        this.ListRadars = ListRadars;
        this.numOfRadars = numOfRadars;

        this.numOfRadars++;
        Radar RadarTemp = new Radar(numOfRadars, this.AzimuthStart, this.AzimuthEnd, this.Long, this.Lat, 1, 1);
        this.ListRadars.Add(RadarTemp);

        MapDrawManager.Instance.Draw(RadarTemp);
    }
}

The error : Inconsistent accessibility : parameter type 'System.Collections.Generic.List' is less accessible than method 'MapSample.Forms.CreatRadar(double,double,double,double,int,System.Collections.Generic.List)'

Ben Tubul
  • 45
  • 1
  • 9

2 Answers2

1

Your class MapSample.Radar seems not to be public. That is necessary because it is used in the public function CreatRadar.

Fratyx
  • 5,717
  • 1
  • 12
  • 22
  • Are you sure you need the parameters in function CreatRadar at all? They are not used. Or did you clip code? – Fratyx Oct 06 '14 at 17:55
  • ... and what is MapSample? A namespace or a (public :-)) parent class? – Fratyx Oct 06 '14 at 17:58
  • public class is public – Mare Infinitus Oct 06 '14 at 18:05
  • Well, I succsseded. But now I have another problem with the list. every time I'm Creat the object list if i not doing this line : this.ListRadars = new List(); it error that the object is null. – Ben Tubul Oct 06 '14 at 18:40
  • Yes it's C#. A declaration like `List ListRadars;` is a mere placeholder containing null. So you have explicitely call `new`. – Fratyx Oct 06 '14 at 18:47
  • didn't understand you Fratyx – Ben Tubul Oct 06 '14 at 19:04
  • Im must to take the listRadar from the other wpf.. if I declarate it new so It cleared.. – Ben Tubul Oct 06 '14 at 19:05
  • 1
    You never assign ListRadars. You have the function `CreatRadar` which takes parameter ListRader and others but you don't use these parameters in this function. I think you try to assign ListRadars in the xxx_Click function but this function assigns the (empty) ListRadars to itself. There is no local variable and no parameter called ListRadars in this function so this.ListRadars is the same as ListRadars (without `this.`). – Fratyx Oct 06 '14 at 19:28
  • Problem solved. I was needed to do : this.listRadar = listRadar; ---> in the constractor not in the xxx_click... Thanks all. – Ben Tubul Oct 06 '14 at 21:04
0

Is the MapSample.Radar class a public class or an internal class? If so, consider changing the internal modifier of this class and makes sure it says "public class MapSample.Radar". You must change additional types into public as required if you can use them from the other WPF app. Or you can also change the assemblies to a friend assembly for the other WPF app by setting the InternalsVisibleTo attribute in AssemblyInfo file.

More info here about friend assemblies here and how to strong name sign assemblies (note that inside Visual Studio it is also possible set up the signing of assemblies such that the sn command does not have to be run from a command line): How to declare a friend assembly?

Community
  • 1
  • 1
Tore Aurstad
  • 3,189
  • 1
  • 27
  • 22