471,603 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

Code generator output opens in notepad

I found the excellent article by Paulo Reichert at http://blogs.conchango.com/pauloreic...5/21/1459.aspx,
which shows how to build a code generator for Visual Studio 2005. I followed
this and made a small generator that output a dummy file containing only
this:

namespace TestNamespace { public class TestClass { } }

This works nicely. The namespace and class is available in the project and
I can compile it and check that it's present via Reflector.

However, if in the solution explorer I make it show all the files so I can
see my generated file and double-click on that file, it opens up in Notepad,
whereas the Settings.Designer.cs file opens up inside Visual Studio.

Additionally, if I right-click on Settings.Designer.cs and selects View Code,
the file opens up in VS, but if I do the same on mine I get this error message:

---------------------------
Microsoft Visual Studio
---------------------------
There is no editor available for 'D:\Dev\VS.NET\WindowsApplication113\WindowsApplic ation113\test.Designer.cs'.

Make sure the application for the file type (.cs) is installed.
---------------------------
OK
---------------------------

I'm not sure what, if anything, to do about this.

Opening up both of these files in a binary editor shows me that the Settings.Designer.cs
file got BOM at the start but mine doesn't, probably because I chose UTF-8
encoding.

If anyone got any advice, please let me know. I can post the project if anyone
wants to look at it, but a "short and complete example" can't be shown in
this post.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Feb 16 '06 #1
1 3176
> I found the excellent article by Paulo Reichert at
http://blogs.conchango.com/pauloreic...5/21/1459.aspx,
which shows how to build a code generator for Visual Studio 2005. I
followed this and made a small generator that output a dummy file
containing only this:

namespace TestNamespace { public class TestClass { } }

This works nicely. The namespace and class is available in the project
and I can compile it and check that it's present via Reflector.

However, if in the solution explorer I make it show all the files so I
can see my generated file and double-click on that file, it opens up
in Notepad, whereas the Settings.Designer.cs file opens up inside
Visual Studio.


Ok, the answer was simple. I used a MemoryStream internally and had used
..GetBuffer() instead of .ToArray(), which meant that the output, and thus
the file, contained 0-bytes at the end, no doubt throwing off Visual Studio.

I fixed that and now it worked nicely.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2

Feb 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bob | last post: by
16 posts views Thread by Tran Tuan Anh | last post: by
10 posts views Thread by linhardt | last post: by
3 posts views Thread by Sander Tekelenburg | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.