Creating a stored procedure in SQL Server using the CLR assembly (C#)

58 views Asked by At

Created a DLL in C#. I made an assembly in SQL Server from my DLL and the DLL that the project needs.

CREATE ASSEMBLY [WindowsBase] FROM 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\WindowsBase.dll' WITH PERMISSION_SET = UNSAFE;

CREATE ASSEMBLY [System.Drawing] FROM 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll' WITH PERMISSION_SET = UNSAFE;

CREATE ASSEMBLY [Accessibility] FROM 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll' WITH PERMISSION_SET = UNSAFE;

CREATE ASSEMBLY [System.Xaml] FROM 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll' WITH PERMISSION_SET = UNSAFE;

CREATE ASSEMBLY [DocumentFormat.OpenXml] FROM 'c:\TEMP\tst2\DocumentFormat.OpenXml.dll' WITH PERMISSION_SET = UNSAFE;
dll
CREATE ASSEMBLY [DemoAssembly] FROM 'c:\TEMP\tst2\test1.dll' WITH PERMISSION_SET = UNSAFE;

Created a stored procedure

create procedure dbo.sp_DemoAssembly 
(
@file nvarchar(200)
)
as external name Simple.Demo.GetExcel
go

starting the procedure

exec dbo.sp_DemoAssembly @file='c:\TEMP\Simple\Simple\test.xlsx'

As a result: everything works as it should on my home computer ** and there is such an error on the working test server:**

Msg 6522, Level 16, State 1, Procedure sp_DemoAssembly, Line 0 [Batch Start Line 26] A .NET Framework error occurred during execution of user-defined routine or aggregate "sp_DemoAssembly": System.IO.FileNotFoundException: Could not load file or assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: at Demo.GetExcel(String file) .

What could be the problem?

I would like to get rid of the error

0

There are 0 answers