
正文
包含.net资源文件丢失的词条
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
在尝试加载程序集 ID 65537 时 Microsoft .NET Framework 出错.服务器可能资源不
产生的原因大概是,在备份数据库的时候,在机器A,那么数据库的拥有者是A\Administrator(如果用windows登录创建),那么但是我们还原到服务器B,那么拥有者可能是B\Administrator,那么SQL CLR的安全性会认为该程序集不可靠.
解决方案:
在还原数据库之后,我们可以将数据库的OWNER设置成SA.
exec sp_changedbowner 'sa'
再调用存储过程就是成功的.
可以查看:KB
后来经过一些整理,发现当SQL CLR 存在EXTERNAL_ACCESS或者是UNSAFE的程序集的时候,SQL Server会检查DBO的SID在sys.databases 和sys.server_principals是否一致.
因此我们可能未必一定要修改成sa 的,只要所有者的SID在sys.databases和sys.server_principals 是一致的,就不出问题.
我们在SSMS里面右键数据库属性-找到文件选项卡-发现在所有者(是空的,还原以后原来的SID,数据库所有者在当前的sys.server_principals不匹配的),我们可以在 [...] 里面选择一个,具有创建CREATE ASSEMLY 权限的所有者就好,我选择了B\Administrator,然后测试 CLR 存储过程,没问题,
引深:
在SQL Server 复制里面也存在类似的问题,就是我们做 "对等复制" 的时候,会出现DBO不存在,以及sp_replcmd 不存在类似的错误.其实也是因为对等复制初始化订阅是通过 RESTORE 来实现的,因此只要简单的修改数据库所有者 就好了....那么对等复制的问题也就解决了!!
相关问答
Q1: .net6runtime安装失败
可能的原因有很多,以下是一些可能导致net6runtime安装失败的原因:
1. 操作系统不兼容: 如果您的操作系统不兼容.net 6 runtime,则会导致安装失败。例如,.Net 6需要 Windows 10 版本 1909 或更高版本,macOS 10.15 或更高版本,以及 Ubuntu 18.04 或更高版本。
2. 旧版本的.NET框架: 如果您计算机上已经安装了旧版本的.NET框架,则可能会导致安装失败。在这种情况下,您需要先卸载旧版本的.NET框架,然后重新安装.net 6 runtime。
3. 安装文件受损或不完整: 如果您下载的安装文件受损或不完整,则可能会导致安装失败。在这种情况下,您需要重新下载安装文件,并确保它完整无损。
4. 安装过程中出现错误: 在安装.net 6 runtime的过程中,如果出现意外错误,则可能会导致安装失败。在这种情况下,您需要检查错误消息以确定出现了什么问题,并尝试解决它。
对于.net 6 runtime安装失败的原因,您可以通过排除以上列举的可能性来解决问题。此外,您也可以在相关的开发者社区中查找解决方案,或者向官方技术支持寻求帮助。
Q2: .NET 用File.Copy()复制文件后删除文件
首先,你不是在做File Move操作么,为什么要用Copy方法呢?
File Stream资源是非托管资源(Unmanaged Resource),你需要自己手动释放其占用的资源, 不然就会报错。 关于File的详细信息直接参考MSDN:
针对你的需求,我给你写了一个简单的例子, 我直接使用File.Move方法来完成。
using System;
using System.IO;
using System.Reflection;
using System.Text;
namespace FileDemos
{
class FileMoveDemo
{
static void Main()
{
string appDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string filePath = appDir + "\\test.txt";
string tempPath = appDir + "\\temp";
string newFilePath = tempPath + "\\test.txt";
try
{
Console.WriteLine("Create a test file:");
Console.WriteLine(filePath);
// Delete the file if it exists.
if (File.Exists(filePath))
{
// Note that no lock is put on the
// file and the possibility exists
// that another process could do
// something with it between
// the calls to Exists and Delete.
File.Delete(filePath);
}
// Create the file.
using (FileStream fs = File.Create(filePath))
{
Byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
// Add some information to the file.
fs.Write(info, 0, info.Length);
}
// Move file to another place.
if (File.Exists(filePath))
{
// Ensure that the target does not exist.
if (File.Exists(newFilePath))
File.Delete(newFilePath);
// Determine whether the directory exists.
if (!Directory.Exists(tempPath))
{
// Try to create the directory.
DirectoryInfo di = Directory.CreateDirectory(tempPath);
Console.WriteLine("Create a temp directory:");
Console.WriteLine(tempPath);
}
// Move the file.
File.Move(filePath, newFilePath);
Console.WriteLine("{0} was moved to {1}.", filePath, newFilePath);
}
}
catch (Exception Ex)
{
Console.WriteLine(Ex.ToString());
}
}
}
}
Q3: VB.NET释放资源文件的办法?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim path As String = "C:\Data.mdb" '文件释放路径
Dim resources As System.Resources.ResourceManager = My.Resources.ResourceManager
Dim b() As Byte = resources.GetObject("Data")
Dim s As IO.Stream
Try
s = IO.File.Create(path)
s.Write(b, 0, b.Length)
s.Close()
MessageBox.Show("资源释放成功")
Catch ex As Exception
MessageBox.Show("资源释放失败!Result=" + ex.Message)
End Try
End Sub
Q4: 求System.Net.ServicePoint.dll文件V4.700.19.60801网盘资源
链接:
提取码:c7r2
软件名称:System.Net.ServicePoint.dll文件V4.700.19.60801官方版
语言:简体中文
大小:18.81KB
类别:系统工具
介绍:System.Net.ServicePoint.dll文件官方版是电脑系统中十分重要的一款系统文件。System.Net.ServicePoint.dll文件可以帮助用户的电脑和电脑中许多软件正常运行,如果用户的电脑中缺失了这款System.Net.ServicePoint.dll文件,将会导致用户电脑或软件无法正常使用。
.net资源文件丢失的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、.net资源文件丢失的信息别忘了在本站进行查找喔。








