Search code examples
sql-server-2012sql-server-profiler

SQL Server Profiler - Could not load pfclnt.dll


First of all i am a novice .NET programmer and I stuck in trying to fix an issue with a custom SQL Profiler tracer like the one described here - http://www.codeproject.com/Articles/20173/MS-SQL-Server-Profiler-with-NET

So, I use the TraceServer(http://technet.microsoft.com/en-us/library/Microsoft.SqlServer.Management.Trace.TraceServer.aspx) class to InitializeAsReader and immediately it throws me a

"Failed to initialize object as reader."

with an InnerException -

"Could not load file or assembly 'file:///c:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\pfclnt.dll' or one of its dependencies. The system cannot find the file specified.""

Interestingly this happens only when i try connecting to a SQL Profiler 2012 and I don't face a problem with 2008R2. Also I noticed that the pfclnt.dll is present in "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn" and not inside the folder that is mentioned in the trace.

Is there a way I can ask it to load it from the right location? Why is it looking at the wrong location in the first place?


Solution

  • Alright, I realized that my project had references to SQL Server 2008 Assemblies especially this one - C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfoExtended.dll. I removed those references and added references to the 2012 libraries present in C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies and everything works now!

    This question - SQL Server file names vs versions helped me understand the weird folder names that SQL server uses to separate versions.