Page 1 of 1

TeeChart.Net v3 in a Windows Service

Posted: Thu Jul 23, 2009 2:29 pm
by 10549439
Hello Steema Team,

I want to use the Teechart.Net v3 in a Windows Service to export Charts in jpeg-files.
I tried to create a new Chart with "new Chart()" in the Service, but it doesn´t work. My Service stoped immediately
without any Exception.
Is it possible to do something like this, and if yes, can I find somewhere an Example or a tutorial?

Greets Centrii

Re: TeeChart.Net v3 in a Windows Service

Posted: Mon Jul 27, 2009 5:42 am
by 10549439
Hello Steema Team,

I´m still working on this Issue and I found a Post in this forum that it should work.
But it doesnt´t work for me.
I hope that you can give some advise to solve my problem.

Greets Centrii

Re: TeeChart.Net v3 in a Windows Service

Posted: Mon Jul 27, 2009 8:00 am
by narcis
Hi Centrii,

Have you tried creating a Steema.TeeChart.TChart instead of a Steema.TeeChart.Chart?

Thanks in advance.

Re: TeeChart.Net v3 in a Windows Service

Posted: Mon Jul 27, 2009 8:28 am
by 10549439
Hello Narcís,

thank you for your answer.
I tried now creating with Steema.TeeChart.TChart, but still have the same Problem.
My Service stop immediately without any Exception after I call

Code: Select all

 Steema.TeeChart.TChart report = new Steema.TeeChart.TChart();
Greets Centrii

Re: TeeChart.Net v3 in a Windows Service

Posted: Mon Jul 27, 2009 11:49 am
by narcis
Hi Centrii,

Could you please try assigning the Administrator account to the service to see if it makes a difference.

Thanks in advance.

Re: TeeChart.Net v3 in a Windows Service

Posted: Tue Jul 28, 2009 5:34 am
by 10549439
Hi Narcís,

I already tried the Administrator Account, but this has no effect.

Greets Centrii

Re: TeeChart.Net v3 in a Windows Service

Posted: Tue Jul 28, 2009 6:39 am
by 10549439
Hi Narcís,

I tried it also in a Windows Forms application and it works great with the same Function like in my Windows Service.

Code: Select all

            try
            {
                String Filename = @"C:\test_" + DateTime.Now.ToString("dd_hhmmss") + ".jpg";

                Steema.TeeChart.TChart report = new TChart();

                report.Chart.Height = 768;
                report.Chart.Width = 1024;
                Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(report.Chart);

                line.Active = true;
                line.FillSampleValues(50);
                line.Title = "Test";

                report.Legend.Visible = true;

                report.Export.Image.JPEG.Save(Filename);
            }
            catch (Exception ex)
            {

            }
I´m using the same TeeChart.dll

I hope you can give me some usefull advise.

Greets Centrii

Re: TeeChart.Net v3 in a Windows Service

Posted: Tue Jul 28, 2009 10:15 am
by narcis
Hello Centrii,

Thanks for the information.

In that case it may be a licensing issue. Can you please download the evaluation version and install it in another machine so that we can check if it's a licensing problem? Evaluation version has no license control but expires after 40 days of its installation. If evaluation version works and registered version doesn't we will try to provide a solution to the problem.

Thanks in advance.

Re: TeeChart.Net v3 in a Windows Service

Posted: Tue Jul 28, 2009 12:54 pm
by 10549439
Hello Narcís,

I dont have a second machine where I can install VS and the Eval version.
But I uninstalled the TeeChart v3 completely from my machine and installed the new v2009 evaluation version (4.0.2009.21357)
and I still get the same error.
Meanwhile I figured out that I probably get a System.IO.FileNotFoundException as soon I want to create a new TChart.
Rigth now I have no idea what I have to do next to solve the Problem.
I hope you can give me some more advice.

Thank you in advance

Greets Centrii

Re: TeeChart.Net v3 in a Windows Service

Posted: Tue Jul 28, 2009 2:19 pm
by narcis
Hi Centrii,

In that case it could be that your Windows Service can't find TeeChart.dll. You could check it using File.Exists, for example:

Code: Select all

			if (System.IO.File.Exists("TeeChart.dll"))
			{
				Steema.TeeChart.TChart tChart1 = new Steema.TeeChart.TChart(); 
			}
You could also try loading TeeChart.dll dynamically, for example:

Code: Select all

		private CompilerParameters compilerParams;

		private void InitializeCompilerParameters()
		{
			//add compiler parameters
			compilerParams = new CompilerParameters();
			compilerParams.CompilerOptions = "/target:library /optimize";
			compilerParams.GenerateExecutable = false;
			compilerParams.GenerateInMemory = true;
			compilerParams.IncludeDebugInformation = false;
			compilerParams.ReferencedAssemblies.Add("mscorlib.dll");
			compilerParams.ReferencedAssemblies.Add("System.dll");
			compilerParams.ReferencedAssemblies.Add("System.Drawing.dll");
			compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
			compilerParams.ReferencedAssemblies.Add(Application.StartupPath + "\\TeeChart.dll");
		}
Hope this helps!

Re: TeeChart.Net v3 in a Windows Service

Posted: Tue Jul 28, 2009 2:53 pm
by 10549439
Hello Narcís,

Thank you very much. :D
Loading TeeChart.dll dynamically did help.
I cannot explain why my Service don´t find the dll, because it is in the same folder like the Service.
I will try to figure it out, but for now I´m happy with this solution.

Thanks again

Greets Centrii

Re: TeeChart.Net v3 in a Windows Service

Posted: Tue Jul 28, 2009 3:11 pm
by narcis
Hi Centrii,

You're very welcome! I'm glad to hear that helped.
I cannot explain why my Service don´t find the dll, because it is in the same folder like the Service.
I will try to figure it out, but for now I´m happy with this solution.
You could check TeeChart's AssemblyFolders settings as described here or you may need to register TeeChart.dll in the GAC if it isn't. Here you'll find and example on how to register TeeChart.dll to the GAC.