Click here to Skip to main content
13,145,068 members (57,065 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to initiate a class to use it's attributes and method from another class, but the class has 2 constructors(1 with parameters, and one without). the one without parameters it is finding ok, the one with parameters it is not seeing it. it is because it is a partial class?

this is the code:
public partial class ScenarioEditorView : UserControl, IScreenSelectorSubItem, IActionable, INotifyPropertyChanged
        string p1 = "";
        string fullp = Path.GetFullPath(p1);
        ScenarioEditorViewModel viewModel = new ScenarioEditorViewModel(fullp);

fullp is unknown.

please help
Posted 26-Jul-11 23:53pm
Updated 26-Jul-11 23:57pm
s_mon 27-Jul-11 6:29am
Currently, I see none... erh... ok, the default... the one without parameters... is this the complete code?

[edit]I'm submitting to fast :)[/edit]
BobJanova 27-Jul-11 6:34am
What is the actual error, and what is the constructor definition of the view model? That code looks okay from a compilation point of view. (It seems kind of backwards to have the view create the view model, but that is a separate discussion.)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Make sure that:
- you didn't forget public for your second constructor
- if the second constructor is in another file (you said your class is partial), then make sure the name of the class is spelled properly, otherwise it will be considered as another class.

For now I don't see anything else. Please post more code if you want more help.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

No, it is not because the class is partial: the only thing the "partial" keyword does is letting you split a class (an interface, a struct) among two or more compilation units[^]. This is especially useful when parts of your class are generated by a tool.

In other words, keyword "partial" is purely a compile-time construct: once a class is compiled, there are no detectable differences between a partial and a non-partial classes if they are identical in all respects except being partial.

The only reason why a compiler could not "see" a declared constructor is because that constructor is not public, and your code is not allowed access to it. Could you post the details of your error, and a code for the constructor's header?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 27 Jul 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100