One of the requirements is that the text for the categories are in a resource DLL. Unfortunately, these aren't natively supported by the .Net framework. You have to manually create the files, compile them with two compilers and then link it into the DLL. Even though it consisted of several steps, it still seemed pretty straight forward based on the details on MSDN. Following the instructions, I created a simple .mc file and tried compiling it with mc.
The Message Compiler emitted a bunch of errors:
- invalid character (0x29)
- invalid character (0x57)
- invalid character (0x10)
- Invalid message file token
Of course I really wanted to edit the file in Visual Studio and so made a change to the newly edited file and saved it. VS kindly put the BOM right back in. It can be so annoyingly helpful. Yet more searching for a means of eliminating the BOM didn't reveal anything that I wanted to use. I found a script or two that I could install in the IDE, but I didn't want to force the rest of the team to have to do this. The more environmental things that have to be configured and maintained, the harder it is to setup a new development machine. After a bit of pouring through VS's Tool | Options, I found Text Editor | File Extensions. This allows you to define which editor to use for a given file type. I added the .mc extension and told it to use the User Control Editor. Sure enough, this editor didn't put the BOM in the file. While not ideal for the team environment, it is better than a script.
So, these were some of the lessons I learned today working with Message Text Files and the Message Compiler. I hope it helps someone else.
5 comments:
Thanks for sharing your post and it was superb .I would like to hear more from you in future too.
Regards:
Inventory Management Software
Thanks. I'm glad you found it useful.
This doesn't seem to work for me (in Visual Studio 2010). The User Control Editor does the same thing. I can clear out a .mc text file with "cat NUL: >test.mc" and it will run through the compiler, but as soon as I reload it (an empty file!) in VS2010 and hit Ctrl+S to save it (again, empty)... it adds the characters back in. I'm thinking I'm going to have to write a console app just to strip them out! By the way, before I found your post I too resorted to the old DOS edit command to create a clean file. I wonder how many programmers these days even know about edit.
Finally found out how to get VS2010 to save without BOM. You do a "Save As" and click the drop-down on the Save button. Select "Save with Encoding..." then change the Encoding to "Unicode (UTF-8 without signature) - Codepage 65001" and click Ok. FINALLY!
Cool. Thanks for the update Tom.
Post a Comment