Not compiling with RTM of Windows 8 and Visual Studio

Aug 21, 2012 at 2:15 PM

Hi,

Being an MSDN subscriber (thanks to my job) I download VS2012 and Windows 8 and decided to give a go at practicing C++ (my C++ are weak...)

And then I downloaded Hilo to start learning....

Hence my disappointment when I got those 3 compilation errors and 2 warnings!!
(Well, not many of, I guess I can earn a lot by fixing them! Anyway, fixing them would be good too!)

1>c:\dev\hilo\hilo\hilo\common\bindablebase.h(19): error C4585: 'Hilo::Common::BindableBase' : A WinRT 'public ref class' must either be sealed or derive from an existing unsealed class

1>c:\dev\hilo\hilo\hilo\viewmodelbase.h(21): error C4585: 'Hilo::ViewModelBase' : A WinRT 'public ref class' must either be sealed or derive from an existing unsealed class

1>c:\dev\hilo\hilo\hilo\imagebase.h(19): error C4585: 'Hilo::ImageBase' : A WinRT 'public ref class' must either be sealed or derive from an existing unsealed class

1>c:\dev\hilo\hilo\hilo\iphoto.h(71): warning C4453: 'Windows::UI::Xaml::Media::Imaging::BitmapImage' : A '[WebHostHidden]' type should not be used on the published surface of a public type that is not '[WebHostHidden]'

1>c:\dev\hilo\hilo\hilo\iphoto.h(76): warning C4453: 'Windows::UI::Xaml::Media::Imaging::BitmapImage' : A '[WebHostHidden]' type should not be used on the published surface of a public type that is not '[WebHostHidden]'

Aug 21, 2012 at 11:34 PM
lloyd wrote:

Hence my disappointment when I got those 3 compilation errors and 2 warnings!!
(Well, not many of, I guess I can earn a lot by fixing them! Anyway, fixing them would be good too!)

Another snipping alligator... as with Lloyd I would like to dive into this project and see how these errors were resolved, i.e., is deriving from a protected class the best practice and how one would have a public type that is not WebHostHidden on a WebHostHidden type (multi-targeted codebase).

Although I have been a C# developer for many years I've heard/read "power and performance" enough to realize that C++ is going to be a main player moving forward (this WinRT P&P is another testimony to the fact).  I'm as much in the dark with C++ as I was when I first came across WPF in the earliest Prism/Unity drops - it was in these P&P projects that I learned patterns, i.e., MvpVm (shameless plug) that would help me successfully create frameworks for my clients to this day.  I'm looking forward to using this project to learn proper patterns, practices and coding techniques for WinRT/C++.

Coordinator
Aug 21, 2012 at 11:50 PM

I think you are experiencing this issue because current code base runs on Window Release Preview. We will post a version that runs on Windows RTM in next couple of days.

Aug 22, 2012 at 3:05 AM
blainew wrote:

I think you are experiencing this issue because current code base runs on Window Release Preview. We will post a version that runs on Windows RTM in next couple of days.


Sounds good - looking forward to it; I'll hold off on looking at the code until then.

Not sure how this project will evolve but it would be nice to see some enterprise patterns (EP) if feasible/practical, so far all of the samples that I've viewed have code in code-behind. 

