Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

malpass

VS.NET VERY wierd error

This topic is 5480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, I posted a while back that VS.NET kept crashing programs for NO reason, I went throught every procedure to make sure it couldn''t be anything but VS.NET making the error, up to the point of having a freshly formatted pc with nothing but VS.NET on, not connected to the internet or anything. I''v found out that the programs that crash dont have a link, but the errors do, the error keeps saying "Error in Font.Initialize()". One of my programs just prints a letter outline at 8inches:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Drawing.Printing;
using System.Drawing.Drawing2D;

namespace Temp
{
	public class Form1 : Form
	{
		#region General
		private System.ComponentModel.Container components = null;
		public Form1(){InitializeComponent();}
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#region Windows Form Designer generated code
		/// <summary>

		/// Required method for Designer support - do not modify

		/// the contents of this method with the code editor.

		/// </summary>

		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.Size = new System.Drawing.Size(300,300);
			this.Text = "Form1";
		}
		#endregion
		[STAThread]
		static void Main(){Application.Run(new Form1());}
		#endregion General

		protected override void OnLoad(EventArgs ea)
		{
			Menu = new MainMenu();
			Menu.MenuItems.Add("Print!",new EventHandler(OnPrintClick));
		}

		protected void OnPrintClick(object s, EventArgs pea)
		{
			PrintDocument pd = new PrintDocument();
			pd.PrintPage += new PrintPageEventHandler(OnPrint);
			pd.Print();
		}

		protected void OnPrint(object s, PrintPageEventArgs pea)
		{
			Graphics g = pea.Graphics;

			g.PageUnit = GraphicsUnit.Inch;

			GraphicsPath gp = new GraphicsPath();

			Font = new Font("Georgia",100);

			gp.AddString("O",Font.FontFamily,(int)FontStyle.Bold,8,new Point(0,0),new StringFormat());

			g.DrawPath(new Pen(Color.Black,0),gp);
		}
	}
}
and another simple 1 just writes some text centered:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Text_Centering
{
	public class Form1 : System.Windows.Forms.Form
	{
		#region General
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			InitializeComponent();
		}
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion
		#region Windows Form Designer generated code
		/// <summary>

		/// Required method for Designer support - do not modify

		/// the contents of this method with the code editor.

		/// </summary>

		private void InitializeComponent()
		{
			// 

			// Form1

			// 

			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 273);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);

		}
		#endregion

		static void Main() 
		{
			Application.Run(new Form1());
		}

		protected override void OnResize(EventArgs ea){Invalidate();}
		protected override void OnPaint(PaintEventArgs pea)
		{
			Graphics g = pea.Graphics;
			g.Clear(Color.AliceBlue);
			string str = "Hello World";
			SizeF textSize = g.MeasureString(str, Font);

			g.DrawString(str, Font, Brushes.Black, (ClientRectangle.Width-textSize.Width)/2, (ClientRectangle.Height-textSize.Height)/2);
		}
		private void Form1_Load(object sender, System.EventArgs e)
		{
		
		}
	}
}
The thing I also found was that if I, for the print program, just click print, it generates the error, it I click continue then click the print button a second time I don''t get the error. The wierd thing is that when I first install VS.NET before I get this error they work fine, so it can''t be the code being wrong can it? Then also right after I started getting this error I keep getting a WMI crash error: "The instruction at ''0x77e6cd71'' referenced memory at ''0x00000000''. The memory could not be ''read''". Isn''t WI just a standard windows program to do with networking for something? Also could these to problems be linked at all? If anyone can help with any of these problems I would be greatful. O......K!?!?!?, just after I finished typing this I checked it again and all is fine, the WMI seems to have stopped crashing and the program is working fine again !!!. Could this be like a hardware PC problem maybe?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Don''t have time to inspect your code for you but... You don''t by any chance have an HP Lasterjet 4000 or another HP printer installed? I''ve had issues on my work network with multiple recent HP drivers causing this kind of problem? We''ve had issues with the LJ4000, 4100, 4m, 5m, 5502 drivers and one or two others. I think HP have some work experience kid coding their drivers for them or something.

Share this post


Link to post
Share on other sites
Funny you should mention that, the error occured just as I had installed the HP Apollo inkjet 2100 to test my app. But I'v had the VS.NET error happening without having the printer installed i'm almost positive. It may be a cause to it though, its really weird how, like I say, once i'd finished tying the message I checked it again and it was all of a sudden fine, I hope it stays that way

[edited by - malpass on June 19, 2003 8:55:05 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!