?
Solved

The type initializer for 'SetPrompts' threw an exception.

Posted on 2011-02-18
6
Medium Priority
?
458 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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