How to configure logging in Spring.NET using log4net? - log4net

I would like use from Spring.NET Aspect library Logging aspect together with log4Net.
I found this article how to use log4Net with Common Logging API.
My test application is console and based on .NET 4.0 Client profile.
1st Attempt
So I refer in my project these libraries:
Spring.Core version 1.3.2.40943, runtime v4.0.30319
Spring.AOP version 1.3.2.40943, runtime v4.0.30319
Common.Logging version: 1.2.0.0, runtime v1.0.3705
Assemblies above I have from Program Files\Spring.NET 1.3.2\bin\net\4.0
log4net version: 1.2.10.0, runtime v2.0.50727
I couldn’t find assembly Common.Logging.Log4Net.dll in Program Files\Spring.NET 1.3.2\bin
\net\4.0 so I download this assembly from SourceForge:
Common.Logging.Log4Net version 2.0.0.0 runtime v2.0.50727
I configured logger in app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
<logger name="myLogger">
<level value="DEBUG" />
</logger>
</log4net>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
</objects>
</spring>
</configuration>
and tried this:
ILog log = LogManager.GetLogger("myLogger");
log.Error("hello world");
I got this runtime error:
{"Could not configure Common.Logging from configuration section
'common/logging'."}
Inner exception:
{"An error occurred creating the configuration section handler for
common/logging: Unable to create type
'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,
Common.Logging.Log4Net' (E:\C#
PROJECTS\STUDY\SPRING.NET\SpringNet.Aspects\LoggingWithLog4Net\bin\Debug\LoggingWithLog4Net.vshost.exe.Config
line 18)"}
StackTrace:
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[]
keys, SectionInput input, Boolean isTrusted, FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult) at
System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult,
Boolean getLkg, Boolean getRuntimeObject, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSection(String
configKey) at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName) at
System.Configuration.ConfigurationManager.GetSection(String
sectionName) at
System.Configuration.ConfigurationSettings.GetConfig(String
sectionName) at
Common.Logging.ConfigurationReader.GetSection(String sectionName)
at Common.Logging.LogManager.BuildLoggerFactoryAdapter()
2nd Attempt
I think problem must be in version of assembly Common.Logging.Log4Net version 2.0.0.0 runtime v2.0.50727. Because I used Common.Logging version: 1.2.0.0, runtime v1.0.3705.
So I changed Common.Logging version from 1.2.0.0 to 2.0.0.0. I used Common.Logging from SourceForge.
And tested again. I got this error:
Unable to create type
'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,
Common.Logging.Log4Net'
Inner exception:
{"Could not load file or assembly 'Common.Logging.Log4Net' or one of
its dependencies. The system cannot find the file
specified.":"Common.Logging.Log4Net"}
StackTrace:
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean
throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMarkHandle stackMark, Boolean loadTypeFromPartialName,
ObjectHandleOnStack type) at
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean
throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) at
System.RuntimeType.GetType(String typeName, Boolean throwOnError,
Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean
ignoreCase) at
Common.Logging.ConfigurationSectionHandler.ReadConfiguration(XmlNode
section) in
c:\CCNet\netcommon\trunk\modules\Common.Logging\src\Common\Common.Logging\Logging\ConfigurationSectionHandler.cs:line
130
3rd and last attempt
Finally I found assembly Common.Logging.Log4Net version 1.2.0.2 in spring examples so I used it.
Common.Logging.Log4Net version 1.2.0.2
Common.Logging version 1.2.0.0
log4Net 1.2.10.0
Tested and got again error:
{"Could not configure Common.Logging from configuration section
'common/logging'."}
Inner exception:
{"An error occurred creating the configuration section handler for
common/logging: Unable to create type
'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,
Common.Logging.Log4Net' (E:\C#
PROJECTS\STUDY\SPRING.NET\SpringNet.Aspects\LoggingWithLog4Net\bin\Debug\LoggingWithLog4Net.vshost.exe.Config
line 18)"}
StackTrace:
{"Unable to create type
'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,
Common.Logging.Log4Net'"}
I am really confuse what I do bad? Some problem with assemblies version?

For Spring.NET 1.3.2 you should use:
Common.Logging 2.0.0
Common.Logging.Log4Net 2.0.0
log4net 1.2.10
Make sure the last two log4net dll's are copied to the output directory. Since your code doesn't reference it directly, they might not be copied by Visual Studio.

Also, instead of
<resource uri="config://springs/objects"/>
Try
<resource uri="config://spring/objects"/>
In your config file the sectionGroup name is "spring", NOT "springs". I copied from yours to make mine work and got in the same problem. Finally figured out why.
Hope that helps!

Another possibility is:
Common.Logging 2.1.1
Common.Logging.Log4Net 2.1.1
log4net 1.2.10
I recommend skipping Common.Logging 2.1.0 as it did throw this exception when reading perfectly valid app.config section:
"Unable to cast object of type 'System.Configuration.DefaultSection' to type 'System.Configuration.AppSettingsSection'."
Installing 2.1.1 fixed the problem.

Related

Vs Test Failing with 3 errors on Azure Dev Ops Running nUnitTest

I'm using VsTest to run my nUnit test on azure dev ops and getting failures. This runs fine on my local machine but not in the Azure DevOps Release. Here is are errors i'm seeing from the log. Its not giving me much to go off of to track what could be wrong. I thought it might be something in my .runsettings file but this is the same file I use locally which is fine. There are to data collectors that is used by my runsettings file that uses code coverage and the video recorder. I dont know if this is what might be causing the test to fail. If i do want to use that and that might be whats causing is is there a way to download these dlls for the server to use or does these get automatically downloaded with vs tool installer?
Here is the current Task
Copy Files to: $(System.DefaultWorkingDirectory) - succeeds
Visual Studio Test Platform Installer - Installs VS 2017 - succeeds
VSTest - I choose test plan - - Fails
- select test platform to - Installed by Tools Installer
- I select path to my .runsettings file
- I give the override test run parameters
- I check Code coveraged enabled
here is the error i received
Unhandled exception : System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
TestExecution encountered unexpected failures System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Error: The process 'E:\Agent_work_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 3762504530
2021-05-07T14:52:00.1569206Z QueryForTaskIntervalInMilliseconds: 3000
2021-05-07T14:52:00.1570380Z MaxQueryForTaskIntervalInMilliseconds: 10000
2021-05-07T14:52:00.1571576Z QueueNotFoundDelayTimeInMilliseconds: 3000
2021-05-07T14:52:00.1598093Z MaxQueueNotFoundDelayTimeInMilliseconds: 50000
2021-05-07T14:52:00.1606607Z ===========================================
2021-05-07T14:52:01.2928251Z Result Attachments will be stored in LogStore
2021-05-07T14:52:01.3427529Z Run Attachments will be stored in LogStore
2021-05-07T14:52:01.8892467Z TestExecutionHost.Execute: Registered TestAgent : 798 : VS2VST05-VS2VST05i-41
2021-05-07T14:52:01.9062609Z Provided settings file:
2021-05-07T14:52:01.9079246Z <?xml version="1.0" encoding="utf-8"?>
2021-05-07T14:52:01.9079831Z <RunSettings>
2021-05-07T14:52:01.9080157Z <!-- Configurations that affect the Test Framework -->
2021-05-07T14:52:01.9084373Z <RunConfiguration>
2021-05-07T14:52:01.9084552Z <MaxCpuCount>1</MaxCpuCount>
2021-05-07T14:52:01.9084824Z <!-- Path relative to directory that contains .runsettings file-->
2021-05-07T14:52:01.9085105Z <ResultsDirectory>.\TestResults</ResultsDirectory>
2021-05-07T14:52:01.9085266Z
2021-05-07T14:52:01.9085400Z <!-- x86 or x64 -->
2021-05-07T14:52:01.9085703Z <!-- You can also change it from the Test menu; choose "Processor Architecture for AnyCPU Projects" -->
2021-05-07T14:52:01.9086015Z <TargetPlatform>x86</TargetPlatform>
2021-05-07T14:52:01.9086158Z
2021-05-07T14:52:01.9086337Z <!-- Framework35 | [Framework40] | Framework45 -->
2021-05-07T14:52:01.9086627Z <TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
2021-05-07T14:52:01.9087680Z
2021-05-07T14:52:01.9087850Z <!-- Path to Test Adapters -->
2021-05-07T14:52:01.9088095Z <TestAdaptersPaths>%SystemDrive%\Temp\foo;</TestAdaptersPaths>
2021-05-07T14:52:01.9088519Z <!-- TestSessionTimeout was introduced in Visual Studio 2017 version 15.5 -->
2021-05-07T14:52:01.9088858Z <!-- Specify timeout in milliseconds. A valid value should be greater than 0 -->
2021-05-07T14:52:01.9089157Z <TestSessionTimeout>15000000</TestSessionTimeout>
2021-05-07T14:52:01.9089420Z <TreatNoTestsAsError>true</TreatNoTestsAsError>
2021-05-07T14:52:01.9089626Z </RunConfiguration>
2021-05-07T14:52:01.9089822Z <!-- Configurations for data collectors -->
2021-05-07T14:52:01.9090027Z <DataCollectionRunSettings>
2021-05-07T14:52:01.9090210Z <DataCollectors>
2021-05-07T14:52:01.9090804Z <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
2021-05-07T14:52:01.9091620Z <Configuration>
2021-05-07T14:52:01.9092022Z <CodeCoverage>
2021-05-07T14:52:01.9092187Z <ModulePaths>
2021-05-07T14:52:01.9092348Z <Exclude>
2021-05-07T14:52:01.9092562Z <ModulePath>.*CPPUnitTestFramework.*</ModulePath>
2021-05-07T14:52:01.9092794Z </Exclude>
2021-05-07T14:52:01.9092955Z </ModulePaths>
2021-05-07T14:52:01.9093227Z <!-- We recommend you do not change the following values: -->
2021-05-07T14:52:01.9093579Z <UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
2021-05-07T14:52:01.9093914Z <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
2021-05-07T14:52:01.9094217Z <CollectFromChildProcesses>True</CollectFromChildProcesses>
2021-05-07T14:52:01.9094530Z <CollectAspDotNet>False</CollectAspDotNet>
2021-05-07T14:52:01.9094757Z </CodeCoverage>
2021-05-07T14:52:01.9094927Z </Configuration>
2021-05-07T14:52:01.9095114Z </DataCollector>
2021-05-07T14:52:01.9095793Z <DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
2021-05-07T14:52:01.9096694Z <!--Video data collector was introduced in Visual Studio 2017 version 15.5 -->
2021-05-07T14:52:01.9096989Z <Configuration>
2021-05-07T14:52:01.9097297Z <!-- Set "sendRecordedMediaForPassedTestCase" to "false" to add video attachments to failed tests only -->
2021-05-07T14:52:01.9097917Z <MediaRecorder sendRecordedMediaForPassedTestCase="false" xmlns=""> ​
2021-05-07T14:52:01.9098305Z <ScreenCaptureVideo bitRate="512" frameRate="2" quality="20" />​
2021-05-07T14:52:01.9098560Z </MediaRecorder>​
2021-05-07T14:52:01.9100157Z </Configuration>
2021-05-07T14:52:01.9100322Z </DataCollector>
2021-05-07T14:52:01.9100532Z <DataCollector friendlyName="blame" enabled="True">
2021-05-07T14:52:01.9100746Z </DataCollector>
2021-05-07T14:52:01.9100925Z </DataCollectors>
2021-05-07T14:52:01.9101487Z </DataCollectionRunSettings>
2021-05-07T14:52:01.9101720Z <!-- Parameters used by tests at run time -->
2021-05-07T14:52:01.9101885Z
2021-05-07T14:52:01.9102041Z <!-- MSTest adapter -->
2021-05-07T14:52:01.9102188Z <NUnit>
2021-05-07T14:52:01.9102371Z <InternalTraceLevel>Error</InternalTraceLevel>
2021-05-07T14:52:01.9102554Z </NUnit>
2021-05-07T14:52:01.9102666Z
2021-05-07T14:52:01.9102782Z </RunSettings>
2021-05-07T14:52:01.9393681Z Overriding UseVerifiableInstrumentation field to false in the runsettings file.
2021-05-07T14:52:01.9550200Z IsValidServiceResponse: Received None command..Service Workflow is not active
2021-05-07T14:52:02.0476240Z ##[error]Unhandled exception : System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
2021-05-07T14:52:02.0485692Z at Microsoft.VisualStudio.TestService.SettingsManager.DiagnosticsSettingsProcessor.ProcessSettings(XDocument settings)
2021-05-07T14:52:02.0486290Z at Microsoft.VisualStudio.TestService.SettingsManager.CommonSettingsManager.UpdateCommonSettings(InputDataContract inputDataContract, SettingsModifier settingsModifier)
2021-05-07T14:52:02.0486843Z at Microsoft.VisualStudio.TestService.SettingsManager.SettingsManager.UpdateSettingsAsRequired(InputDataContract inputDataContract)
2021-05-07T14:52:02.0487361Z at Microsoft.VisualStudio.TestService.VstestAdapter.SetupPhase.Run(ExecutionStateContext stateModelContext, CancellationToken cancellationToken)
2021-05-07T14:52:02.0487776Z at System.Threading.Tasks.Task`1.InnerInvoke()
2021-05-07T14:52:02.0488008Z at System.Threading.Tasks.Task.Execute()
2021-05-07T14:52:02.0488240Z --- End of inner exception stack trace ---
2021-05-07T14:52:02.0488490Z at System.AggregateException.Handle(Func`2 predicate)
2021-05-07T14:52:02.0488905Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.ExecuteCurrentPhase(CancellationToken cancellationToken)
2021-05-07T14:52:02.0489423Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.Execute(CancellationToken cancellationToken)
2021-05-07T14:52:02.0489864Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.Start()
2021-05-07T14:52:02.0490324Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.DistributedTestRunHost.InitializeAndStartExecutionHost(Boolean debugLogs)
2021-05-07T14:52:02.0490784Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.DistributedTestRunHost.Execute(Boolean debugLogs)
2021-05-07T14:52:02.0491382Z ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
2021-05-07T14:52:02.0491868Z at Microsoft.VisualStudio.TestService.SettingsManager.DiagnosticsSettingsProcessor.ProcessSettings(XDocument settings)
2021-05-07T14:52:02.0492404Z at Microsoft.VisualStudio.TestService.SettingsManager.CommonSettingsManager.UpdateCommonSettings(InputDataContract inputDataContract, SettingsModifier settingsModifier)
2021-05-07T14:52:02.0492953Z at Microsoft.VisualStudio.TestService.SettingsManager.SettingsManager.UpdateSettingsAsRequired(InputDataContract inputDataContract)
2021-05-07T14:52:02.0493484Z at Microsoft.VisualStudio.TestService.VstestAdapter.SetupPhase.Run(ExecutionStateContext stateModelContext, CancellationToken cancellationToken)
2021-05-07T14:52:02.0493867Z at System.Threading.Tasks.Task`1.InnerInvoke()
2021-05-07T14:52:02.0494108Z at System.Threading.Tasks.Task.Execute()<---
2021-05-07T14:52:02.0494260Z
2021-05-07T14:52:02.1579135Z ##[error]TestExecution encountered unexpected failures System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
2021-05-07T14:52:02.1581938Z at Microsoft.VisualStudio.TestService.SettingsManager.DiagnosticsSettingsProcessor.ProcessSettings(XDocument settings)
2021-05-07T14:52:02.1583067Z at Microsoft.VisualStudio.TestService.SettingsManager.CommonSettingsManager.UpdateCommonSettings(InputDataContract inputDataContract, SettingsModifier settingsModifier)
2021-05-07T14:52:02.1584187Z at Microsoft.VisualStudio.TestService.SettingsManager.SettingsManager.UpdateSettingsAsRequired(InputDataContract inputDataContract)
2021-05-07T14:52:02.1585236Z at Microsoft.VisualStudio.TestService.VstestAdapter.SetupPhase.Run(ExecutionStateContext stateModelContext, CancellationToken cancellationToken)
2021-05-07T14:52:02.1587079Z at System.Threading.Tasks.Task`1.InnerInvoke()
2021-05-07T14:52:02.1587869Z at System.Threading.Tasks.Task.Execute()
2021-05-07T14:52:02.1588636Z --- End of inner exception stack trace ---
2021-05-07T14:52:02.1589413Z at System.AggregateException.Handle(Func`2 predicate)
2021-05-07T14:52:02.1590350Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.ExecuteCurrentPhase(CancellationToken cancellationToken)
2021-05-07T14:52:02.1591492Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.Execute(CancellationToken cancellationToken)
2021-05-07T14:52:02.1591974Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.Start()
2021-05-07T14:52:02.1593219Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.DistributedTestRunHost.InitializeAndStartExecutionHost(Boolean debugLogs)
2021-05-07T14:52:02.1594214Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.DistributedTestRunHost.Execute(Boolean debugLogs)
2021-05-07T14:52:02.1595156Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.Program.Main(String[] args)
2021-05-07T14:52:02.1596244Z ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
2021-05-07T14:52:02.1597231Z at Microsoft.VisualStudio.TestService.SettingsManager.DiagnosticsSettingsProcessor.ProcessSettings(XDocument settings)
2021-05-07T14:52:02.1597806Z at Microsoft.VisualStudio.TestService.SettingsManager.CommonSettingsManager.UpdateCommonSettings(InputDataContract inputDataContract, SettingsModifier settingsModifier)
2021-05-07T14:52:02.1607075Z at Microsoft.VisualStudio.TestService.SettingsManager.SettingsManager.UpdateSettingsAsRequired(InputDataContract inputDataContract)
2021-05-07T14:52:02.1608570Z at Microsoft.VisualStudio.TestService.VstestAdapter.SetupPhase.Run(ExecutionStateContext stateModelContext, CancellationToken cancellationToken)
2021-05-07T14:52:02.1609155Z at System.Threading.Tasks.Task`1.InnerInvoke()
2021-05-07T14:52:02.1610029Z at System.Threading.Tasks.Task.Execute()<---
2021-05-07T14:52:02.1610221Z
2021-05-07T14:52:02.1612560Z
2021-05-07T14:52:02.1613028Z Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
2021-05-07T14:52:02.1614180Z at Microsoft.VisualStudio.TestService.SettingsManager.DiagnosticsSettingsProcessor.ProcessSettings(XDocument settings)
2021-05-07T14:52:02.1614742Z at Microsoft.VisualStudio.TestService.SettingsManager.CommonSettingsManager.UpdateCommonSettings(InputDataContract inputDataContract, SettingsModifier settingsModifier)
2021-05-07T14:52:02.1620575Z at Microsoft.VisualStudio.TestService.SettingsManager.SettingsManager.UpdateSettingsAsRequired(InputDataContract inputDataContract)
2021-05-07T14:52:02.1621740Z at Microsoft.VisualStudio.TestService.VstestAdapter.SetupPhase.Run(ExecutionStateContext stateModelContext, CancellationToken cancellationToken)
2021-05-07T14:52:02.1622351Z at System.Threading.Tasks.Task`1.InnerInvoke()
2021-05-07T14:52:02.1625627Z at System.Threading.Tasks.Task.Execute()
2021-05-07T14:52:02.1626144Z --- End of inner exception stack trace ---
2021-05-07T14:52:02.1626519Z at System.AggregateException.Handle(Func`2 predicate)
2021-05-07T14:52:02.1627028Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.ExecuteCurrentPhase(CancellationToken cancellationToken)
2021-05-07T14:52:02.1627670Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.Execute(CancellationToken cancellationToken)
2021-05-07T14:52:02.1629545Z at Microsoft.VisualStudio.TestService.ExecutionStateModel.DistributedTestExecutionAgent.Start()
2021-05-07T14:52:02.1630375Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.DistributedTestRunHost.InitializeAndStartExecutionHost(Boolean debugLogs)
2021-05-07T14:52:02.1631959Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.DistributedTestRunHost.Execute(Boolean debugLogs)
2021-05-07T14:52:02.1632811Z at Microsoft.VisualStudio.TestService.AgentExecutionHost.Program.Main(String[] args)
2021-05-07T14:52:02.1866126Z ##[error]Error: The process 'E:\Agent\_work\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 3762504530
2021-05-07T14:52:02.1874141Z ##[section]Finishing: VsTest - testPlan
Here is the Yaml file
steps:
task: CopyFiles#2
displayName: 'Copy Files to: $(System.DefaultWorkingDirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/_Atlas Automation (Agile) CI 2020/drop/Atlas_Automation_Test/Atlas_Automation_Test/bin/Release'
Contents: |
*.testsettings
*.runsettings
TargetFolder: '$(System.DefaultWorkingDirectory)'
CleanTargetFolder: true
OverWrite: true
flattenFolders: true

Acumatica TestSDK_17_207_0029_18 Failure to generate wrappers

I am following the documentation for Part1: General Ledger and Cash Management where you are instructed to run the Classgenerator.exe.
Expected results: Page Wrappers successfully generated
Actual results: System.AppDomainUnloadedException: The application domain in which the thread was running has been unloaded.
I have verified my ClassGenerator.exe.config to be correct.
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="SitePhysicalPath" value="E:\Program Files (x86)\Acumatica ERP\960 Instances\AcumaticaIntegrations"/>
<add key="GenResultPath" value="C:\SDK\ClassGenerator\Out"/>
<add key="Username" value="admin#Company"/>
<add key="Namespace" value="GeneratedWrappers.Acumatica"/>
<add key="ClearOutput" value="true"/>
<add key="FilenameFilter" value="CS100000, CS102000, CM202000, GL201500, CS202000, GL202500, GL102000, GL101000, GL201000"/>
<!--<add key="PagesList" value="list.txt"/>
<add key="PagesListAttribute" value="exclude"/>
<add key="PagesListAttribute" value="include"/>
<add key="PagesParameters" value="ParamsPP.txt"/>
<add key="GenericInquiryParameters" value="ParamsGI.txt"/>-->
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
</startup>
</configuration>
Every time I try to run the class Generator exe I get this error.
C:\Users\jonat\Downloads\TestSDK_17_207_0029_18\ClassGenerator>ClassGenerator.exe
System.AppDomainUnloadedException: The application domain in which the thread was running has been unloaded.
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ApplicationManager.CreateInstanceInNewWorkerAppDomain(Type type, String appId, VirtualPath virtualPath, String physicalPath)
at System.Web.Hosting.ApplicationHost.CreateApplicationHost(Type hostType, String virtualDir, String physicalDir)
at ClassGenerator.ScreenExtractor.GetProxy() in E:\Bld\AC-TESTSDK2017R207-JOB1\tests\Selenium\ClassGenerator\ClassGenerator\ScreenExtractor.cs:line 64
at ClassGenerator.ScreenExtractor..ctor(String virtualPath, String sitePhysicalPath, String genResultPath, String username, String namespace, String postfix, Boolean correctCTL01) in E:\Bld\AC-TESTSDK2017R207-JOB1\tests\Selenium\ClassGenerator\ClassGenerator\ScreenExtractor.cs:line 28
at ClassGenerator.ClassGenerator.Run() in E:\Bld\AC-TESTSDK2017R207-JOB1\tests\Selenium\ClassGenerator\ClassGenerator\ClassGenerator.cs:line 177
at ClassGenerator.Launcher.Main(String[] args) in E:\Bld\AC-TESTSDK2017R207-JOB1\tests\Selenium\ClassGenerator\ClassGenerator\Launcher.cs:line 11
Has anyone else encountered this issue? Thank you in advanced.

ArgumentOutOfRangeException on Azure RemoteForwarder Plugin

I currently have an Azure CloudService running and when I check the 'WADDiagnosticInfrastructureLogsTable', there is an error coming out every minute.
The details are as the following.
Exception:
System.ArgumentOutOfRangeException:
Length cannot be less than zero.
Parameter name: lengthServer
stack trace:
at System.String.Substring(Int32 startIndex, Int32 length)
at Microsoft.WindowsAzure.Plugins.RemoteForwarder.RdpRemoteEndpointFinder.GetRemoteEndpoint(Socket clientSocket, Stream peekBuffer)Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.WindowsAzure.Plugins.RemoteForwarder.IRemoteEndpointFinder.GetRemoteEndpoint(Socket clientSocket, Stream peekBuffer)
at Microsoft.WindowsAzure.Plugins.RemoteForwarder.RemoteForwardingService.ClientConnected(Object sender, ConnectionEventArgs e)
at Microsoft.WindowsAzure.Plugins.RemoteForwarder.TcpSocketServer.OnClientConnected(ConnectionEventArgs e)
CloudService Config:
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="*** omitted intentionally ***" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="*** omitted intentionally ***" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2017-11-04T23:59:59.0000000+09:00" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
</ConfigurationSettings>
Azure SDK Version:
v2.9.6
Any one have an idea what's wrong?
Thanks in advance.

Azure: Failed to send bytes to XContainer wad-tracefiles

For some reason I get errors while using Diagnostics in Azure. The code of my (WCF) WebRole is:
public override bool OnStart()
{
// To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config
DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());
diagnosticConfig.Directories.BufferQuotaInMB = 256;
// Start diagnostics
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfig);
// Write trace line
Trace.WriteLine("CUSTUM TRACE MESSAGE");
// Start instance
return base.OnStart();
}
My Web.config file looks like this:
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<system.diagnostics>
<sharedListeners>
<add name="AzureLocalStorage" type="WCFServiceWebRole1.AzureLocalStorageTraceListener, WCFServiceWebRole1"/>
</sharedListeners>
<sources>
<source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
<listeners>
<add name="AzureLocalStorage"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
<listeners>
<add name="AzureLocalStorage"/>
</listeners>
</source>
</sources>
<trace autoflush="true">
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
In the Compute Emulator I see the following error:
[MonAgentHost] Output: Monitoring Agent Started
[Diagnostics]: Starting configuration channel polling
[MonAgentHost] Error: MA EVENT: 2012-06-06T10:01:20.111Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6396
[MonAgentHost] Error: 6624
[MonAgentHost] Error: NetTransport
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\shared\nettransport\src\xblobconnection.cpp
[MonAgentHost] Error: XBlobConnection::PutBytesXBlob
[MonAgentHost] Error: 1621
[MonAgentHost] Error: ffffffff80050023
[MonAgentHost] Error: 0
[MonAgentHost] Error:
[MonAgentHost] Error: Failed to send bytes to XContainer wad-tracefiles
This error repeats several times. The "wad-tracefiles" container is added by the following code in the AzureLocalStorageTraceListener class:
public static DirectoryConfiguration GetLogDirectory()
{
DirectoryConfiguration directory = new DirectoryConfiguration();
directory.Container = "wad-tracefiles";
directory.DirectoryQuotaInMB = 10;
directory.Path = RoleEnvironment.GetLocalResource("WCFServiceWebRole1.svclog").RootPath;
return directory;
}
Why does writing trace messages fails in this scenario? When I look in my Storage with the Azure Storage Explorer the only table I see is the WADDirectoriesTable and not the the WADLogsTable. The "wad-tracefiles" blob does get created but that is not the place where I should find the Trace messages from my code.
Anyone, any idea? Any help is appreciated!
Your first problem is that you haven't used SetCurrentConfiguration() with your GetDefaultInitialConfiguration() to finally save the transfer time and log level. You must use the set of these API as below:
GetDefaultInitialConfiguration()
SetCurrentConfiguration()
OR
GetCurrentConfiguration()
SetCurrentConfiguration()
Because of it the following line based configuration will not be saved in Diagnostics configuration:
diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());
Use above suggestion and then see what happens.
I would also suggest to just create a very simple web or worker role hello world sample and add general TRACE Message by enabling Azure Diagnostics to see if that give you any error. This will prove if you have any issue with your SDK installation or Azure Storage Emulator or not as well.
Thank you for your reply! The project I am using is a really simple WebRole with only one trace message so I can not strip any code out.
I tried your suggestion and you are right, I do not get any error messages anymore with the following code:
public override bool OnStart()
{
setDiagnostics();
Trace.WriteLine("CUSTUM TRACE MESSAGE");
// Start instance
return base.OnStart();
}
private void setDiagnostics()
{
// Get diagnostics connectionstring
string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
// Get the diagnostics configuration of the deployment and its role instances that are currently running
DeploymentDiagnosticManager deploymentDiagnosticManager = new DeploymentDiagnosticManager(cloudStorageAccount, RoleEnvironment.DeploymentId);
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance.Role.Name,
RoleEnvironment.CurrentRoleInstance.Id);
// Load diagnostics configuration
DiagnosticMonitorConfiguration diagConfig = roleInstanceDiagnosticManager.GetCurrentConfiguration();
// Get the default value if there is no config yet
if (diagConfig == null)
diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
// Enable EventLogs
diagConfig.WindowsEventLog.DataSources.Add("Application!*");
diagConfig.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
diagConfig.WindowsEventLog.BufferQuotaInMB = 128;
// Failed Request Logs
diagConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());
diagConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
diagConfig.Directories.BufferQuotaInMB = 128;
// Crash Dumps
CrashDumps.EnableCollection(true);
// Set new configuration
roleInstanceDiagnosticManager.SetCurrentConfiguration(diagConfig);
// Start the DiagnosticMonitor
DiagnosticMonitor.Start(wadConnectionString, diagConfig);
}
When I look in which tables are present in the Azure Storage Explorer I only see the "WADDirectoriesTable" and the "WADWindowsEventLogsTable". Trace messages should come in the "WADLogsTable" right? So I see the Trace message in the Compute Emulator but I do not see them in my storage... any ideas why?

