config与Interop控件一起使用

config与Interop控件一起使用

本文介绍了将app.config与Interop控件一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用app.config的.net项目(MySolution.Common).我在名为MySolution.InteropCtrl的InteropUserControl项目中使用项目MySolution.Common. MySolution.InteropCtrl嵌入到VB6项目中.当MySolution.InteropCtrl在VB6项目中时,它找不到app.config文件.除了依赖于app.config文件中信息的内容之外,InteropControl中的所有内容都可以在VB6中使用.我需要更改什么才能使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与Interop控件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:26