问题描述
我必须处理一个现有应用程序,该应用程序包含许多项目,包括数据库项目。
在statup项目(它是Windows应用程序)中,当调用 Adapter.Fill(dataTable);
时出现一个可怕的错误,说: / p>
Microsoft .NET Framework尝试加载程序集ID 65675时发生错误。服务器可能资源不足,或者PERMISSION_SET = EXTERNAL_ACCESS或UNSAFE可能不信任该程序集。再次运行查询,或查看文档以查看如何解决程序集信任问题。有关此错误的更多信息:
$中的dholdings.btnSearch_Click(Object sender,EventArgs e) p $ p>
System.IO.FileLoadException:无法加载文件或程序集 xxxxx.yyyy.database,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null或其依赖项之一。给定的程序集名称或代码库无效。 (来自HRESULT的异常:0x80131047)
System.IO.FileLoadException:
,位于System.Reflection.Assembly._nLoad(AssemblyName文件名,字符串codeBase,证据汇编安全性,程序集locationHint,StackCrawlMark& stackMark,布尔throwOnFileNotFound,布尔值forIntrospection)
在System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,Evidence assemblySecurity,StackCrawlMark& stackMark,Boolean forIntrospection)
在System.Reflection.Assembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& Stack ,Introspection布尔值)System.Reflection.Assembly.Load(String assemblyString)
(.Net SqlClient数据提供程序)中的
在System中的
Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection)
在System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection)System.Data.SqlClient.TdsParser.ThrowExc System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)上的eptionAndWarning(TdsParserStateObject stateObj)
在System.Data.SqlReader。 )
在System.Data.SqlClient.SqlDataReader.get_MetaData()
在System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)
在System.Data。 SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean ReturnB,结果字符串,D $ b在System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String方法) .Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior行为,String方法)System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior行为)
在System.Data.Common.DbCommand.System.Data中。 IDbCommand.ExecuteReader(CommandBehavior行为),位于System.Data.Common.DbDataAdapter.FillInternal(DataSet数据集,DataTable []数据表,Int32 startRecord,Int32 maxRecords,字符串srcTable,IDbCommand命令,CommandBehavior行为)中,
System.Data.Common.DbDataAdapter.Fill(DataTable [] dataTables,Int32 startRecord,Int32 maxRecords,IDbCommand命令,CommandBehavior行为)
在System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
在E:\项目\PPP\XXX\YYY\Data\dsLandholdings中的XXX.YY.Data.dsLandholdingsTableAdapters.LandholdingsTableAdapter.Fill(LandholdingsDataTable dataTable,字符串IV_LRNO,字符串SearchField,字符串SearchVal,Nullable`1 SearchType) .Designer.cs:XXX.YYY.Browse.BrowseLan的第5678行
E:holdProjects\PPPPSearchXXXX\YYY\Browse\BrowseLandholdings.cs:line 352
在网络上调查后,我发现将数据库项目属性中数据库选项卡上的权限级别从安全更改为帮助表示不安全或外部。
但是错误仍然存在
有人说过为什么会发生这种情况吗?
任何帮助表示赞赏
解决方案终于可以解决了,
- 启用 在SQL Server中。
- (在我的情况下是数据库项目),我还将权限级别也设置为外部。
感谢所有评论/答案。
I have to work on an existing application, comprises of many projects including a database project. In the statup project, which is a windows app., when making a call to a
Adapter.Fill(dataTable);
a scary error appears saying that:An error occurred in the Microsoft .NET Framework while trying to load assembly id 65675. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error: System.IO.FileLoadException: Could not load file or assembly 'xxxxx.yyyy.database, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) System.IO.FileLoadException: at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) (.Net SqlClient Data Provider) at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at XXX.YY.Data.dsLandholdingsTableAdapters.LandholdingsTableAdapter.Fill(LandholdingsDataTable dataTable, String IV_LRNO, String SearchField, String SearchVal, Nullable`1 SearchType) in E:\Projects\PPP\XXX\YYY\Data\dsLandholdings.Designer.cs:line 5678 at XXX.YYY.Browse.BrowseLandholdings.btnSearch_Click(Object sender, EventArgs e) in E:\Projects\PPPP\XXXX\YYY\Browse\BrowseLandholdings.cs:line 352
After investigating on the web, I found that it may help to change the "Permission level" on the "Database" tab of my "Database project properties" from "safe" to either "Unsafe" or "External".
But the error is still coming up after doing mentioned change!
Does anyone possibly have any idea why this is happening?
Any help appreciated in advance.
解决方案At long last, I could fix it,
- Enable the "CLR Integration" in SQL server.
- Deploy the CLR Object ,which in my case was the Database Project,and I set the Permission level to external as well.
Thanks for all comments/answers.
这篇关于尝试加载程序集ID 65675的Microsoft .NET Framework中发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!