Link to home
Start Free TrialLog in
Avatar of GAM3R
GAM3R

asked on

Error on Startup C#

Hello,

I am using C# with skin crafter. When I debug, my form show then it automatically give me an error saying, object not set to refference. The code that the error points to : Application.Run(new Editor());
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Ah the wonders of skincrafter!!

One possibility is that it's having trouble locating the skin file. Are you specifying the skin file at design time, or through code?
Avatar of GAM3R
GAM3R

ASKER

I am specifying the skin through design.
OK, try removing the skin path through the designer and specifying it through code instead. I've used skincrafter in the the past and to be perfectly honest it was a complete pain in the backside!
Avatar of GAM3R

ASKER

Could you give an example?
Avatar of GAM3R

ASKER

This is what my code looks like in the designer.cs

this.skinCrafter1.SkinFile = "vista_style.skf";

The skin file is in the debug folder, near the .exe
Hardcode the path this.skinCrafter1.SkinFile = Application.StartupPah + "\\vista_style.skf";
If i remember correctly (been a while since i used skincrafter) but it has trouble with relative paths.

For starters you want to remove the line:

    this.skinCrafter1.SkinFile = "vista_style.skf";

Form the designer.cs, and then try adding the following to your form constructor:


this.skinCrafter1.SkinFile = Path.Combine(Application.StartupPath, "vista_style.skf");

Open in new window

Avatar of GAM3R

ASKER

Tried both, the form still closes.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
goto your project,    properties,    application   startup object, select a startup object, or you can select a form if you did create a form using create new project wizard.
eq.,(startup objects)
using System;
using System.Drawing;
using System.Windows.Forms;

//On this classes inside namespace,
//we can select at startup object:
//MyPen_C.xMyPen, MyPen_C.zMyPen, MyPen_C.yMyPen 

namespace MyPen_C
{//begin namespace

    // Class Startup yMyPen
    public class yMyPen : System.Windows.Forms.Form
    {
        private System.ComponentModel.Container components = null;
        public yMyPen()
        {
            this.BackColor=Color.Black;
        }
        [STAThread]
        static void Main() 
        {
            Application.Run(new yMyPen());
        }

    }

    // Class Startup xMyPen
    public class xMyPen : System.Windows.Forms.Form
    {
        private System.ComponentModel.Container components = null;
        public xMyPen()
        {
            this.BackColor = Color.Blue;
        }
        [STAThread]
        static void Main()
        {
            Application.Run(new xMyPen());
        }
     }

     // Class Startup zMyPen
     public class zMyPen : System.Windows.Forms.Form
     {
         private System.ComponentModel.Container components = null;
         public zMyPen()
         {
             this.BackColor = Color.Gold;
         }
         [STAThread]
         static void Main()
         {
             Application.Run(new zMyPen());
         }
     }


}//end namespace

Open in new window

And;

>>Application.Run(new Editor());
Maybe your Editor() is not named on your class, or you have not declared a function for it.

Please check according to my sample code.