跟踪在从 VB6 EXE 加载的 .NET DLL 中不起作用

Trace not working in a .NET DLL loaded from VB6 EXE(跟踪在从 VB6 EXE 加载的 .NET DLL 中不起作用)

本文介绍了跟踪在从 VB6 EXE 加载的 .NET DLL 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个写入 Trace 的 .NET DLL.但似乎当我从 VB6 EXE 调用我的 DLL 时,跟踪不起作用.

I have a .NET DLL that writes to the Trace. But it seems that when I call my DLL from a VB6 EXE the trace is not working.

我在 EXE 文件夹中创建了一个 myApp.config 文件,其中包含跟踪配置,但这并不能解决问题.

I have created an myApp.config file in the EXE folder with the trace configuration, but this does not solve the issue.

我也尝试在代码中创建 Trace 对象,但不起作用:

I've also tried creating the Trace objects in code, but doesn't work:

Dim _traceSrc As TraceSource = New TraceSource("myTraceSorce")
Dim flListener As FileLogTraceListener = New FileLogTraceListener("myFileLogTraceListener")
Dim tSwitch As SourceSwitch = New SourceSwitch("mySwitch")
tSwitch.Level = _logLevel

如果我从 .NET EXE 调用我的 DLL,即使我在 EXE 文件夹中没有 app.config,它也可以工作,因为如果找不到配置,我会在代码中设置它.

If I call my DLL from a .NET EXE it works, even if I dont have the app.config in the EXE folder, because I set it in code if the config is not found.

推荐答案

如果您的 VB6 应用程序名为 MyApp.exe,则配置文件应名为 MyApp.exe.config.(MyApp.config 有时也可以工作,具体取决于 .NET Framework 版本和服务包.)

If your VB6 application is called MyApp.exe then the config file should be called MyApp.exe.config. (MyApp.config does also work sometimes depending upon .NET Framework versions and service packs.)

在该配置文件中,您的设置应该可以工作.

Inside that config file your settings should work.

我在通过 COM 从 VB6 运行的代码中进行了跟踪,运行良好.

I have tracing in my code running from VB6 via COM that is working fine.

在运行 VB6 代码时,您的权限是否会有所不同?

Also is there any chance your privileges are different when running the VB6 code?

最后,如果您在 VB6 IDE 中调试 VB6 应用程序,您需要将设置添加到 VB6.exe 文件夹中的 VB6.exe.config 中,然后重新启动 VB6 以确保更改被注意到了.

Finally, if you're debugging the VB6 app in the VB6 IDE you need to add the settings to the VB6.exe.config in the VB6.exe folder, and restart VB6 to ensure changes are noticed.

这篇关于跟踪在从 VB6 EXE 加载的 .NET DLL 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:跟踪在从 VB6 EXE 加载的 .NET DLL 中不起作用