Solved

The type initializer for 'SetPrompts' threw an exception.

Posted on 2011-02-18
6
452 Views
Last Modified: 2012-06-21
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

0
Comment
Question by:moosetracker
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34943048
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...
0
 
LVL 1

Author Comment

by:moosetracker
ID: 34943391
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..
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 34943567
You will need to find a way to to log your exceptions.  The usual place is to put a global exception handler in the Global.asax, and then write the stack trace to the event log.

Global Exception Handling with ASP.NET
http://www.developer.com/net/asp/article.php/961301/Global-Exception-Handling-with-ASPNET.htm
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Author Closing Comment

by:moosetracker
ID: 34961537
Thank you for your help!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34962080
What was the inner exception?
0
 
LVL 1

Author Comment

by:moosetracker
ID: 34962650
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..
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question