Walkthough problems...

Anyone,

I followed theWalkthrough: Building an Acropolis Notepad Application documentation and after running through the example noticed that open a file would not work. After opening a file, the Load event for my Part does not fire. Any suggestions?

Andres Olivares

[316 byte] By [andresmolivares] at [2008-2-22]
# 1

Hi Anders,

If you add the part directly to the applications child's part collection then the file menu's do not work. However, if you use a lifetime manager to handle the creation of the part, the lifetime manager can hook up to these commands. We shipped a sample lifetime manager in CTP1 called the DocumentManager. The DocumentManager has a templates collection that specify which parts to route which documents to. If your part dervies from DocumentPartBase, when you recompile the solution, you will get a DocumentTemplate typed to your part that you can use to add to the templates collection of the DocumentManager. Once this is done, the document manager knows how to handle the file commands and can route the files to your part.

Let me know if this helps!

Nathan

NathanE at 2007-9-28 > top of Msdn Tech,.NET Development,Acropolis...
# 2

Does your application have the right document template added to the document manager? It should look something like this:

Code Snippet

<Afx:DocumentManager x:Name="DocumentManager">
<Afx:DocumentManager.Templates>
<Afx:DocumentTemplate x:Name="DocumentTemplate" Type="{x:Type my:NotepadPart}" FileExtension=".txt"/>
</Afx:DocumentManager.Templates>

</Afx:DocumentManager>

You could also check your code against the code in the completd Notepad sample that ships with the Acropolis CTP1 release.

Hope this helps,

David.

DavidHill(Microsoft) at 2007-9-28 > top of Msdn Tech,.NET Development,Acropolis...
# 3

Nathan and Dave,

I am aware of the DocumentManager's role in the sample app. At first I did physically drop the Part onto the Appplication designer, and realized that was not working for me. Afterwards I followed the Notepad sample documentation.

After completing the sample, and comparing to the Notepad sample ship with the Acropolis CTP1 release, my FilePart project had code like the following:

Code Snippet (Application.xaml)
<AcropolisApplication.LifetimeManager>
<Afx:DocumentManager x:Name="DocumentManager">
<Afx:DocumentManager.Templates>
<Afx:DocumentTemplate x:Name="DocumentTemplate"
Type="{x:Type my:FilePart}" FileExtension="*.cs" />
</Afx:DocumentManager.Templates>
</Afx:DocumentManager>
</AcropolisApplication.LifetimeManager>

Everything else is idenitcal (with the exception that I called my part FilePart). Executing the NEW command works for me - creating a new blank doc and saves correctly when invoking SAVE. In this case, the OnSave method fires, but when I go to OPEN, the OnLoad method in the FilePart class is never invoked and the FileText property is never populated.

Thank you for your suggestions,

Andres Olivares

andresmolivares at 2007-9-28 > top of Msdn Tech,.NET Development,Acropolis...
# 4

I see my problem....very careless....

Code Snippet

FileExtension="*.cs"

//should be

FileExtension=".cs"

Sorry for the inconvnience.

andresmolivares at 2007-9-28 > top of Msdn Tech,.NET Development,Acropolis...
# 5
In our CTP2, we have modified it to allow "*.cs" and ".cs" and "cs". Smile Thank you for your feedback. Let us know if there are any other things we can improve on.
KathyKam-Microsoft at 2007-9-28 > top of Msdn Tech,.NET Development,Acropolis...

.NET Development

Site Classified