Solved

The type initializer for 'SetPrompts' threw an exception.

Posted on 2011-02-18
6
451 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now