将 app.config 与互操作控件一起使用 [英] Using app.config with Interop Controls

查看:25
本文介绍了将 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 与互操作控件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