C# App Installer - installed App not opening

183 Views Asked by At

I have created Setup.exe of my Application in Visual Studio 2019, using C#, in my computer. I installed the app in another laptop, by copying the debug folder with setup files, to that laptop. But, after installation, when I clicked the App, it is not opening. I have also tried changing the target dotnet frame work of application in Visual Studio, to match with the laptop. But same effect. This App have references to some external dll files such as a spectrometer related dlls and the tool mathematica's dll. If everything works fine, this App is supposed to collect data from spectrometer and do signal processing and display results at dotnet GUI.

References and dlls used

  1. Ocean Optics Spectrometer related - common64.dll, NETOmniDriver-NET40.dll

  2. Wolfram Mathemtica tool related - ml32i4.dll, Wolfram.NETLink.dll

Please help me in opening my App.

Please find code below.

    namespace JointApp1
{
    public partial class Form1 : Form
    {
        int numberOfSpectrometersFound;
        int spectrometerIndex; // indicates which spectrometer we are using
        OmniDriver.CCoWrapper wrapper;
        private Wolfram.NETLink.MathKernel mathKernel;


        public Form1(string[] args)

        {
             InitializeComponent(args);
            wrapper = new OmniDriver.CCoWrapper();
            spectrometerIndex = -1; 

        }


        private void button5_Click(object sender, EventArgs e)
        {


            numberOfSpectrometersFound = wrapper.openAllSpectrometers();
            if (numberOfSpectrometersFound < 1)
            {
                listBox1.Items.Add("No spectrometers found");
                spectrometerIndex = -1; // set it to an invalid value
                return;
            }
            spectrometerIndex = 0; // arbitrarily choose the first
            // spectrometer for this demo
            listBox1.Items.Add("Selecting spectrometer: " +
           wrapper.getName(spectrometerIndex));
        }

        private void button2_Click(object sender, EventArgs e)
        {


            StreamReader sr = new StreamReader(@"C:\Program Files\Wolfram Research\Mathematicanew\12.0\SystemFiles\Links\NETLink\Examples\Part1\MathKernelApp\JointApps\rd.csv");
            string line;



            if (sr != null) sr.Close();

            //end of graph

            int numberOfPixels; // number of CCD elements/pixels provided by the spectrometer
            double[] spectrum;

            if (spectrometerIndex == -1)
                return; // no available spectrometer
            numberOfPixels = wrapper.getNumberOfPixels(spectrometerIndex);
            // Set some acquisition parameters and then acquire a spectrum

            spectrum = (double[])wrapper.getSpectrum(spectrometerIndex);
            // Display the raw pixel values of this spectrum

            var csv = new StringBuilder();
           string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Imprint KGT\Documents\Visual Studio 2012\editingg for lamda\WindowsFormsApplication1\wn.txt");

            for (int i = 0; i < numberOfPixels; ++i)
            {
                double[] array = new double[1044];
                var first = spectrum[i].ToString();

                var newLine = string.Format("{0},{1}",lines[i], first);
                csv.AppendLine(newLine);
            }
            File.WriteAllText((@"C:\Program Files\Wolfram Research\Mathematicanew\12.0\SystemFiles\qwer.csv"), csv.ToString());


            for (int index = 0; index < numberOfPixels; ++index)
            {
                listBox2.Items.Add("Raman Shift[" + lines[index] + "] = " +
                  spectrum[index]);

                double qw = spectrum[1];         

            }

        }

        private async void Button4_Click(object sender, System.EventArgs e)
        {

            statusStrip1.Text = "calling mathematica.......detecting pesticide presence.....";

            if (mathKernel.IsComputing) { mathKernel.Abort(); }
            else
            {

                try
                {

                   mathKernel.Compute("linkName = \"Bob\"");
                    mathKernel.Compute("remoteLinkObj = LinkOpen[linkName, LinkMode -> Listen]");

                    mathKernel.Compute("Needs[\"JLink`\"]");
                    mathKernel.Compute("$FrontEndLaunchCommand = \"C:\\Program Files\\Wolfram Research\\Mathematicanew\\12.0\\Mathematica.exe\"");
                    mathKernel.Compute("UseFrontEnd[nb = CreateDocument[Null, Visible -> False]; NotebookWrite[nb, Cell[BoxData[{RowBox[{RowBox[{\"linkName\", \"=\", \"\\\"Bob\\\"\"}], \";\"}], \" \", RowBox[{RowBox[{\"feLinkObject\", \"=\", RowBox[{\"LinkOpen\", \"[\", RowBox[{\"linkName\", \",\", RowBox[{\"LinkMode\", \"\\[Rule]\", \"Connect\"}]}], \"]\"}]}], \";\"}], \" \", RowBox[{RowBox[{\"SetAttributes\", \"[\", RowBox[{\"remoteEval\", \",\", \"HoldRest\"}], \"]\"}], \";\"}], \" \", RowBox[{RowBox[{RowBox[{\"remoteEval\", \"[\", RowBox[{\"link_LinkObject\", \",\", \"expr_\"}], \"]\"}], \":=\", RowBox[{\"(\", RowBox[{RowBox[{\"LinkWrite\", \"[\", RowBox[{\"link\", \",\", RowBox[{\"Unevaluated\", \"[\", \"expr\", \"]\"}]}], \"]\"}], \";\", RowBox[{\"LinkRead\", \"[\", \"link\", \"]\"}]}], \")\"}]}], \";\"}]}], \"Input\"]]; SelectionMove[nb, Previous, Cell]; SelectionEvaluate[nb];  NotebookClose[nb]]");

                    mathKernel.Compute("NotebookEvaluate[\"greenchillicode.nb\"]");
                    string a = mathKernel.Result.ToString();
                    //la

                    textBox1.Text = a;

                    mathKernel.Compute("evalLoop[link_LinkObject] := Module[{resultOfEval, exprIn, exprOut, evalMessages}, evalMessages = {}; collectMessages[m_] := AppendTo[evalMessages, m]; Internal`AddHandler[\"Message\", collectMessages]; While[True, evalMessages = {}; exprIn = LinkRead[link, Hold]; resultOfEval = Check[exprOut = ReleaseHold[exprIn], $Failed]; Which[resultOfEval === $Failed, LinkWrite[link, EvalError[\"In\" -> exprIn, \"Out\" -> exprOut, \"Messages\" -> evalMessages]], True, LinkWrite[link, exprOut]]]; Internal`RemoveHandler[\"Message\", collectMessages]; LinkWrite[link, \"Evaluation loop is off\"]]");

                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }

            }
        }
        private void Show(System.Drawing.Image image)
        {
            throw new System.NotImplementedException();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.SuspendLayout();
            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(1378, 744);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "23april";
            this.ResumeLayout(false);

        }
    }
}
0

There are 0 best solutions below