Files to process: 1 ( 19.8 MB )
Clearing Target Tables...
SMO Version: Microsoft.SqlServer.ConnectionInfoExtended, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
Processing: ClearTraceTest.trc
Trace File Read Error in C:\DBA\Temp\ClearTraceTest.trc (Exception has been thrown by the target of an invocation.)
Inner Exception: Exception has been thrown by the target of an invocation.
Inner Exception: Failed to initialize object as reader.
Inner Exception: Could not load file or assembly 'Microsoft.SqlServer.Instapi, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
You can visit the support forum at http://forums.sqlteam.com/c/cleartrace
Done.
Exception calling "Load" with "1" argument(s): "Could not load file or assembly 'Microsoft.SqlServer.Instapi, Version=13.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified."
At line:4 char:1
My best guess is that the SQL Server 2016 Engine is installed but the SSMS 2016 tools aren't. In SQL Server 2016 they're a separate install. Can you confirm whether SSMS 2016 is installed?
A second option is to replace the contents of ClearTrace.EXE.config with the following.
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings/>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<!--
Uncommnet the following section to remap the SMO vesions
This is built with SQL Server 2012 SMO. It should run
with most common SMO vesions.
Replace the "newVersion" with the version you'd like
to target.
SQL Server 2008 10.0.0.0
SQL Server 2008 R2 10.0.0.0 (Uses the previous SMO)
SQL Server 2012 11.0.0.0
SQL Server 2014 12.0.0.0
SQL Server 2016 13.0.0.0
-->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Smo"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.ConnectionInfo"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.ConnectionInfoExtended"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Management.Sdk.Sfc"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.SmoExtended"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.SqlEnum"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Trace File Read Error in C:\Downloads\DBBackups\Untitled - 1.trc (Exception has been thrown by the target of an invocation.)
Inner Exception: Exception has been thrown by the target of an invocation.
Inner Exception: Failed to initialize object as reader.
Inner Exception: Could not load file or assembly 'Microsoft.SqlServer.Instapi, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
You can visit the support forum at http://forums.sqlteam.com/c/cleartrace
Done.
Here is the config file maybe something is wrong or missing?
<?xml version="1.0"?>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Smo"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="12.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.ConnectionInfo"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="12.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.ConnectionInfoExtended"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="12.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Management.Sdk.Sfc"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="12.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.SmoExtended"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="12.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.SqlEnum"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
Assembly versions can be redirected in application,
publisher policy, or machine configuration files.
<bindingRedirect oldVersion="12.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
Did this ever get resolved? I'm running into the same issue.
Windows Server 2019
SQL Server 2016 SP2
SSMS 18
"Inner Exception: Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\pfclnt.dll' or one of its dependencies. The system cannot find the file specified."
Please could you check the following error I am getting when trying to import a sql server 2012 trace file? In case it helps: I am using Windows 10 and I have SQL Server 2012, 2014, 2016 and 2019 installed with latest SSMS.
Files to process: 1 ( 110 KB )
Clearing Target Tables...
SMO Version: Microsoft.SqlServer.ConnectionInfoExtended, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
Processing: test.trc
Trace File Read Error in C:\Temp\test.trc (Exception has been thrown by the target of an invocation.)
Inner Exception: Exception has been thrown by the target of an invocation.
Inner Exception: Failed to initialize object as reader.
Inner Exception: Failed to get SQL Tools directory path from InstAPI.
You can visit the support forum at ...
Done.
I have used the tool a few years ago and I loved it!
Unfortunately I can no longer use it in my new environment.
So this is a challenging problem to solve and I don't know that I can. Just to be clear, the latest versions of SSMS and SMO don't support using SMO to read trace files. Which means I have no API to read trace files. And Microsoft hasn't published the file layouts. So here are some best guesses on what might work.
The best solution is to switch to extended events. Fully supported and works well.
The next best solution is to build a VM with SQL Server 2016, it's related SSMS, and run ClearTrace on that. The SMO libraries used some DLL buried deep inside SQL Server or SSMS to read the trace files. That doesn't seem to be present in the latest builds.
You may be able to make it work by installing an earlier version of SSMS.
You can try to hard code the SMO version in the ClearTrace.exe.config like this. This may remap the version of SSMS it is trying to use. I've had little success with this. I'm not spending much time trying to make this work since Trace is going away.
Good luck!
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings/>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<!--
Use the following section to remap the SMO vesions
This is built with SQL Server 2017 SMO. It should run
with most common SMO vesions.
Replace the "newVersion" with the version you'd like
to target.
SQL Server 2012 11.0.0.0
SQL Server 2014 12.0.0.0
SQL Server 2016 13.0.0.0
SQL Server 2017 14.0.0.0 (Or just comment out the runtime section)
...
-->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.ConnectionInfoExtended"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
<bindingRedirect oldVersion="14.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.XEvent.Linq"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
<bindingRedirect oldVersion="14.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.XE.Core"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
<bindingRedirect oldVersion="14.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>