Failing to connect to Sql Server from a C# program in Release only

  • Thread starter Thread starter MyCatAlex
  • Start date Start date
M

MyCatAlex

Guest
Hi there,

I need to move my C# code from Debug where it works well to Release. The program compiles and I can run the resulting exec file, however when I try to connect to Sql Server I get this exception message (runtime)

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Smo, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.Smo, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
at SQLServerSampleCodes.Form1.PushConnectToSqlServer_PG1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

This .dll file Microsoft.SqlServer.Smo.dll is present in both Debug and Release folders with the same version, it works for Debug but does not work for Release. The version of the file in both folders is different, however, from the version the exception is looking for, it is older. It seems to me the system suggests a solution but I will have to mess with the Registry.

Is it what I should do?

Thanks, -MyCatAlex

Continue reading...
 
Back
Top