Click here to Skip to main content
15,889,398 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is my code for WindowsClassLibrary:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Drawing.Drawing2D;
using System.Drawing.Design;
using System.Threading;
using System.Drawing.Imaging;
using System.Configuration;
using System.Xml;
using InfoSoftGlobal;

namespace GraphCapture
{
    public partial class Form1 : UserControl 
    {
        public Form1()
        {
            InitializeComponent();
        }
        public string filePath ;
        protected void SwfToImage()
        {
          

            Screen screen = Screen.PrimaryScreen;
           
         
            Rectangle bounds = new Rectangle(axShockwaveFlash1.Location, axShockwaveFlash1.Size);
            using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
            {
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
                }

                bitmap.Save(filePath + "/FCF_Column3D.Jpeg", ImageFormat.Jpeg);
            }

        }

        public void GetGraph(XmlDocument strXml,string fPath)
        {
            string appPath = "file:///" + Application.StartupPath + "\\FusionCharts\\FCF_Column3D.swf";
            appPath = appPath.Replace("\\", "/");
            filePath = fPath;
            FileStream fs = new FileStream(filePath + "\\FCF_Column3D.Xml", FileMode.Open, FileAccess.Read);
            strXml.Load(fs);
            //string strChart = filePath + @"?dataXML=" + strXml.InnerXml.Replace("\"","'")  + "®isterwithjs=1";
            //string ChartXML = appPath + strChart;
            string ChartXML = appPath + @"?dataXML=" + strXml.InnerXml.Replace("\"", "'").Replace("#", "") + "®isterwithjs=1";


        
            string XML = ChartXML;

            axShockwaveFlash1.Movie = XML;
            timer1.Start(); 


        }
        
        private void Form1_Load(object sender, EventArgs e)
        {
          

        }

       
        private void timer1_Tick(object sender, EventArgs e)
        {
            SwfToImage();
            timer1.Stop();
           
        }
    }
}


Here I am getting error d27cdb6e-ae6d-11cf-96b8-444553540000' cannot be instantiated because the current thread is not in a single-threaded apartment
while calling dll from web application.
Posted
Updated 8-Jun-15 22:54pm
v2
Comments

Windows dlls are not suitable for use in a web app. Just put the code in a class in your website and call it from there after making the relevant amendments. Also note that this isn't going to read anything from the client or save anything to the client, the file will have to exist on the server after being already uploaded, and the resulting image will be saved on the server also.
 
Share this answer
 
You cannot use Windows forms in a web environment: they are totally different. For one thing, C# code is Server based - which means it always executes on the Server, not the Client. So even if you could get it to run (which you can't. IIS isn't set up for that) whatever was displayed would be visible to the Web host admin, and not to the client half a world away.

You cannot just find some code and assume it will work under all environments, any more than you can find a car, and assume it will work as a submarine!

Look at the code, work out how it works, and extract the logic into a web-based solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900