简体   繁体   English

无法在MS SQL SERVER中创建程序集

[英]Failed To Create Assembly in MS SQL SERVER

I am trying to implement routing funcationality in MS SQL Server 2012 using the prospatial tutorial, I created a C# class and successfully build DLL file. 我试图使用专业教程在MS SQL Server 2012中实现路由功能,我创建了C#类并成功构建了DLL文件。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Server;
using Microsoft.SqlServer.Types;

namespace ProSQLSpatial.Ch14
{
public partial class UserDefinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlGeometry GeometryTSP(SqlGeometry PlacesToVisit)
    {
        // Convert the supplied MultiPoint instance into a List<> of SqlGeometry points
        List<SqlGeometry> RemainingCities = new List<SqlGeometry>();
        // Loop and add each point to the list
        for (int i = 1; i <= PlacesToVisit.STNumGeometries(); i++)
        {
            RemainingCities.Add(PlacesToVisit.STGeometryN(i));
        }
        // Start the tour from the first city
        SqlGeometry CurrentCity = RemainingCities[0];

        // Begin the geometry
        SqlGeometryBuilder Builder = new SqlGeometryBuilder();
        Builder.SetSrid((int)PlacesToVisit.STSrid);
        Builder.BeginGeometry(OpenGisGeometryType.LineString);
        // Begin the LineString with the first point
        Builder.BeginFigure((double)CurrentCity.STX, (double)CurrentCity.STY);
        // We don't need to visit this city again
        RemainingCities.Remove(CurrentCity);

        // While there are still unvisited cities
        while (RemainingCities.Count > 0)
        {
            RemainingCities.Sort(delegate(SqlGeometry p1, SqlGeometry p2)
            { return p1.STDistance(CurrentCity).CompareTo(p2.STDistance(CurrentCity)); });

            // Move to the closest destination
            CurrentCity = RemainingCities[0];

            // Add this city to the tour route
            Builder.AddLine((double)CurrentCity.STX, (double)CurrentCity.STY);

            // Update the list of remaining cities
            RemainingCities.Remove(CurrentCity);
        }

        // End the geometry
        Builder.EndFigure();
        Builder.EndGeometry();

        // Return the constructed geometry
        return Builder.ConstructedGeometry;
    }
};
}

I also enabled CLR and when I try to create a assembly using the above created DLL: 我还启用了CLR,当我尝试使用上面创建的DLL创建程序集时:

CREATE ASSEMBLY GeometryTSP 
FROM 'D:\Routing\my example\GeometryTSP\GeometryTSP\bin\Debug\GeometryTSP.dll' 
WITH PERMISSION_SET = EXTERNAL_ACCESS; 
GO 

I'm getting "Failed to create AppDomain" error like this: 我收到这样的“无法创建AppDomain”错误:

Msg 6517, Level 16, State 1, Line 2
Failed to create AppDomain "master.dbo[ddl].12". 
Exception has been thrown by the target of an invocation.

What should be the reason? 应该是什么原因?

try remove the neamespace section 尝试删除neamespace部分

namespace ProSQLSpatial.Ch14
{
}

sql server use default namespace sql server使用默认名称空间

经过一些研究后,我找到了解决方案,其问题是安装.NET Framework之后系统重新启动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 ref 参数从 dll 程序集创建 MS SQL Server 函数 - Create MS SQL Server function from dll assembly with ref parameter SQL Server:“为程序集&#39;测试&#39;创建程序集失败,因为程序集&#39;测试&#39;格式错误或不是纯.NET程序集。” - SQL Server: “CREATE ASSEMBLY for assembly 'Test' failed because assembly 'Test' is malformed or not a pure .NET assembly.” Sql 服务器 CLR 加载组件失败 - Sql Server CLR load assembly failed 自动创建SQL Server CREATE ASSEMBLY脚本 - Create SQL Server CREATE ASSEMBLY script automatically SQL Server 2017:无法创建程序集。 检查引用的程序集是否是最新的和受信任的 - SQL Server 2017: Failed To Create Assembly. Check if referenced assemblies are up-to-date and trusted 将程序集安装到SQL Server中时如何解决失败的程序集验证 - How to resolve failed assembly verification when installing assembly into SQL Server 从SQL Server创建到MS Word的报告 - Create a report to MS Word from SQL Server 无法在SQL中创建程序集&#39;System.ServiceModel.Internals&#39; - Failed to create assembly 'System.ServiceModel.Internals' in SQL 从MS SQL Server转换为MySQL时无法保存Unicode - Failed to save Unicode in converting from MS SQL Server to MySQL SQL Server 2008 R2如何创建ASSEMBLY - SQL Server 2008 R2 how to create ASSEMBLY
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM