Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - On the renaming of MyApp to something more descriptive...

 
 
Old 01-31-2006   #1 (permalink)
Jason Dolinger


 
 

On the renaming of MyApp to something more descriptive...

Has anyone had any success trying to name their application something
other than MyApp.xaml? I'd like to give it a real name now, and it
doesn't quite seem to be working. First of all, you can use the rename
feature within VS which will simultaneously rename the .xaml and
..xaml.cs files themselves, but it won't change the name of the actual
class definition inside the file (i.e. you end up with a file named
CoolApp.xaml but inside the file the definition is still:

public partial class MyApp : Application { ...

so you have to fix that up manually (come on MS, that's a feature that
Eclipse has had for years).

The next issue stems from the fact that you are still left with a
MyApp.g.cs and MyApp.g.baml file. Shouldn't the next build result in
these files getting regenerated with the new name (CoolApp.g.cs and
CoolApp.baml)? It doesn't, instead the old files remain and you may get
new files with the correct names, but they aren't valid as an
Application. They are missing the main method and have a bunch of stuff
that look more like it's a .g.cs for a Window (it implements IConnect
and contains the Connect method).

I got it to work temporarily by manually renaming the MyApp.g.cs file to
CoolApp.g.cs, changing the name of the class it defines and having it
load coolapp.baml. But this will only last until the next time the
files are regenerated, and you then lose your main method.

Can anyone from MS elaborate on this issue? Thanks guys,

Jason

My System SpecsSystem Spec
Old 01-31-2006   #2 (permalink)
viliescu


 
 

RE: On the renaming of MyApp to something more descriptive...

You have to manually change this line in the .csproj file
<Page Include="CoolApp.xaml" />
to
<ApplicationDefinition Include="CoolApp.xaml" />

ApplicationDefinition specifies the XAML file that contains the entry point
for your application.
--
Valentin Iliescu [MVP C#]


"Jason Dolinger" wrote:

> Has anyone had any success trying to name their application something
> other than MyApp.xaml? I'd like to give it a real name now, and it
> doesn't quite seem to be working. First of all, you can use the rename
> feature within VS which will simultaneously rename the .xaml and
> ..xaml.cs files themselves, but it won't change the name of the actual
> class definition inside the file (i.e. you end up with a file named
> CoolApp.xaml but inside the file the definition is still:
>
> public partial class MyApp : Application { ...
>
> so you have to fix that up manually (come on MS, that's a feature that
> Eclipse has had for years).
>
> The next issue stems from the fact that you are still left with a
> MyApp.g.cs and MyApp.g.baml file. Shouldn't the next build result in
> these files getting regenerated with the new name (CoolApp.g.cs and
> CoolApp.baml)? It doesn't, instead the old files remain and you may get
> new files with the correct names, but they aren't valid as an
> Application. They are missing the main method and have a bunch of stuff
> that look more like it's a .g.cs for a Window (it implements IConnect
> and contains the Connect method).
>
> I got it to work temporarily by manually renaming the MyApp.g.cs file to
> CoolApp.g.cs, changing the name of the class it defines and having it
> load coolapp.baml. But this will only last until the next time the
> files are regenerated, and you then lose your main method.
>
> Can anyone from MS elaborate on this issue? Thanks guys,
>
> Jason
>

My System SpecsSystem Spec
Old 01-31-2006   #3 (permalink)
viliescu


 
 

Re: On the renaming of MyApp to something more descriptive...

You're absolutely right. Keep in mind, however, this CTP is not very polished
.... I am pretty sure the final version will not have these bugs.
--
Valentin Iliescu [MVP C#]


"Jason Dolinger" wrote:

> viliescu wrote:
> > You have to manually change this line in the .csproj file
> > <Page Include="CoolApp.xaml" />
> > to
> > <ApplicationDefinition Include="CoolApp.xaml" />
> >
> > ApplicationDefinition specifies the XAML file that contains the entry point
> > for your application.

>
> Thanks Valentin, that did it. Although I do wonder a couple of things:
>
> - Why does renaming MyApp.xaml to something else change the .csproj file
> to reference it as <Page Include=... rather than <ApplicationDefinition
> Include=... ?
> - Why oh why doesn't the actual class definitions in the file contents
> get renamed along with the file name itself? ie. When you use the name
> feature in VS, not just the .xaml and .xaml.cs files get renamed. Also:
>
> public partial class MyApp : Application {
>
> should become
>
> public partial class CoolApp : Application {
>
>
> and <Application x:Class="MyNamespace.MyApp" ...
>
> should become:
>
> <Application x:Class="MyNamespace.CoolApp" ...
>
>
> Given that this rename is something virtually all of us will have to do
> when we are building real apps.
>
> Thanks,
> Jason
>
>
>
>

My System SpecsSystem Spec
Old 01-31-2006   #4 (permalink)
Bob Brown[MSFT]


 
 

Re: On the renaming of MyApp to something more descriptive...

I ran into the class rename problem too (you're talking about the new
right-click -> "refactor" feature, right?) and filed a bug on it back in
October. From what I've seen in the bug report, it apears to be a problem
with language services in Visual Studio (doesn't look into the Xaml for
necessary renames) and may not be able to be fixed in the near future (since
VS 2005 has already shipped). This was a pain point for me since I use this
feature a lot, but unfortunately it looks like there's nothing we can do
about it in the immediate future. My way around it was to use Find/Replace
(CTL-H) instead.

I didn't try the application file rename thing though.

--
Bob Brown [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.


"viliescu" <viliescu@discussions.microsoft.com> wrote in message
news:E58265B3-3523-409C-846C-0BE57B0C237A@microsoft.com...
> You're absolutely right. Keep in mind, however, this CTP is not very
> polished
> ... I am pretty sure the final version will not have these bugs.
> --
> Valentin Iliescu [MVP C#]
>
>
> "Jason Dolinger" wrote:
>
>> viliescu wrote:
>> > You have to manually change this line in the .csproj file
>> > <Page Include="CoolApp.xaml" />
>> > to
>> > <ApplicationDefinition Include="CoolApp.xaml" />
>> >
>> > ApplicationDefinition specifies the XAML file that contains the entry
>> > point
>> > for your application.

>>
>> Thanks Valentin, that did it. Although I do wonder a couple of things:
>>
>> - Why does renaming MyApp.xaml to something else change the .csproj file
>> to reference it as <Page Include=... rather than <ApplicationDefinition
>> Include=... ?
>> - Why oh why doesn't the actual class definitions in the file contents
>> get renamed along with the file name itself? ie. When you use the name
>> feature in VS, not just the .xaml and .xaml.cs files get renamed. Also:
>>
>> public partial class MyApp : Application {
>>
>> should become
>>
>> public partial class CoolApp : Application {
>>
>>
>> and <Application x:Class="MyNamespace.MyApp" ...
>>
>> should become:
>>
>> <Application x:Class="MyNamespace.CoolApp" ...
>>
>>
>> Given that this rename is something virtually all of us will have to do
>> when we are building real apps.
>>
>> Thanks,
>> Jason
>>
>>
>>
>>



My System SpecsSystem Spec
Old 01-31-2006   #5 (permalink)
Jason Dolinger


 
 

Re: On the renaming of MyApp to something more descriptive...

Bob Brown[MSFT] wrote:
> I ran into the class rename problem too (you're talking about the new
> right-click -> "refactor" feature, right?) and filed a bug on it back in
> October. From what I've seen in the bug report, it apears to be a problem
> with language services in Visual Studio (doesn't look into the Xaml for
> necessary renames) and may not be able to be fixed in the near future (since
> VS 2005 has already shipped). This was a pain point for me since I use this
> feature a lot, but unfortunately it looks like there's nothing we can do
> about it in the immediate future. My way around it was to use Find/Replace
> (CTL-H) instead.
>
> I didn't try the application file rename thing though.
>


Hey Bob,

I was actually just talking about right clicking on the .xaml file and
selecting "Rename" in the Solution Explorer, not any of the refactor
options.

Jason
My System SpecsSystem Spec
Old 01-31-2006   #6 (permalink)
Peter Johnston


 
 

Re: On the renaming of MyApp to something more descriptive...


Another thing I've noticed is that when you add a new xaml page item, the
"code-behind" file is listed as a seperate item, not a sub-item as one would
expect. Editing the project file fixes it. - this is an example of the
malformed project file:

<ItemGroup>
<ApplicationDefinition Include="MyApp.xaml" />
<Page Include="Page1.xaml" />
<Page Include="Window1.xaml" />
<Compile Include="MyApp.xaml.cs">
<DependentUpon>MyApp.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Window1.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Page1.xaml.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
.......


Peter Johnston


"Dennis Cheng [MSFT]" <dennis.cheng@online.microsoft.com> wrote in message
news:eJarAXGHGHA.3176@TK2MSFTNGP12.phx.gbl...
> Thanks for bringing this up! Yes, these are bugs that we're looking at
> right now.
>
>
> "Jason Dolinger" <jdolinger@lab49.com> wrote in message
> news:O9u1pdEHGHA.3944@tk2msftngp13.phx.gbl...
>> viliescu wrote:
>>> You have to manually change this line in the .csproj file
>>> <Page Include="CoolApp.xaml" />
>>> to
>>> <ApplicationDefinition Include="CoolApp.xaml" />
>>>
>>> ApplicationDefinition specifies the XAML file that contains the entry
>>> point for your application.

>>
>> Thanks Valentin, that did it. Although I do wonder a couple of things:
>>
>> - Why does renaming MyApp.xaml to something else change the .csproj file
>> to reference it as <Page Include=... rather than <ApplicationDefinition
>> Include=... ?
>> - Why oh why doesn't the actual class definitions in the file contents
>> get renamed along with the file name itself? ie. When you use the name
>> feature in VS, not just the .xaml and .xaml.cs files get renamed. Also:
>>
>> public partial class MyApp : Application {
>>
>> should become
>>
>> public partial class CoolApp : Application {
>>
>>
>> and <Application x:Class="MyNamespace.MyApp" ...
>>
>> should become:
>>
>> <Application x:Class="MyNamespace.CoolApp" ...
>>
>>
>> Given that this rename is something virtually all of us will have to do
>> when we are building real apps.
>>
>> Thanks,
>> Jason
>>
>>
>>

>
>



My System SpecsSystem Spec
Old 01-31-2006   #7 (permalink)
Keith Patrick


 
 

Re: On the renaming of MyApp to something more descriptive...

It'll also do that if you move MyApp anywhere via drag n drop. Took a lot
longer than I expected to find the problem, as searing for "static Main
method entry point C#" returns a suprisingly small amount of pertinent hits.


My System SpecsSystem Spec
Old 01-31-2006   #8 (permalink)
Keith Patrick


 
 

Re: On the renaming of MyApp to something more descriptive...

You can also change the build action to "Application Definition" in the
properties window to change it.


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
MyApp.exe.config vs MyApp.config .NET General
Renaming A DVD Drive? Vista General
Renaming a file Vista file management
Renaming Bug Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46