Reputation: 167
I get the below error while using traceReader.InitializeAsReader(connDef, "D:\\trace.tdf");
Error:
2013-07-25 13:59:53,578 [8] DEBUG Error while invoking InitializeAsReaderException has been thrown by the target of an invocation. Microsoft.SqlServer.Management.Trace.SqlTraceException: Failed to initialize object as reader. ---> System.Runtime.InteropServices.COMException at ?A0xe4daab47.ProcessError(Int32 hr, UInt16* lpszMessage) at Microsoft.SqlServer.Management.Trace.CTraceControllerBase.InitSource(Boolean bReOpen) at Microsoft.SqlServer.Management.Trace.CTraceObjectsRowsetController.InitSource(Boolean bReOpen) at Microsoft.SqlServer.Management.Trace.TraceServer.InitializeAsReader(ConnectionInfoBase serverConnInfo, String profileFileName) --- End of inner exception stack trace --- at Microsoft.SqlServer.Management.Trace.TraceServer.InitializeAsReader(ConnectionInfoBase serverConnInfo, String profileFileName).
Scenario:
I use sql 2012 server under windows 2008 R2.
Assemblies loaded are
connectionInfoAssembly = Assembly.Load("Microsoft.SqlServer.ConnectionInfo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
traceAssembly = Assembly.Load("Microsoft.SqlServer.ConnectionInfoExtended, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
smoAssembly = Assembly.Load("Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
ConnInfo is
server='';Trusted_Connection=true;multipleactiveresultsets=false --- Database name.
what I am doing wrong?
Upvotes: 4
Views: 1918
Reputation: 167
I figured out the issue.
I use wix tool to create the msi and deploy this project (Trace reader) as service in windows.What was happening is, trace reader service was running with LocalSystem account.This account did not have sufficient privileged to access traces.
I have enabled "Alter trace" permission for LocalSystem as below.
This is required when you deploy the project as service.
Upvotes: 2