开发者

Visual Studio 2008 likes to insert random strings into my code

Here's the setup:

I have some controls with text fields that I wish to be blank. So I might have, in my designer file:

someControl.HeaderText = ""

or

someControl.HeaderText = Properties.Resources.blank_string

THis only seems to happen when i'm trying to specify a blank string for a text or headertext property to a control.

If I open up the designer file (perhaps becuase I was searching something) and close/save all, VS will sometimes replace my "" or Properties.Resources.blank_string

with:

global::ProjNameSpace.Properties.Resources."SomethingCompletelyRandomHere!!!!"

Awesome!

I sometimes won't catch this until I start screwing around with my application and notice strange strings showing up in places where there should be none.

WHY is this happening?

Actually, what I think it's doing is a replace. I have a bunch of entries in my default string resources file that are all blank (populated ones are the in the translated resource files). So I think it's going through and finding "" or blank strings and just saying, "hey, looks like u got some other blank strings in this resource file, let's开发者_高级运维 just swap this one with this one, Cool! I'm Microsoft!"


You shouldn't be editing the designer file. It's auto generated and visual studio will happily clobber anything you put in there.

if something needs to be blank either set the default values in the .aspx/.ascx file or in your codebehind.

As a matter of fact, all the designer files i've seen start off with:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.4927
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