Solved

The type initializer for 'SetPrompts' threw an exception.

Posted on 2011-02-18
6
449 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

9 Experts available now in Live!

Get 1:1 Help Now