将 LINQ 添加到 SQL 后 Properties.Settings 不明确
我最近通过在解决方案中创建 LINQ to SQL 项,将数据库链接到我的 C# 服务。当我继续编码时,一切都很好,但后来我突然注意到有 16 个歧义错误。例如
Ambiguity between 'EmailService.Properties.Settings.defaultInstance' and 'EmailService.Properties.Settings.defaultInstance'
,数据库文件决定创建它自己的Setting.Designer.cs;现在,我的 Properties 文件夹中有一个 Settings.Designer.cs 和一个 Settings1.Designer.cs (由 LINQ to SQL 文件创建)。
无论如何,我是否可以更改数据库文件引用其设置的位置,以便删除重复项?
I have recently linked a database to my C# service by creating a LINQ to SQL item in my solution. Everything was fine and dandy as I was continuing to code, but then I suddenly noticed that there where 16 Ambiguity errors. e.g.
Ambiguity between 'EmailService.Properties.Settings.defaultInstance' and 'EmailService.Properties.Settings.defaultInstance'
What happened was that the database file decided to create it's own Setting.Designer.cs; So now I have a Settings.Designer.cs and a Settings1.Designer.cs (which was created by the LINQ to SQL file) in my Properties folder.
Is there anyway that I can change where the database file is referencing its settings so I can delete the duplicate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我手动修复了它。
我必须使用查找和替换来替换引用 Settings1.settings 的所有实例,因为我无法使用重构;然后我不得不删除 Settings1.settings 文件。
但是,您必须确保不会错过引用,否则在重建解决方案时将自动生成另一个 Settings1.settings。
I fixed it manually.
I had to use find and replace to replace all instances that were referencing to Settings1.settings since I couldn't use refactoring; then I had to delete the Settings1.settings file.
You must however make sure that you do not miss a reference otherwise another Settings1.settings will be automatically generated when you rebuild your solution.
我删除了 Settings1 文件,这似乎已经成功了......
I deleted Settings1 file and that seemed to have done the trick...
在 dbml 设计器的 DataContext 属性中,有一个选项可以使用默认启用的应用程序设置。如果设置为 false,将不再生成设置类。
In the dbml designer, in the DataContext properties, there's an option to use app settings that's enabled by default. If you set it to false, it will no longer generate the settings class.