Azure Service Bus webHttpRelayBinding using WCF REST Template causes unnecessary aspNetCompatibilityEnabled error

I am using Azure Service Bus webHttpRelayBinding using WCF REST Template but it causes unnecessary aspNetCompatibilityEnabled error even though my service-class is correctly decorated:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
[ServiceContract( Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
public class InsightDataService //: Insight.WebAPI.WCFRestImplementation.IInsightDataService
{...
My Web.Config:-
<system.serviceModel>
<services>
<service name="compname.WebAPI.WCFRestImplementation.InsightDataService" behaviorConfiguration="InsightDataServiceBehavior">
<endpoint address="https://namespacename.servicebus.windows.net/InsightDataService"
binding="webHttpRelayBinding"
contract="compname.WebAPI.WCFRestImplementation.InsightDataService"
behaviorConfiguration="sharedSecret"
name="default"
>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://namespacename.servicebus.windows.net/InsightDataService"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<webHttpRelayBinding>
<binding name="webHttpRelayBinding"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
receiveTimeout="00:30:00"
sendTimeout="00:30:00"
openTimeout="00:30:00"
closeTimeout="00:30:00">
<security mode="None"></security>
</binding>
</webHttpRelayBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="InsightDataServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="True" />
<serviceThrottling
maxConcurrentCalls="20"
maxConcurrentInstances="2147483647"
maxConcurrentSessions="20"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="sharedSecret">
<transportClientEndpointBehavior credentialType="SharedSecret">
<clientCredentials>
<sharedSecret issuerName="owner"
issuerSecret="****************securitykey**********" />
</clientCredentials>
</transportClientEndpointBehavior>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="default" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
Exception is:-
[InvalidOperationException: The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.]
System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibilityRequirements(AspNetCompatibilityRequirementsMode compatibilityMode) +119682
System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) +31
System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +190
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +109
System.ServiceModel.ServiceHostBase.InitializeRuntime() +60
System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +50
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
Microsoft.ServiceBus.RelayedSocketListener.Open(TimeSpan timeout) +56
Microsoft.ServiceBus.Channels.BufferedConnectionListener.Open(TimeSpan timeout) +55
Microsoft.ServiceBus.Channels.ConnectionAcceptor.Open(TimeSpan timeout) +55
Microsoft.ServiceBus.Channels.ConnectionDemuxer.StartDemuxing(TimeSpan timeout, OnViaDelegate viaDelegate) +74
Microsoft.ServiceBus.Channels.ConnectionDemuxer.Open(TimeSpan timeout) +46
Microsoft.ServiceBus.SocketConnectionTransportManager.OnOpen(TimeSpan timeout) +639
Microsoft.ServiceBus.Channels.TransportManager.Open(TimeSpan timeout, TransportChannelListener channelListener) +687
Microsoft.ServiceBus.Channels.TransportManagerContainer.Open(TimeSpan timeout, SelectTransportManagersCallback selectTransportManagerCallback) +286
Microsoft.ServiceBus.Channels.TransportChannelListener.OnOpen(TimeSpan timeout) +106
Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelListener.OnOpen(TimeSpan timeout) +92
Microsoft.ServiceBus.SocketConnectionChannelListener`2.OnOpen(TimeSpan timeout) +106
Microsoft.ServiceBus.Channels.CommunicationObject.Open(TimeSpan timeout) +658
Microsoft.ServiceBus.Channels.LayeredChannelListener`1.OnOpen(TimeSpan timeout) +89
Microsoft.ServiceBus.Channels.CommunicationObject.Open(TimeSpan timeout) +658
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +72
[InvalidOperationException: The ChannelDispatcher at 'sb://namespacename.servicebus.windows.net/InsightDataService' with contract(s) '"InsightDataService"' is unable to open its IChannelListener.]
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +118
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +111
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +206
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651
[ServiceActivationException: The service '/InsightDataService' cannot be activated due to an exception during compilation. The exception message is: The ChannelDispatcher at 'sb://namespacename.servicebus.windows.net/InsightDataService' with contract(s) '"InsightDataService"' is unable to open its IChannelListener..]
System.Runtime.AsyncResult.End(IAsyncResult result) +688590
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
System.ServiceModel.Activation.AspNetRouteServiceHttpHandler.EndProcessRequest(IAsyncResult result) +6
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +96

Resources