Link to home
Start Free TrialLog in
Avatar of moosetracker
moosetracker

asked on

The type initializer for 'SetPrompts' threw an exception.

This is thrown when entering a custom library, code runs fine until it is deployed to the iis intranet.. I am unsure if the msi for the project bundles in the dll to the library or not, but just in case I know the iis area can follow the directory path to get the dll for the library if needed..

The only thing I can think of that might be flaking it out is I am trying to use LINQ.. Perhaps I need to do something special to utilize LINQ on the IIS??

The code calling the library is ..

        private Crystal.ScrFields.SetPrompts ULPrompts;
:
:
                ULPrompts.ClearList();

                ULPrompts.CRSPOnly(txtRunDate.Text, "prmPressRunDate", "@ProcessDate");
                ULPrompts.CRSPOnly(ddlSubKey.SelectedValue, "prmSubKey", "@SubKey");

Significant parts of the Class code from the library are in the code window..
using System.Diagnostics;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Linq;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

using System.Configuration;

namespace ul_ClassLibrary
{

    public class Crystal
    {
         public class ScrFields
        {

            //Private Shared strWhichRpt As String
            private static string strBindRefresh;
            private static string strReportName;
            private static string strReportNameSaved;
            private static string strReportTitle;
            //               private static ControlFieldList[] controls;
            private static List<ControlFieldList> controls = new List<ControlFieldList>();
            private static ControlFieldList tempList;
            private static string strWhichRpt;
            private static string strWhichDB;
            private static string strWhichMenu;
            //private static string strSpecialScreen;


            private static bool blnSPPrerun;
            private static bool blnSPOutputErrParm;
            private static string strSPName;

            private static string strPDForDisplay;
            private static string strAutoSPPrompts;
            private static string strAutoCRPrompts;
            private static int dateRangeInMonths;
            private static int dateRangeInDays;
            private static string strRptPath;


            public ScrFields()
            {
            }


            public int Initialize()
            {
                int returnValue;
                returnValue = 1;
                strBindRefresh = "N";
                strReportName = " ";
                strReportNameSaved = "";
                strReportTitle = " ";
                //strWhichRpt = "";   'This clears when don't want it to.
                //strSpecialScreen = "";

                blnSPPrerun = false;
                blnSPOutputErrParm = true;
                strSPName = " ";

                strAutoCRPrompts = "";
                strAutoSPPrompts = "";
                dateRangeInDays = 0;
                dateRangeInMonths = 0;

                returnValue = 0;
                strRptPath = " ";

                return returnValue;
            }
:
:
:

                public void ClearList()
                {
                    controls.Clear();
                }
:
:
:
            public List<ControlFieldList> ControlList
            {
                get { return controls; }
                set { controls = value; }
            }
:
:
:

                 public void CRSPOnly(string crName, string spName)
                {
                    try
                    {
                        tempList = new ControlFieldList("", "", "", spName, crName, true);
                        controls.Add(tempList);
                    }
                    catch (Exception)
                    {

                        throw;
                    }
                }
:
:
:
       private ControlFieldList LINQForControlName(string _controlName)
            {
                int intko = 0;
                ControlFieldList saveit = new ControlFieldList("", "", "", "", "", false);
                try
                {
                    var pullQuery =
                           from c in controls
                           where c.ControlName == _controlName
                           select new
                           {
                               c.ParmValue,
                               c.ControlName,
                               c.ControlText,
                               c.SPParmName,
                               c.CRParmName,
                               c.IsLocked
                           };

                    foreach (var item in pullQuery)
                    {
                        intko = intko + 1;
                        saveit = new ControlFieldList(item.ParmValue,
                         item.ControlName, item.ControlText,
                         item.SPParmName, item.CRParmName, item.IsLocked);
                    }
                    if (intko != 1)
                        LINQError(intko); 
                }
                catch (Exception)
                {
                    
                    throw;
                }
                return saveit;
            }

            private void LINQError(int intko)
            {
                try
                {
                    if (intko == 0)
                        throw new Exception("No Match found for the Name you passed");
                    if (intko > 1)
                        throw new Exception("More then one item named the same as what you passed");
                }
                catch (Exception)
                {
                    throw;
                }
            }
:
:
:
        public class ControlFieldList
        {
            private string controlName;
            private string controlText;
            private object parmValue;
            private string spParmName;
            private string crParmName;
            private bool isLocked;
            public ControlFieldList(object _parmValue, string _controlName, string _controlText,
                        string _spParmName, string _crParmName, bool _isLocked)
            {
                this.controlName = _controlName;
                this.controlText = _controlText;
                this.parmValue = _parmValue;
                this.spParmName = _spParmName;
                this.crParmName = _crParmName;
                this.isLocked = _isLocked;
            }

            public string ControlName
            {
                get { return controlName; }
                set { controlName = value; }
            }
            public string ControlText
            {
                get { return controlText; }
                set { controlText = value; }
            }
            public object ParmValue
            {
                get { return parmValue; }
                set { parmValue = value; }
            }

            public string SPParmName
            {
                get { return spParmName; }
                set { spParmName = value; }
            }
 
            public string CRParmName
            {
                get { return crParmName; }
                set { crParmName = value; }
            }
            public bool IsLocked
            {
                get { return isLocked; }
                set { isLocked = value; }
            }

        }
:

Open in new window

Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What is the inner exception?  If you dig down to the lowest inner exception, that should give you the detail that you need to determine the cause for the problem.  The problem is usually found in the constructor, or module-level object initialization...
Avatar of moosetracker
moosetracker

ASKER

How do I get to the "inner exception"  I just get the error I described displayed on the web page.. passed there by the "Try" statement..

Will I get a more detailed error if I remove the "Try"?  When I tried moving the calls up to before the web page displayed to make sure it was the library calls and not something with crystal, (which was in the same call).. I seemed to get a error page that just stated I got it because I didn't have custom page errors..  When I looked up custom page errors, it seems based on the error number I still only got a choice of 5 errors by display one of 5 pages with my own message on each page..

I really didn't see a way to break down the error to a detail state once it was running in the IIS.. And no option to run it in debug mode..
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America 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
Thank you for your help!
What was the inner exception?
Actually I put the code in, and the error magically disappeared.. Don't know if it was adding the code, or just quirky glitches in the system..

The code is installed for next time though..

So thanks..