Console Application Calling Datalayer Throws An Exception "The Type Initializer For Threw An Exception."

Aug 17, 2010

I have simple 3 tier web application and have mostly CRUDE functionalities. Recently I required to add new console application to the existing solution in which I call data layer methods for retrieving data from DB but I get an exception "The type initializer for threw an exception."When I debugged I found that the exception is thrown at datalayer on first line of class where I get connectionstring from

web.config, the code is public static readonly string CONNECT_STRING =


Now if I hardcode the connection string value like public static readonly string CONNECT_STRING = "Data Source=XYZ;uid=sa;password=XXX;initial catalog=ABC;"

it works fine.I don't understand what is the issue here as web application works fine with this datalayer.

View 2 Replies

Similar Messages:

Web Forms :: The Type Initializer For 'IBM.WMQ.MQQueueManager' Threw An Exception In MQ Connection?

Feb 25, 2011

I am getting this error while connecting to MQ Manager.I have given correct login credentials and MQ details..but it is throwing the same error.

I have my code written as below...

MQQueueManager lObjMQManager = null;

Hashtable lObjMQProps = new Hashtable(); [code].....

View 1 Replies

Configuration :: The Type Initializer For 'System.Drawing.ToolboxBitmapAttribute' Threw An Exception?

Nov 1, 2010

All of a sudden I started getting this nasty exception all over the place:

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.

Some relevant observations: * The error started occuring a few hours after the last deployment to the live server, not immediately after. So it basically started occuring of its own accord.

* We have recently moved to a new host (a VPS). The error only occurs on that server, not our local server nor at the old host's (which was a shared environment).

* The problem is basically the same as this: [URL]

* I tried reinstalling Ajax extensions, then our website in IIS, then finally the .Net 2 framework. But the error still occurs after all this.

* The error occurs on line 1, which is just the page directive: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Test.WebForm1" %>

I'm finding it difficult to get a decent trace, but here is one that our CMS provided:

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath)
at System.Web.UI.TemplateControl.LoadControl(String virtualPath)
at umbraco.macro.loadUserControl(String fileName, Hashtable attributes, page umbPage)

My own code doesn't use the ToolboxBitmapAttribute, but third party products like Peter Blum's and Telerik's do.

Peter Blum replied with some useful hints:

* The "type initializer" concept probably needs some research, but I'm guessing that is an important clue. A quick web search of "type initializer" finds many situations it occurs for a variety of classes.

* The stack trace suggests that this is happening as ASP.NET is compiling your web form. The error is happening as the ASP.NET parser runs. Again this is external from my code (even creating or "type initializing" the attribute is not something my code does).

View 1 Replies

Web Forms :: The Type Initializer For 'CrystalDecisions.CrystalReports.Engine.ReportDocument' Threw An Exception

Mar 12, 2011

i hve CRRedist2005_x86 installed in my ststem but still it give the below error