This is my first/early stab at applying EP (from a C# perspective)
http://www.global-webnet.com/Blog/post/2012/08/21/Enterprise-patterns-for-WinRt-and-Cpp.aspx

Aug 25, 2012 at 1:35 PM

Hi Blaine,

I'm encountering the same issue that is preventing this project from compiling - do you have a best practice for this?   Bing'ing the issue has not revealed any solutions (but there are a lot of folks asking the same question).  My forum entry follows: How do you create a ref base class that you can derive from? 

Best regards
Bill

Aug 25, 2012 at 4:31 PM
Edited Aug 26, 2012 at 3:21 PM

I resolved the first problem, reported by lloyd, by creating a dummy project in Visual Studio and literally copying BindableBase.cpp & h over to Hilo (just change the namespace name to Hilo). It is also helpful to disable project setting that treats all warnings as errors, othewise you'll go nuts splattering [Windows::Foundation::Metadata::WebHostHidden] all over the place. 

Then you have to make one internal virtual destructor public, add parameter name (like Platform::String^ language) to all converters, and comment out one operator method on a public ref class - these are not allowed on ABI classes. Sorry, by now I forgot which files are in question, but explanation on what to do should suffice. After that I was able to run Hilo compiled with RTM Visual Studio 2012 and on RTM Windows 8. Yeeey!

However, I was lucky that I had no pictures in my Pictures folder. As soon as I added some pictures and started Hilo it threw an exception, somewhere deep in PPL running the continuation (based on the call stack that I see) and now I am really, finally, totally clueless as to what to do.

I have a presentation on programming Windows 8 Modern in C++ on Monday. It has to include MVVM and all the goody-goody stuff that currently I can find only in Hilo sample. Meaning: googling for Metro C++ MVVM doesn't find you anything of any value, unless you want to settle for C#.

I was hoping that MS P&P guys would fix it in a few days, but now my Monday presentation will probably include a story of a personal struggle and weekend sacrifice, despite all the obstacles that MS behemoth threw at me. 

Aug 25, 2012 at 6:39 PM
Edited Aug 25, 2012 at 6:46 PM
Tonko wrote:

I resolved the first problem, reported by lloyd, by creating a dummy project in Visual Studio and literally copying BindableBase.cpp & h over to Hilo (just change the namespace name to Hilo). It is also helpful to disable project setting that treats all warnings as errors, othewise you'll go nuts splattering [Windows::Foundation::Metadata::WebHostHidden] all over the place.

Very cool Tonko!  Since you got it to compile perhaps you can answer the question I can't seem to find an answer for.  Outside of the documented process of deriving your class from DependencyObject, what is a valid WinRt class that we can derive from?  I've been tapping the shoulders of our gurus, like blaine, hoping for a response that will either provide me the answer or give a definitive response that it can't be done (so I can devise a work-around until it is available).

When I pulled BindableBase into my solution, and replaced it as the baseclass to my PresenterBase, I got the standard message "A WinRT 'public ref class' must either be sealed or derive rom an existing unsealed class (PresenterBase.cpp)".  My vision statement is to create a WinRt/ARM (reusable) enterprise framework that is pretty much guaranteed to work on all platforms to include Phone when it comes out - so I have to operate within those constraints.

Tim Heuer provided the most comprehensive response (in all of my searching) which suggest that perhaps we can't this release.  An excerpt from this link follows:

XAML is likely the primary use case and hence the example.  If this is just a WinRT component, then you may have to think differently in the design.  Does it have to be public, etc. -- you can see the details (and some suggestions) in the doc http://win8.ms/rtmdevdoc -- see about page 29

public ref classes must inherit from a WinRT base and in this release that is scoped to most XAML scenarios.  If Resource inherits from DependencyObject you should get past the compiler error.

My preference is to develop via TDD so I'm blocked without an answer (more info); I've tapped a lot of shoulders, perhaps I'll get some news in the coming week...

Aug 26, 2012 at 5:18 PM
blainew wrote:

I think you are experiencing this issue because current code base runs on Window Release Preview. We will post a version that runs on Windows RTM in next couple of days.


I came up with "A Solution" - let me know when you come up with "The solution" :)
I blog about it HERE

Best regards
Bill

Sep 7, 2012 at 11:48 PM
Tonko wrote:

I resolved the first problem, reported by lloyd, by creating a dummy project in Visual Studio and literally copying BindableBase.cpp & h over to Hilo (just change the namespace name to Hilo). It is also helpful to disable project setting that treats all warnings as errors, othewise you'll go nuts splattering [Windows::Foundation::Metadata::WebHostHidden] all over the place. 

Then you have to make one internal virtual destructor public, add parameter name (like Platform::String^ language) to all converters, and comment out one operator method on a public ref class - these are not allowed on ABI classes. Sorry, by now I forgot which files are in question, but explanation on what to do should suffice. After that I was able to run Hilo compiled with RTM Visual Studio 2012 and on RTM Windows 8. Yeeey!

However, I was lucky that I had no pictures in my Pictures folder. As soon as I added some pictures and started Hilo it threw an exception, somewhere deep in PPL running the continuation (based on the call stack that I see) and now I am really, finally, totally clueless as to what to do.

I have a presentation on programming Windows 8 Modern in C++ on Monday. It has to include MVVM and all the goody-goody stuff that currently I can find only in Hilo sample. Meaning: googling for Metro C++ MVVM doesn't find you anything of any value, unless you want to settle for C#.

I was hoping that MS P&P guys would fix it in a few days, but now my Monday presentation will probably include a story of a personal struggle and weekend sacrifice, despite all the obstacles that MS behemoth threw at me. 

I've made almost the same work, and ended up at the same exception somewhere in app initialization in PPL code...

BTW you can notice that when you create a new C++/CX solution, warning 4453 is disabled (in project/properties/C++/Advanced/Disable specific warning).

If you are interested in MVVM in C++/CX, you can learn how it works in C#, it works exactly the same way in C++/CX (in fact C++/CX is C# with C++-like syntax! ;)). You can download a (working !!) C++/CX MVVM photo sample on the MSDN UK blog: http://blogs.msdn.com/b/ukmsdn/archive/2012/08/29/mvvm-in-c-cx.aspx

Sep 8, 2012 at 4:36 PM

Thanks for the link Pierre!

Coordinator
Oct 10, 2012 at 6:46 PM

We updated the source code to RTM. Let us know if you continue to have this problem.