-1

環境: c#.net VS 2010

ソリューションには、次の 2 つのプロジェクトがあります。

  • 私が追加したいくつかのテスト済みメソッドを含む dll。

  • テスト プロジェクト

テスト プロジェクトの唯一のものは、次のコードを含むフォームです: (読みやすくするために名前は変更されています)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using DLL_PROJECT; //Yes I remembered to include the dll project

namespace DLL_PROJECT_Test
{
public partial class frmTest : Form
{
    private Class_1 myClass_1; //this comes from the dll - no errors here
    private Class_2 myClass_2 = new Class_2(); // no errors here either

    public frmTest()
    {
        InitializeComponent();
        //TransparencyKey = BackColor;
        this.SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, true);
        this.BackColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black);
        myDebouncer = new Debouncer(this);
        this.SetDragging(true); //THIS EXTENSION COMES FROM THE DLL AND WORKS FINE
        this.RoundCorners(40, 80); //AS DOES THIS ONE
        myClass_2 = new Class_2();
        myClass_2.HoldStartEvent += new Class_2EventHandler(myClass_2_HoldStartEvent);
        myClass_2.DragStartEvent += new Class_2EventHandler(myClass_2_DragStartEvent);
    }

    private void myClass_2_DragStartEvent(Class_2 sender)
    {
        myClass_2("DragStart") += 1; //THE ONLY ERROR IS HERE AS FOLLOWS
//ERROR: "The name 'myClass_2' does not exist in the current context"
//     - Yes, the DLL is included
//     - Yes, the project is .Net 4 (not client profile)
//     - Yes xxx WRONG xxx, this exact syntax has been tested before on an instance of
//       this class, it's just a default parameter.
// xxx should be [] instead of () for the indexer in c#.  #VB_Fails
    }

    void myClass_2_HoldStartEvent(Class_2 sender)
    {
        this.Close();
    }
}
}
4

1 に答える 1