Using app.config with Interop Controls(将 app.config 与互操作控件一起使用)
问题描述
我有一个使用 app.config 的 .net 项目 (MySolution.Common).我在名为 MySolution.InteropCtrl 的 InteropUserControl 项目中使用项目 MySolution.Common.MySolution.InteropCtrl 嵌入到 VB6 项目中.当 MySolution.InteropCtrl 在 VB6 项目中时,它找不到 app.config 文件.InteropControl 中的所有内容都可以在 VB6 中使用,除了依赖于 app.config 文件中的信息的内容.我需要更改什么以便 MySolution.InteropCtrl 在 VB6 中可以看到 app.config 文件?
I have a .net project (MySolution.Common) that uses the app.config. I am using the project MySolution.Common in an InteropUserControl project called MySolution.InteropCtrl. MySolution.InteropCtrl is embedded into a VB6 project. When the MySolution.InteropCtrl is in the VB6 project, It cannot find the app.config file. Everything in the InteropControl works in VB6 except for what depends on the information in the app.config file. What do I need to change so the MySolution.InteropCtrl can see the app.config file while in VB6?
推荐答案
我对此不是 100% 确定的.但我会排除一些可能性.首先,app.config 不是文件的正确名称.虽然它是您项目中的 app.config,但它会自动重命名为 binary.exe.config 或 binary.dll.config(取决于项目类型)其中 binary 是项目的名称.
I'm not 100% sure on this. But I'll throw out some possibilities. First of all, app.config is not the correct name for the file. While it is app.config in your project, it gets auto-renamed to binary.exe.config or binary.dll.config (depending on project type) where binary is the name of the project.
其次,我不能 100% 确定 dll.config 文件是否总是在应用程序加载时被 .NET 正确加载和读取.我不相信它会自动发生,并且如果它用于 dll,则必须进行额外的调用才能读取配置文件.如果您重命名配置文件以匹配您的 exe,那么它肯定会加载并可供您使用.
Secondly, I'm not 100% sure if dll.config files are always properly loaded and read by .NET when the application loads. I don't believe it happens automatically, and that there is an extra call you have to make to read the config file if its for the dll. If you reneame the config file to match your exe, then it will definitely load and be available to you.
这篇关于将 app.config 与互操作控件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 app.config 与互操作控件一起使用
基础教程推荐
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 如果条件可以为空 2022-01-01
- 将数据集转换为列表 2022-01-01
