Visual studio add-on
-
It was pointed out to me that this is more appropriate place for this question: I'm writing a VS add-on which, on activation, is supposed to add a couple of attributes in the App.xaml. The problem I get is, when App.xaml is opened for editing, everything works fine. But, if App.xaml isn't opened the changes aren't saved. I went through the code, it still goes through it like it should, it adds the attributes like it should, it even executes the line of code that's supposed to save the changes, except... changes aren't saved This is an overview of what i do: codeState.editPoint.StartOfDocument(); string xmlText = codeState.editPoint.GetText(codeState.textDoc.EndPoint); --- add a couple of attributes using XmlDocuments --- save the changes into a memory stream codeState.editPoint.ReplaceText(codeState.textDoc.EndPoint, reader.ReadToEnd(), 0); Any ideas why?
Where it seems there are only borderlines, Where others turn and sigh, You shall rise!
-
It was pointed out to me that this is more appropriate place for this question: I'm writing a VS add-on which, on activation, is supposed to add a couple of attributes in the App.xaml. The problem I get is, when App.xaml is opened for editing, everything works fine. But, if App.xaml isn't opened the changes aren't saved. I went through the code, it still goes through it like it should, it adds the attributes like it should, it even executes the line of code that's supposed to save the changes, except... changes aren't saved This is an overview of what i do: codeState.editPoint.StartOfDocument(); string xmlText = codeState.editPoint.GetText(codeState.textDoc.EndPoint); --- add a couple of attributes using XmlDocuments --- save the changes into a memory stream codeState.editPoint.ReplaceText(codeState.textDoc.EndPoint, reader.ReadToEnd(), 0); Any ideas why?
Where it seems there are only borderlines, Where others turn and sigh, You shall rise!
rastaVnuce wrote:
Any ideas why?
If the file isn't open, you can't manipulate it like this. If you'd like to download the source to my MoXAML Power Toys[^] addin, you can find some code examples where I manipulate XAML regardless as to whether it was previously open or not (have a read of the Scrubber code to see what I mean).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
rastaVnuce wrote:
Any ideas why?
If the file isn't open, you can't manipulate it like this. If you'd like to download the source to my MoXAML Power Toys[^] addin, you can find some code examples where I manipulate XAML regardless as to whether it was previously open or not (have a read of the Scrubber code to see what I mean).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
I open the file before editing, of course. What I meant was, if the file isn't open by the user, like the user's about to edit it. Only when I open the file for editing in VS and then I activate my add-on it works. If I close the file, and activate, then it doesn't (although, I open the file programatically). Nevertheless, I'll take a look at the power toys' source, thanks.
Where it seems there are only borderlines, Where others turn and sigh, You shall rise!