3

我想使用neodynamic image draw sdk并在构建时不断收到此错误我已经搜索了解决方案但没有任何工作我有这是我当前的代码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using DevPro.Data.Enums;
    using YGOPro_Launcher.CardDatabase;
    using System.IO;
    using System.Reflection;
    using System.Data.SQLite;
    using DevPro_CardManager.Properties;
    using Neodynamic.SDK;

namespace Outlaws_CardManager
{
    public partial class cardmaker : Form
    {
        public cardmaker()
        {
            InitializeComponent();
            TopLevel = false;
            Dock = DockStyle.Fill;
            Visible = true;
        }

        private void GenerateCard()
        {
            //Get the info to create the card
            string cardname = "";
            string cardid = "";
            string level = "";
            string race = "";
            string attribute = "";
            string atk = "";
            string def = "";
            string type1 = "";
            string type2 = "";
            string stype = "";
            string traptype = "";
            string mainpicture = "";
            string layout = "Left";

            if (!String.IsNullOrEmpty(CardName.Text))
            {
                cardname = CardName.Text;
            }
            if (!String.IsNullOrEmpty(CardID.Text))
            {
                cardid = CardID.Text;
            }
            if (!String.IsNullOrEmpty(ATK.Text))
            {
                atk = ATK.Text;
            }
            if (!String.IsNullOrEmpty(DEF.Text))
            {
                def = DEF.Text;
            }

            ImageDraw imgDraw = new ImageDraw();
            //Basic settings for Card
            imgDraw.Canvas.AutoSize = false;
            imgDraw.ImageFormat = ImageDrawFormat.Png;
            //Set card size
            imgDraw.Canvas.Width = 400;
            imgDraw.Canvas.Height = 250;

            //Create main decorative shape element
            RectangleShapeElement rect1 = new RectangleShapeElement();
            rect1.X = 10;
            rect1.Y = 10;
            rect1.Width = 380;
            rect1.Height = 230;

            rect1.Roundness = 20;
            rect1.StrokeWidth = 0;
            //Set background
            rect1.Fill.BackgroundColor = Color.Black;
            //Add element to output image
            imgDraw.Elements.Add(rect1);



            //Create top decorative shape element
            RectangleShapeElement rect2 = new RectangleShapeElement();
            rect2.X = 20;
            rect2.Y = 20;
            rect2.Width = 360;
            rect2.Height = 170;
            rect2.Roundness = 10;
            rect2.StrokeWidth = 0;
            rect2.Fill.BackgroundColor = Color.White;
            //Add element to output image
            imgDraw.Elements.Add(rect2);

            //Create bottom decorative shape element
            RectangleShapeElement rect3 = new RectangleShapeElement();
            rect3.X = 30;
            rect3.Y = 130;
            rect3.Width = 340;
            rect3.Height = 100;
            rect3.Roundness = 10;
            rect3.StrokeWidth = 1;
            rect3.StrokeFill.BackgroundColor = Color.Black;
            rect3.Fill.BackgroundColor = Color.White;
            //Add element to output image
            imgDraw.Elements.Add(rect3);





            //Create an ImageElement to wrap the user logo
            if (mainpicture.Length > 0 && System.IO.File.Exists(mainpicture))
            {
                ImageElement imgElemLogo = new ImageElement();
                //Get user logo from disk
                imgElemLogo.Source = ImageSource.File;
                imgElemLogo.SourceFile = mainpicture;
                //Logo Layout
                if (layout == "Right")
                {
                    imgElemLogo.X = 40;
                    imgElemLogo.Y = 40;
                }
                else
                {
                    imgElemLogo.X = 400 - (50 + 40); //Canvas Width - (Logo Width + X Margin)
                    imgElemLogo.Y = 40;
                }
                //Apply Resize logo
                Resize resizeLogo = new Resize();
                resizeLogo.Width = 50;
                resizeLogo.LockAspectRatio = LockAspectRatio.WidthBased;
                imgElemLogo.Actions.Clear();
                imgElemLogo.Actions.Add(resizeLogo);
                //Add element to output image
                imgDraw.Elements.Add(imgElemLogo);
            }


            //Create TextElement objects for each fields

            if (cardname.Length > 0)
            {
                TextElement txtElemName = new TextElement();
                txtElemName.AutoSize = false;
                txtElemName.Font.Name = "Arial";
                txtElemName.Font.Size = 14f;
                txtElemName.Font.Unit = FontUnit.Point;
                txtElemName.Font.Bold = true;
                txtElemName.ForeColor = System.Drawing.Color.Black;
                txtElemName.Text = cardname;
                txtElemName.TextQuality = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                txtElemName.X = 40;
                txtElemName.Y = 40;
                txtElemName.Width = 320;
                txtElemName.Height = 20;
                if (layout == "Left")
                {
                    txtElemName.TextAlignment = ContentAlignment.MiddleLeft;
                }
                else
                {
                    txtElemName.TextAlignment = ContentAlignment.MiddleRight;
                }
                //Add element to output image
                imgDraw.Elements.Add(txtElemName);
            }

            if (cardid.Length > 0)
            {
                TextElement txtElemJob = new TextElement();
                txtElemJob.AutoSize = false;
                txtElemJob.Font.Name = "Arial";
                txtElemJob.Font.Size = 10f;
                txtElemJob.Font.Unit = FontUnit.Point;
                txtElemJob.ForeColor = System.Drawing.Color.Black;
                txtElemJob.Text = cardid;
                txtElemJob.TextQuality = System.Drawing.Text.TextRenderingHint.AntiAlias;
                txtElemJob.X = 40;
                txtElemJob.Y = 64;
                txtElemJob.Width = 320;
                txtElemJob.Height = 14;
                if (layout == "Left")
                {
                    txtElemJob.TextAlignment = ContentAlignment.MiddleLeft;
                }
                else
                {
                    txtElemJob.TextAlignment = ContentAlignment.MiddleRight;
                }
                //Add element to output image
                imgDraw.Elements.Add(txtElemJob);
            }

            if (atk.Length > 0)
            {
                TextElement txtElemAddress = new TextElement();
                txtElemAddress.AutoSize = false;
                txtElemAddress.Font.Name = "Times New Roman";
                txtElemAddress.Font.Italic = true;
                txtElemAddress.Font.Size = 11f;
                txtElemAddress.Font.Unit = FontUnit.Point;
                txtElemAddress.ForeColor = System.Drawing.Color.Black;
                txtElemAddress.Text = atk + "\n" + race;
                txtElemAddress.TextQuality = System.Drawing.Text.TextRenderingHint.AntiAlias;
                txtElemAddress.X = 40;
                txtElemAddress.Y = 130;
                txtElemAddress.Width = 160;
                txtElemAddress.Height = 50;
                if (layout == "Left")
                {
                    txtElemAddress.TextAlignment = ContentAlignment.MiddleLeft;
                }
                else
                {
                    txtElemAddress.TextAlignment = ContentAlignment.MiddleRight;
                }
                //Add element to output image
                imgDraw.Elements.Add(txtElemAddress);
            }

            if (attribute.Length > 0 || atk.Length > 0)
            {
                TextElement txtElemPhone = new TextElement();
                txtElemPhone.AutoSize = false;
                txtElemPhone.Font.Name = "Georgia";
                txtElemPhone.Font.Size = 10f;
                txtElemPhone.Font.Unit = FontUnit.Point;
                txtElemPhone.ForeColor = System.Drawing.Color.Black;
                txtElemPhone.Text = "Phone: " + attribute + "\n" + atk;
                txtElemPhone.TextQuality = System.Drawing.Text.TextRenderingHint.AntiAlias;
                txtElemPhone.X = 200;
                txtElemPhone.Y = 180;
                txtElemPhone.Width = 160;
                txtElemPhone.Height = 50;
                if (layout == "Right")
                {
                    txtElemPhone.TextAlignment = ContentAlignment.MiddleLeft;
                }
                else
                {
                    txtElemPhone.TextAlignment = ContentAlignment.MiddleRight;
                }
                //Add element to output image
                imgDraw.Elements.Add(txtElemPhone);
            }

            //generate image card and preview it
            CardImg.Image = imgDraw.GetOutputImage();
        }

    }
}

有没有人遇到过这样的问题,请解释如何解决。

4

1 回答 1

2

如果您的项目的 Target-Framework 和您引用的程序集框架版本不兼容,则可能会出现此类问题。

因此,我认为,您应该采取以下步骤:

右键单击您的项目 -> 属性 -> 目标框架 -> 确保客户端配置文件上设置它,如果设置了,则选择.NET Framework 44.5(根据引用的程序集目标固件)。

更新:这是设置的快照

目标框架设置

于 2013-07-07T05:11:32.950 回答