Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 26-Jul-11 23:57pm
v2
Comments
StM0n 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.)

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.
 
Share this answer
 
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?
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900