Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
225 views
in Technique[技术] by (71.8m points)

c# - Why am I unable to select a custom Type for a setting from the same project/assembly as the settings file?

I am trying to set the type of an application setting property to a custom enum type I have defined in my assembly (call this Project A)

In the settings browser I click browse and am presented with the "Select a Type" dialog box.

And the Types defined in Project A are not seem to be available to me. Yet types are available from other projects that A has referenced.

It seems almost beyond comprehension to me that one would not be able to use Types defined in the base project, so I assume I am doing something wrong. I have tried building, cleaning, rebuilding, restarting without any luck, so what exactly am I missing?

edit: screenshot here http://tinypic.com/r/2ls8myb/7

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was trying to do exactly the same thing in VS 2010 (.net 3.5). It turns out that you can do this using the Settings designer. The UI is totally flawed, as stated, but if you manually enter the fully qualified name of the enum in the Browse window it'll work. This has the benefit of not modifying generated code (*.Designer.cs), which is always good to avoid because when you do there's no guarantee that you're changes won't be overwritten.

PS - This only seems to work if the enum is public.

Settings GUI:

enter image description here

Then manually type fully-qualified type name:

enter image description here

At one point I swear I saw a drop-down of the enum values in the Value column, but I haven't seen it since and you just have to type an appropriate value in.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...