Error while using ExecuteNonQuery c#

对着背影说爱祢 提交于 2019-11-29 08:42:47

I had a similar issue. I have an SMO application which uses the Microsoft.SqlServer.SqlManagementObjects nuget package.

The app all runs perfectly on my p.c however when it came to deploying it and running it on our app server i was getting the error.

Could not load file or assembly 'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies. The specified module could not be found.

To fix the issue I needed to build the project again targeting x86 platform.

You should add the missing dll in your project and if you publish your project, you must put this dll in to the bin folder.

I had faced a similar issue. In my setup, I have a WPF application which uses a class library which in turn refers the Microsoft.SqlServer.SqlManagement Objects (SMO) (version 140.17283.0) via NuGet package.

After trying lot of things, finally figured out that in addition to the class library, the WPF application also needs to refer the SMO library via NuGet.

So I just added the SMO library via NuGet at the solution level and install it for class library as well as WPF application. Voila, it worked !!! (Looks like the Microsoft.SqlServer.BatchParserClient.dll is not properly referenced if it is referred only in the class library which is weird but it solved the issue)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!