Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trace not working in a .NET DLL loaded from VB6 EXE

Tags:

c#

.net

vb.net

com

vb6

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.

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

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

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.

like image 378
Luis Avatar asked Feb 10 '10 22:02

Luis


1 Answers

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.

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

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

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.

like image 132
Mark Hurd Avatar answered Oct 17 '22 23:10

Mark Hurd