首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Visual Studio中调试输出类型为类库的项目?

如何在Visual Studio中调试输出类型为类库的项目?
EN

Stack Overflow用户
提问于 2011-04-07 00:55:01
回答 4查看 5K关注 0票数 2

我遇到了一个问题,我需要在类库项目的方法中进行调试。但是我收到一个项目错误,说“输出类型为类库的项目不能直接启动”?有没有办法解决这个问题?我的项目是一个用户控件。

代码语言:javascript
运行
复制
 [XRDesigner("Rapattoni.ControlLibrary.CCMLThreePicGalleryTableDesigner," + "Rapattoni.ControlLibrary")]
    public class CCMLThreePicGalleryCtrl : XRTable
    {
        #region Variables
        const int cTableWidth = 825;
        #endregion

        #region Properties
        /// <summary>
        /// Get\Set  bindable variables
        /// </summary>

        [Bindable( true ), DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden )]
        public string SerialPicUrlString
        {
            get
            {
                return String.Empty;
            }
            set
            {
                SetPictures( value );
            }
        }

        private int CellWidth
        {
            get;  
            set;
        }

        private int CellHeight
        {
            get;  
            set;
        }

        private int PicHeight
        {
            get;  
            set;
        }

        private int PicWidth  
        { 
            get; set; 
        }

        private int MaximumPictures
        {
            get; set;
        }
        #endregion Properties


        #region Events

        #endregion

        #region Public/Private Methods

        private void SetPictures( string urlString )
        {
            CellWidth = 275;
            CellHeight = 130;
            PicWidth = 175;
            PicHeight = 120;
            //CommentCellWidth = "150";
            MaximumPictures = 12;

            this.Rows.Clear();
            this.BeginInit();

            string[] urls = urlString.Split( ';' );

            XRPictureBox picBox;
            XRTableRow row;
            CCMLThreePicGalleryCell cell;  //, CommentCell;

            // Prepare first Row
            row = new XRTableRow();
            row.Height = CellHeight; 
            row.CanShrink = false;

            int picTotal = urls.Length;
            /*
            if (picTotal % 3 == 1)  // Don't have one picture in a row
                picTotal--;
             */
            if (picTotal > MaximumPictures)      // Max of 12 pictures shown
                picTotal = MaximumPictures;
            else if (picTotal == 1)
                picTotal = 0;

            // Keep track of which picture
            int picCount = 0;
            // Go through each picture and assign to a cell
            for (int i = 0; i < picTotal; i++)
            {
                if (urls[i] != "")
                {

                    if (picCount % 3 == 0 && picCount > 0 )   // Make a new row after every 3rd picture
                    {
                        // Create a new row for pictures
                        row = new XRTableRow();
                        row.Height = CellHeight;
                        row.CanShrink = false;
                    }


                    cell = new CCMLThreePicGalleryCell();
                    cell.Size = new Size(CellWidth, CellHeight);
                    cell.CanShrink = false;
                    cell.Padding = new PaddingInfo(0, 0, 5, 5);


                    //CommentCell = new ThreePicGalleryCell(); // Don't want Comments

                    string[] url_comment = urls[i].Split('|');
                    picBox = new XRPictureBox();
                    //picBox.HtmlItemCreated += new HtmlEventHandler(picBox_HtmlItemCreated);
                    picBox.Sizing = ImageSizeMode.ZoomImage;
                    url_comment[0] = url_comment[0].Trim();
                    picBox.ImageUrl = url_comment[0];
                    picBox.Size = new Size(PicWidth, PicHeight);

                    cell.Controls.Add(picBox);

                    row.Cells.Add(cell);

                    if (picCount % 3 == 0)   // Add Finalized row
                    {
                        this.Rows.Add(row); // Add current row

                    }
                picCount++;
                } 
            }
            // Fix for odd bug where final picture is out 
            // of alignment if it is 2nd in the last row 
            if (picCount % 3 == 2)
            {
                cell = new CCMLThreePicGalleryCell();
                cell.Size = new Size(CellWidth, CellHeight);
                row.Cells.Add(cell);
                this.Rows.Add(row);
            }
            else if (picCount % 3 == 1)  // When last row has 1 picture
            {
                this.Rows.Remove(row);
            }


            if (urlString.Equals(string.Empty))
                this.Rows.Clear();

            this.EndInit();

        }

        #endregion
    }
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2011-04-07 00:57:40

通常,我会创建一个单独的单元测试类库项目,然后在您最喜欢的单元测试运行器中启动它,并以这种方式进行调试。

或者,开始调试任何实际使用您的类库的应用程序,执行将命中您想要设置的任何断点的功能,然后从那里继续。

票数 4
EN

Stack Overflow用户

发布于 2011-04-07 00:56:18

设置第二个小项目来使用库。

票数 3
EN

Stack Overflow用户

发布于 2011-04-07 00:56:22

将Visual Studio调试器附加到运行二进制文件的进程。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5570105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档