{"The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception."}
{"An error has occurred while attempting to load the Crystal Reports runtime.

Either the Crystal Reports registry key permissions are insufficient or the Crystal Reports runtime is not installed correctly.

View 2 Replies

WCF / ASMX :: ServerVersion = 'Conn.ServerVersion' Threw An Exception Of Type 'System.InvalidOperationException'?

Oct 22, 2010

I have a web service which tries to connect to the SQL server.It uses Integrated security = true.I get the Conn.ServerVersion threw an exception of type System.InvalidOperationException as soon as the connection object is instatiated.

View 2 Replies

ADO.NET :: Web Application Throws An Exception Now And Then?

Jan 17, 2011

every now and then my server throws an exceeption. When it first starts to throw an exception the server wont work until I reinstall my web app (copy and Paste). I think this forces a restart of IIS and somethiong gets cleared bercause the app is working again for some hours, sometime less. Now I have created a scheduled task recopying all the web site files every 15 minutes. This restarts the server and the users are able to use the site. Problem is that now the server either start throwing exceptions, or the user is kicked because the server restarts. So you see, this is absolutly not a good solution.I have looked in the Event Viewer on the sever. Her is some examples of the exceptions:


An other exception:


As you can see, the common part of all the exceptions is the Exception message: Unable to cast object of type 'System.Int32' to type 'System.String'. Her is the code of one of the places throwing an exxception:


View 3 Replies

WCF / ASMX :: The Formatter Threw An Exception While Trying To Deserialize The Message

Sep 9, 2010

I have

public interface IBusiness

Add client: [Code]....

But......... the result

Error:The server encountered an error processing the request. The exception message is 'The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'UpdateLanguage'. The token '"' was expected
but found '''.'. See server logs for more details. The exception stack trace is:

at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest

View 1 Replies

Web Custom User Control Threw A Null Reference Exception?

Mar 8, 2010

I' m using a web custom control to upload images and mark them as primary. all the flow is working fine but it fails to mark images as primary in a diffrent category(there are four categories in which we can load a image-,catalog,primary,misc).It works in - category but not in others when I debug it is failing at a condition in grey . If it is not an element of the Datalist item it would not even enter the loop. I' m lost and unable to find the reason.

View 2 Replies

C# - Creating XMLSerializer In .net Throws Exception

Jul 22, 2010

We have an old asp application that instantiates a .NET com visible class. In this class, we do some serialization to store our object in the session.

When I call the following line of code in my test class, it works fine.

var cereal = new XmlSerializer(couponApplicator.GetType());

However, when it gets called in the website and I am debugging, it throws the following error:

{"Cannot execute a program. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /noconfig /fullpaths @"C:\WINDOWS\TEMP\rwot-yx9.cmdline"."} System.SystemException {System.Runtime.InteropServices.ExternalException}

I thought maybe it was permissions related so I tried giving 'EVERYONE' full control to the windows/ folder as well as the windows/temp folder. For reference, I am running this on a Windows XP machine.

View 2 Replies

Using A RenderAction Method Throws An Exception

Dec 29, 2010

i have this (simple) code

<% Html.RenderAction("Version", "Generic"); %>

in my masterpage of my mvc 2 app. This method returns the version of the application.

i also have this code in my controller:

class GenericController : BaseController
public string Version()
string assemblyFile = Assembly.GetCallingAssembly().FullName;
FileInfo fi = new FileInfo(assemblyFile);
string version = fi.LastWriteTime.Year.ToString( ) + fi.LastWriteTime.Month.ToString() + fi.LastWriteTime.Day.ToString();
return version;
catch (Exception e)
return "1.0";

Now i get this error:
Execution of the child request failed. Please examine the InnerException for more information.

and the innerexcpetion is:
{"The controller for path '/Account/LogOn' was not found or does not implement IController."}

What i was thinking is that maybe the code can't execute because the user is not logged on yet, and tries to redirect to the logon method etc.

So the first thing i was thinking is to grant access in the web.config (like i do with the directory that has the css and images in it, it should also be accessable when you're not logged on:

<location path="Content">
<allow users="*" />

but what is the path for this (version) method ?

(or maybe there is another reason for the excpetion.

View 1 Replies

C# - GetRequestStream Throws Timeout Exception Randomly

Feb 12, 2010

After googling for couple of days, I really cannot solve described issue. Hope here will find a solution

I'm using attached code when calling WCF service on the same server. I get Timeout error randomly in call WebReq.GetRequestStream()

When I'm check netstat I see that connection remains open, so probably is there a problem, but I don't know how to solve it

//request inicialization
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
WebReq.Method = "POST";
WebReq.ContentType = "application/json; charset=utf-8";
WebReq.ContentLength = buffer.Length;
WebReq.Proxy = null;
WebReq.KeepAlive = false; //also tried with true
WebReq.AllowWriteStreamBuffering = false; //also tried with true
//this produces an error
using (Stream PostData = WebReq.GetRequestStream())
PostData.Write(buffer, 0, buffer.Length);
//open and read response
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
//return string
return _Answer.ReadToEnd();

Timeout is thrown mostly after some 10 seconds of idle time, but also after five or so requests in the row. Really cannot find a pattern.

What could be wrong with this code? Is there any other (better) way for calling WCF service?

View 4 Replies

MVC :: Custom Authorization Attribute Throws Security Exception

Mar 4, 2010

I have a custom authorization attribute, that basically check if the current user's role is equals to the current area name, and if not, redirect them to the signup view in that requested area. (dummy role provider at this this stage, therefor check it against the user's name at the moment)

It runs fine (IIS) but when I debug it I can see a Security Exception are being thrown by the code

The code:


View 2 Replies

Setting DefaultButton To Button.UniqueID Throws Exception?

Jan 31, 2011

I have several text boxes in an asp:Panel. When the user hits Enter from any of those boxes, I want the form to submit as if they've clicked btnAddTag. (When the cursor is not in those boxes, I have a different default submit button.)

The aspx:

<asp:Panel id="thePanel" runat="server">
<asp:Button ID="btnAddTag" Text="Add Tag" runat="server" />

The vb:

tagPanel.DefaultButton = btnAddTag.UniqueID

The exception:

The DefaultButton of 'tagPanel' must be the ID of a control of type IButtonControl.

The value of btnAddTag.UniqueID is ctl00$phMain$btnAddTag (there's a master page, this section is called phMain).

I've also tried CType(tagPanel.FindControl("btnAddTag"), Button).UniqueID.

View 3 Replies

ADO.NET :: What Is The Purpose Of Adding A Try Catch Condition That Simply Throws The Exception?

Sep 30, 2010

What is the purpose of adding a try catch condition that simply throws the Exception?

Sample Code (Note: The db object is proprietary code that simply uses ADO.Net):


View 6 Replies

Security :: Membership.DeleteUser Throws Exception When Website Is Published

Mar 29, 2010

I am using Membership.DeleteUser("username",true) method to delete the user from DataBase. This works fine in my local machine. When i publish the same code, i am not able to delete the user..... it throws an javascript error saying..... "Login failed for user NT AUTHORITY/NETWORK SERVICE"

View 5 Replies

ADO.NET :: Typed Dataset Throws Null Value Exception For Datetime Field?

Nov 12, 2010

I have a date field in a typed dataset that created from database.

I get an NULL Value exception when I try to enter some null value. I am not able to set the Nullvalue property of the DateTime field in XSD to other value other than Throw Exception.

View 1 Replies

AJAX :: DropDownExtender Inside List View Throws A JavaScript Exception

Apr 23, 2010

The following code listed on the bottom is a dropdown extender contained with a listview insert template. The code works fine however int VS 2008 Debug mode, its throwing the exception:Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.If I click ignore or continue, the taret label is properly populated with the appropriate value. Has anybody encountered this and is

<asp:Label ID="lblTest" style="height:25px;border: solid 1px black" runat="server" Text='<%#Bind("TestCode") %>' Width="90%"></asp:Label>
<asp:DropDownExtender ID="ddExtTestCode" runat="server" TargetControlID="lblTest" DropDownControlID="pnlTestCode"></asp:DropDownExtender>
<asp:Panel ID="pnlTestCode" runat="server" style="display : none; visibility: hidden;">
<asp:LinkButton runat="server" ID="Option1" Text="12345-New York" CommandArgument="12345" OnClick="OnTestCodeSelect"></asp:LinkButton>
<asp:LinkButton runat="server" ID="Option2" Text="45678-New Jersey" CommandArgument="45678" OnClick="OnTestCodeSelect"></asp:LinkButton>

View 1 Replies

State Management :: Cast From Cache To Generic List Throws An Exception

Mar 17, 2011

In application. i cache a Linq to Xml result to a Cache object. when i cast the cache object back to generic list. i get the following exception.

[A]System.Collections.Generic.List`1[CarRentalAddress] cannot be cast to [B]System.Collections.Generic.List`1[CarRentalAddress]. Type A originates from 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'. Type B originates from 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'.

My code looks like this.

if (!Page.IsPostBack) { if (Cache["xml"] == null) { DataSet ds = new DataSet(); ds.ReadXml(HttpContext.Current.Server.MapPath("~/CarRentalAddress.xml")); var grid = (from d in ds.Tables[0].AsEnumerable() orderby d.Field<string>("City") where d.Field<string>("Enabled") == "1" select new CarRentalAddress { City = d.Field<string>("City"), HotelName = d.Field<string>("HotelName"), Address = d.Field<string>("Address"), EmailID1 = d.Field<string>("EmailID1"), EmailID2 = d.Field<string>("EmailID2") }).ToList(); Cache["xml"] = grid; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } else { //Exception is thrown by this line var grid = (List<CarRentalAddress>)Cache["xml"]; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } }

View 4 Replies

Localization :: DateTime Conversion / Date Doesnot Work And Throws Exception?

Jul 30, 2010

I am working on application which is deployed in UK environment. But the machine which I am using has US as dateculture.

I always face issues while running application on my machine as some of the functionality which involves date doesnot work and throws exception.

I tried to google on the datetime conversion issue but it did not help.

Can any one please guide me about the changes to be done so that the application works fine in both US and UK environments?

View 2 Replies

Visual Studio :: Visualizer For LINQ To SQL Throws Exception When Encountering A Timestamp - Rowversion In The Data

Jan 10, 2011

This problem is trivial to duplicate. Do any query on a table which contains a timestamp / rowversion column. Set a breakpoint and examine the resulting query in the Linq to SQL visualizer. Click on Execute which displays the results in a DataGridView. For each row you get "System Argument Exception: Parameter is not valid" when it tries to display the timestamp / rowversion in the grid. What is most annoying is that there is no way to get out of the visualizer without going to Task Manager and killing the Visual Studio process, devenv.exe.

This is definitely a bug. How can you presume to be able to display a database query when you can't display an essential datatype like timestamp / rowversion? Is there any way around this ? I would like to add that in general the CLR is woefully inadequate in the way it handles timestamp / rowversion fields. It would be nice if they could be defined, copied, compared, displayed and serialized in some standardized automatic way.

View 3 Replies

AJAX :: AjaxControlToolkit.ToolKitScriptManager.OnInit() Throws Thread Abort Exception For Every Aspx Page

Nov 3, 2010

AjaxControlToolkit.ToolKitScriptManager.OnInit() throws thread abort exception for every aspx page. I have an 2.0 Ajax application, where I have set the following properties of ToolScriptManager on my pages.

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="true"
EnableScriptLocalization="true" CombineScripts="true" EnablePageMethods="true">

I have this configuration on all the aspx pages in my application. When I checked the .NET CLR exception Performance counter I figured out a large number of exceptions, mainly one exception per page load is occuring. On running windbg I was noticed that

AjaxControlToolkit.ToolKitScriptManager.OnInit() has the following code block which is getting executed. The OutputCombinedScriptFile() returns true. But since I am setting my controls on DesignTime still designmode is set to false for toolkitscriptmanager.

if (!DesignMode && (null != Context) && OutputCombinedScriptFile(Context))
// This was a combined script request that was satisfied; end all processing now

I am not sure if this is a reported bug or even a bug with ajax, but this is causing havoc in my load test results as I have around 3 hundred thousand HTTP requests to be handled per day out of which 80% are aspx page requests resulting in a large number of threadafbortexceptions, thus affecting the performance.

View 3 Replies

Calling A Stored Procedure In Mysql From .NET Throws Error - All Parameters Must Have Their Type Explicitly Set

Jul 15, 2010

I have a page which submits a form in my local system but in my production system when i click my submit button it just freezes with the error in my web developer toolbar saying Error: Sys.WebForms.PageRequestManagerServerErrorException: When calling stored procedures and 'Use Procedure Bodies' is false, all parameters must have their type explicitly set.

View 1 Replies

ToolkitScriptManager Throwing Exception On Calling Page_ClientValidate

Jan 17, 2011

I am using AjaxToolkit 4.0 which suggests to use ToolkitScriptManager in place of ScriptManager. But when I am using ToolkitScriptManager, it throws javascript exception when Page_ClientValidate() in called from javascript. However, this error is not coming when ScriptManager is used. Can anybody tell me how to make Page_ClientValidate() run when using ToolkitScriptManager?

View 1 Replies

Mobiles :: Exception While Calling HttpWebRequest.GetRequestStream()

Mar 17, 2010

From my windows mobile application, i want to connect to the server which resides on my local machine. I want to use HTTPS.

SSL certificates have been implemented and they dont cause any problems.

However, i get an exception at the code line

Stream requestStream = webrequest.GetRequestStream(); ----> webrequest is an object of HttpWebRequest class

The exception message is "Could not establish connection to network." InnerException is null.

View 2 Replies

MVC :: Exception Calling UpdateModel - Value Cannot Be Null Or Empty

Apr 8, 2010

This is probably something silly I'm missing but I'm definitely lost. I'm using .NET 4 RC and VS 2010. This is also my first attempt to use UpdateModel in .NET 4, but every time I call it, I get an exception saying Value cannont be null or empty. I've got a simple ViewModel called LogOnModel:


My view uses the new strongly typed helpers in MVC2 to generate a textbox for username and one for the password. When I look at FormCollection in my controller method, I see values for both coming through.

And last but not least, here's are post controller methods:


why UpdateModel would be throwing this exception?

View 4 Replies

Copyrights 2005-15, All rights reserved