on 2016 Apr 01 8:45 AM
I have a C# script to resize jpg files. It is a rather simple script using the Microsft System.Drawing dll.
But when I execute the SQL function fn_tsd_net_resizeimage() I got a error. The sp_test() is working fine, that function does not have dependencies.
The manual is not very clear about how to make 'complex' functions like this, with dependencies, working.
The dll is build as x64.
I tried the following things:
None of these work.
Question: how to fix this..?
Below you will find the two SA fucntions and the C# script.
SELECT "DBA"."fn_tsd_net_resizeimage"('d:/fotos/001/abbnana.jpg','d:/temp/t.jpg',100,100)
The error:
Procedure 'fn_tsd_net_resizeimage' terminated with unhandled exception
'Kan bestand of assembly System.Drawing, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a of een van de
afhankelijkheden hiervan niet laden. Deze assembly is gebouwd
SQLCODE=-91, ODBC 3 State="HY000"
In english it is something like
"....could not load assembly ..xxx.. or one of the dependenies. This assembly is build SQLCode...."
The sp_test() is working well.
//C# script:
using System; using System.Drawing; using System.Drawing.Drawing2D;public class Resize { public static string Test(string one, string two) { return one + two ; } public static int ResizeFile(string filein, string fileOut, int width, int height) { Image imageIn = Image.FromFile(filein); Image imageNew = ResizeImage(imageIn, new Size(width, height)); imageNew.Save(fileOut); return 1; } public static Image ResizeImage(Image image, Size size, bool preserveAspectRatio = true, bool mayGrow = false) { . . return newImage; } }
SQL Anywhere functions.
//This one works fine. ALTER FUNCTION "DBA"."sp_tst"( in "as_file_in" long varchar, in "as_file_out" long varchar ) returns long varchar external name 'd:\\wintreeapps\\bin\\TSDSAaddons.dll::Resize.Test( string, string) string' language "CLR"
//Problem about dependecy ALTER FUNCTION "DBA"."fn_tsd_net_resizeimage"( in "as_file_in" long varchar, in "as_file_out" long varchar, in "ai_width" integer, in "ai_height" integer ) returns integer external name 'd:\\wintreeapps\\bin\\TSDSAaddons.dll::Resize.ResizeFile( string, string, int, int) int' language "CLR"
Request clarification before answering.
I saw in the installed software from Windows 10 that the .Net framework 3.5 and 4.5/6 were installed, not a 4.0. Therefore I changed, the "Target framework" from v4.0 to v3.5.
That solved the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
30 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.