新安装U9C,连接初始库,保存档案时,报错:
在尝试加载程序集 ID 65536 时 Microsoft .NET Framework 出错。服务器可能资源不足,或者不信任该程序集,因为它的 PERMISSION_SET 设置为 EXTERNAL_ACCESS 或 UNSAFE。请重新运行查询,或检查有关的文档了解如何解决程序集信任问题。有关此错误的详细信息:
System.IO.FileLoadException: 未能加载文件或程序集“ufida.u9.sql.clrlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。异常来自 HRESULT:0x80FC80F1
System.IO.FileLoadException:
在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
在 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
在 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
在 System.Reflection.Assembly.Load(String assemblyString)
AllocSerials过程试图返回状态 NULL,这是不允许的。将返回状态 0。 在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
在 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
在 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
在 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
在 UFSoft.UBF.Util.DataAccess.AbstractDataAccessor.Execute(IDbConnection con, String commandText, DataParamList dataParams, CommandType cmdType)
在 UFSoft.UBF.Util.DataAccess.DataAccessor.RunSP(IDbConnection conn, String sprocName, DataParamList dataParams)
在 UFSoft.UBF.Util.DataAccess.KeyGenerator.GetStartSNFromSP()
在 UFSoft.UBF.Util.DataAccess.KeyGenerator.NewValue()
在 UFSoft.UBF.Business.Tool.ExtendHelpAPI.GetNewID()
在 UFSoft.UBF.Business.Entity.BeforeCreate(IClassKey classKey, Entity entity, IEntity parent, Object ID)
在 UFSoft.UBF.Business.Entity.Create(IClassKey classKey, Entity entity, IEntity parent, Object ID, Boolean needPersistable)
在 UFSoft.UBF.Business.Entity.Create(IClassKey classKey, IEntity parent, Object ID, Boolean needPersistable)
在 UFSoft.UBF.Business.Entity.Create(IClassKey classKey, IEntity parent)
在 UFSoft.UBF.Business.Entity.Create(String fullName, IEntity parent)
在 UFSoft.UBF.UI.UICommonCRUD.DomainUpdate.CreateOrUpdateRowData(IUIRecord record, Int64 parentKey, Entity parentPO)
在 UFSoft.UBF.UI.UICommonCRUD.DomainUpdate.UpdateRecord(IUIRecord record, Int64 parentKey, Entity parentPo)
在 UFSoft.UBF.UI.UICommonCRUD.DomainUpdate.ExecuteUpdate(IUIModel model)
在 UFSoft.UBF.UI.UICommonCRUD.UIModelUpdateImpementStrategy.Do(Object obj)
百度查到解决办法:
https://www.intohard.com/thread-268432-1-1.html
这说明数据库存在EXTERNAL_ACCESS 和UNSAFE的程序集,要解决此问题,要想完成数据迁移,原库与目标库库所有者必须设为SA或Administrator,然后启用SQL CLR,否则SQL CLR的安全性会认为该程序集不可靠,从而无法进行数据表任何操作。
--数据库的OWNER设置成SA语句.
exec sp_changedbowner 'sa'
--如果没有启用CLR,开启
EXEC sp_configure 'clr enabled',1
RECONFIGURE WITH OVERRIDE;
--查看程序集,是存在的.
SELECT * FROM sys.assemblies;
SELECT * FROM sys.assembly_files;
--还原之后的数据库TRUSTWORTHY 都是OFF的,需要重新设置
ALTER DATABASE B SET TRUSTWORTHY ON;
解决!