via NUnit: Trace.Listeners.Add failure

  • Thread starter Thread starter Bill Cohagan
  • Start date Start date
B

Bill Cohagan

In my c# app I create a TextWriterTraceListener object and add it to the
Listeners collection via a call to Trace.Listeners.Add(...). This works
fine in my application; however it causes the unit tests to fail when the
code gets run via NUnit tests. This appears to be some kind of permissions
problem, probably related to the fact that NUnit is running my tests through
reflection, but I don't have a clue how to proceed. Any suggestions or
pointers would be appreciated...

The error that is thrown is:

c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config Request
for the permission of type
System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
(c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config)

and the stack trace is:at System.Configuration.ConfigurationRecord.OpenXmlTextReader(String
configFileName)
at System.Configuration.ConfigurationRecord.Load(String filename)
at
System.Configuration.DefaultConfigurationSystem.System.Configuration.IConfig
urationSystem.Init()
at
System.Configuration.ConfigurationSettings.SetConfigurationSystem(IConfigura
tionSystem configSystem)
at System.Configuration.ConfigurationSettings.GetConfig(String
sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetConfigTable()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
at System.Diagnostics.TraceInternal.InitializeSettings()
at System.Diagnostics.TraceInternal.get_Listeners()
at System.Diagnostics.Trace.get_Listeners()
at gptg.QAtoQB.Transactions.Transaction.DumpLog(StreamWriter sw) in
c:\working barrel\tq finint\qatoqb\transactions\transactions.cs:line 46
at gptg.QAtoQB.Transactions.ProcessModel.SaveIIF() in c:\working
barrel\tq finint\qatoqb\transactions\processmodel.cs:line 168
at gptg.QAtoQB.Tests.IIFTests.BillableTime() in c:\working barrel\tq
finint\qatoqb\tests\iiftests.cs:line 29
 
Hello Bill,

Thanks for your response. Would you please tell me what version of the
Framework is your code compiled against?

I found a similar issue when the code was compiled against v1.1 and NUnit
is compiled against v1.0, it was resolved by adding the following to the
NUnit config file:

<startup>
<supportedRuntime version="v1.1.4322" />
</startup>

Please check it on your side. In addition, NUnit is a third-party
component, I recommend you also contact NUnit directly at
<http://www.nunit.org/contactUs.html>.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
HuangTM-
Thanks for the suggestion. Yes, I am running my app under 1.1, but I'll
have to investigate to determine whether NUnit was compiled under 1.0.

Bill
 
HuangTM

Thanks again, You were correct regarding the config file. Adding support
for the 1.1 framework solves the problem.

Regads,
Bill
 
Back
Top