Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

Error running unit tests under MbUnit (Gallio)

Posted: Jan/22/2011   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:251   Vote Up (0)   Vote Down (0)    

I'm trying to do a basic Entity Framework CTP5 code first model that publishes to a database.  The following exception is showing up in both MS Test and MB Unit Test Frameworks:

 

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlServerCe.SqlCeProviderServices' threw an exception. ---> System.Security.VerificationException: Operation could destabilize the runtime.
 at System.Data.SqlServerCe.SqlCeProviderServices..ctor()
 at System.Data.SqlServerCe.SqlCeProviderServices..cctor()
 --- End of inner exception stack trace ---
TypeName: System.Data.SqlServerCe.SqlCeProviderServices
 --- End of inner exception stack trace ---

Server stack trace: 
 at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized)
 at System.Reflection.RtFieldInfo.GetValue(Object obj)
 at System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance_GetValue()
 at System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance()
 at System.Data.SqlServerCe.SqlCeProviderFactory.System.IServiceProvider.GetService(Type serviceType)
 at System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory factory)
 at System.Data.Common.DbProviderServices.GetProviderServices(DbConnection connection)
 at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
 at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection)
 at System.Data.Entity.Internal.LazyInternalContext.CreateModel()
 at System.Lazy`1.CreateValue()

Exception rethrown at [0]: 
 at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized)
 at System.Reflection.RtFieldInfo.GetValue(Object obj)
 at System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance_GetValue()
 at System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance()
 at System.Data.SqlServerCe.SqlCeProviderFactory.System.IServiceProvider.GetService(Type serviceType)
 at System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory factory)
 at System.Data.Common.DbProviderServices.GetProviderServices(DbConnection connection)
 at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
 at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection)
 at System.Data.Entity.Internal.LazyInternalContext.CreateModel()
 at System.Lazy`1.CreateValue()
 at System.Lazy`1.LazyInitValue()
 at System.Lazy`1.get_Value()
 at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
 at System.Data.Entity.Internal.InternalContext.Initialize()
 at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
 at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
 at System.Data.Entity.Internal.Linq.InternalSet`1.get_Provider()
 at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
 at System.Linq.Queryable.First[TSource](IQueryable`1 source)
 at Contoso.Events.Tests.Persistence.Impl.EventsTests.Test() in C:\Projects\Private\Src\Tests\Persistence\Impl\EventsTests.cs:line 25

 

The tests are pretty simple:

 

using System.Collections.Generic;
using System.Data.Entity.Database;
using System.Linq;
using Contoso.Events.Core.Domain;
using Contoso.Events.Core.Persistence;
using MbUnit.Framework;

namespace Contoso.Events.Tests.Persistence.Impl
{
 [TestFixture]
 public class EventsTests
 {
  [FixtureSetUp]
  public static void FixtureSetUp()
  {
   DbDatabase.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
   DbDatabase.SetInitializer<DataContext>(new TestInitializer());
  }

  [Test]
  public void Test()
  {
   var context = new DataContext();

   View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

Running Total In Gridview Footer in ASP.NET C# VB.NET

  
In this example i am going to demonstrate how to display running total in footer row or footer template of GridView in ASP.NET using C# and VB.NET. This method works with paging enabled gridview as well.

open datareader associated with this connection error...

  

I'm trying to figure out how I can get around an error I get when multiple users are accessing different my site. I'm getting an error:

there is already an open datareader associated with this connection which must be closed first

It's not the same query everytime but I recently triggered it on this statement:

Dim adapterSavedState As New SQLDataAdapter("SELECT SavedStateContactView, SavedStatePropertyView, SavedStateTransView, SavedStateCompanyView FROM WebusersProfiles WHERE ContactID = '" & Session("ContactID") & "'", myConnection)
    Dim dtSavedState As New DataTable()
    adapterSavedState.Fill(dtSavedState)
         Dim rowSavedState As DataRow
         For Each rowSavedState In dtSavedState.Rows
             If Request.QueryString("View") = "Contact" Then
                SavedState = rowSavedState("SavedStateContactView").ToString()
            Else If Request.QueryString("View") = "Property" Then
                SavedState = rowSavedState("SavedStatePropertyView").ToString()
            Else If Request.QueryString("View") = "Trans" Then
                SavedState = rowSavedState("SavedStateTransView").ToString()
            Else If Request.QueryString("View") = "Company" Then
                SavedState = rowSavedState("SavedStateCompanyView").ToString()
            End If
         Next rowSavedState


I define my connection in my basepage

    Public Dim MyConnection As SqlConnection
    Public Shared Dim strSite As String = "dev"
        
    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        myConnection = New SqlConnection("server=xxxx;database=xxxxx;User ID=xxxxx;Password=xxxxx;")


Where is my issue and how can I overcome it? This is a .net 1.1 site so MARS I know is not available...


master page error

  

I'm doing an application which has already contains a master page named Master.master. And all related web forms(Webpage) are running well. But I create another master page in same application named Profile.master for some other web form(Webpage). But this time some of the related pages are running a blank page and some are generating an error that is:-

is not allowed here because it does not extend class 'System.Web.UI.Page'.

please help me to rectify this error.



Vishal Purohit


The remote server returned an error: (403) Forbidden.

  

Hi All,

i have a program in vb.net..i use the webrequest to post the data to another page (http://localpost/posReceived.aspx), and use the webResponse to get the back the response from the remote page.

When i run this program, it returned error "The remote server returned an error: (403) Forbidden.". I have no idea on this. Coz my aspx page and posReceived.aspx are placed in the same server and same directory. I supposed it should be worked without any security concerns.

Can anyone help me to solve it. Thanks a lot!

 

 

 


TryUpdateModel throws NullReferenceException in ASP.NET MVC 3 unit test

  

Hi,

Since I upgraded from MVC 2 to MVC 3 RC, using TryUpdateModel causes a NullReferenceException. This problem only occurs when running my action method as part of a unit test. Running it on the actual server works as expected.

Here's a stack trace of the exception:

System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(ControllerContext controllerContext) at System.Web.Mvc.ValueProviderFactoryCollection.<>c_DisplayClassc.b_7(ValueProviderFactory factory) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, String prefix)
... my own code from here on....

In case it matters, my controller has the following signature:

[AcceptVerbs(HttpVerbs.Post)]
public virtual ActionResult Edit(int id, FormCollection collection)
{
}

My guess is that this has to do with the new way DI works in MVC3, but I can't figure out what I'm doing wrong. Perhaps there is something in terms of DI setup that is required in MVC 3, but wasn't required in MVC 2?

Thanks,


Error Creating Control

  

I have created a sample Web App. for creating dynamic controls. It worked fine when I originally created it, however after closing the solution and opening a couple days later this is what happens. Any ideas why?

 

Error Creating Control - ScriptManager1, Oject Reference not set to an instance of an object. 

Error Creating Control - Button1, Oject Reference not set to an instance of an object. 

Error Creating Control - UpdatePanel1, Oject Reference not set to an instance of an object.

 

<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeBehind="Default.aspx.vb" Inherits="WebApplication5._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
 <asp:Button ID="Button1" runat="server" Text="Button" />
    <div style="text-align: center; float: left; width: 336px;">
        <div style="background-color: Aqua; ">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <br />
                <asp:PlaceHolder runat="server" id="myPlaceHolder" />
                <br />
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="MyButton" EventName="Click" />
            </Triggers>

            </asp:UpdatePanel>
       </div>
   </div>

   <div style="text-align: center; float: left; width: 336px;">
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
            <asp:Button ID="btnAddTextBox" runat="server" Text="Add Control" OnClick="btnAddTextBox_Click" Width="200" />
            <br /> <br />
            <asp:Button ID="RemoveTextBoxButton" runat="server" Text="Remove Control" OnClick="RemoveTextBoxButton_Click" Width="200" />
            <br /> <br />
            <asp:Button ID="MyButton" runat="server" Text="My Button" Width="200" />
            <br /> <br />
            <asp:Label runat="server" ID="MyLabel"></asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>
    
</div>

</asp:Content>


 

 

 

 

 


Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element

  

Hello,

I am facing this error 

Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
Parameter name: element

Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.

Parameter name: element

while using Ajaxtoolkit ModelPopupextender with listview, actually I am retriving image from database to the listview in VS 2008. 

Can anyone please help me out of this..


error calling webservice using json

  

 I am trying to populate dropdown using json. It calls the webservice method but its not returning any value and get a error code 500.

My code is as

function changeContextKey()
		{
		var servicePath = "http://localhost:3496/ccm/WsWebService.asmx";
		var methodName = "add";
		var useGet = false ;
		var xValue = $get("cboScenario").value;
//		var yValue = "Scenario:8";
//		var zValue = "";
		alert("xValue");
		var params = {x: xValue};
		var userContext = $get ("result");
		var webServiceProxy = new Sys.Net.WebServiceProxy ();
		webServiceProxy .set_timeout(0);
		request = webServiceProxy ._invoke(servicePath ,methodName ,useGet ,params ,onSuccess, onFailure, userContext );
		}
		function onSuccess(result, userContext, methodName)
		
		{
		userContext .innerHtML = "<b><u>" + result + "</b></u>"
		
		
		}
		
		function onFailure(result, userContext, methodName)
		{
		    alert('Ravi');
		
		}

and in webservice we are just calling a method which populate 
 [WebMethod ]
    public DataSet add(string x)
    {

//code for populating using x
return dataset;


     }


follows

 


Getting error using json

  

 I am trying to call webservice method using JSON.

my code is as follows

<script src="jquery-1.3.2.min.js" type ="text/javascript" ></script>
    <script type ="text/javascript" >
    var pageUrl = '<%=ResolveUrl("~/CS.aspx")%>'
function PopulateContinents() {
    $("#<%=ddlCountries.ClientID%>").attr("disabled", "disabled");
    $("#<%=ddlCities.ClientID%>").attr("disabled", "disabled");
    if ($('#<%=ddlContinents.ClientID%>').val() == "0") {
        $('#<%=ddlCountries.ClientID %>').empty().append('<option selected="selected" value="0">Please select</option>');
        $('#<%=ddlCities.ClientID %>').empty().append('<option selected="selected" value="0">Please select</option>');
    }
    else {
        $('#<%=ddlCountries.ClientID %>').empty().append('<option selected="selected" value="0">Loading...</option>');
        $.ajax({
            type: "POST",
            url: "CS.aspx.cs/PopulateCountries",
            data: "()" ,
            contentType: "application/json; charset=utf-8",
            timeout: 10000,
            dataType: "json",
            success: OnCountriesPopulated,
            error: function(xhr) {if (!error) return;
                                    if (xhr.responseText)
                                    {var err = JSON2.parse(xhr.responseText);
                                                                if (err)error(err);
                                                                else error( { Message: "Unknown server error." })} return;},
            failure: function(response) {
                alert(response.d);
            }
        });
    }
}


 

 

But am getting error like this:

<html>
    <head>
        <title>This type of page is not served.</title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>

    <body bgcolor="white">

            <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

            <h2> <i>This type of page is not served.</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> Description: </b>The type of page you have requested is not served because it has been explicitly forbidden.     Please review the URL below and make sure that it is spelled correctly.
            <br><br>

            <b> Requested URL: </b>/CS.aspx.cs/PopulateCountries<br><br>

            <hr width=100% size=1 color=silver>

            <b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.1882; ASP.NET Version:2.0.50727.1887

            </font>

    </body>
</html>
<!-- 
[HttpException]: Path '/CS.aspx.cs/PopulateCountries' is forbidden.
   at System.Web.HttpForbiddenHandler.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->


 

how to overcome this problem?


Jquery script and IE crashes with the error "Operation Aborted"

  

I have got this script from http://flowplayer.org/tools/demos/overlay/modal-dialog.html and using this overlay to display errors in my application. But when i call this script from code behind I get "Operation Aborted" in IE although it works perfectly in FireFox. Here is the code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="throw.aspx.cs" Inherits="ElectronicBillPayment._throw" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
<!-- include the Tools -->
	<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
	
	<style>
	
	.modal {
		background-color:#fff;
		display:none;
		width:350px;
		padding:15px;
		text-align:left;
		border:2px solid #333;
	
		opacity:0.8;
		-moz-border-radius:6px;
		-webkit-border-radius:6px;
		-moz-box-shadow: 0 0 50px #fff;
		-webkit-box-shadow: 0 0 50px #ccc;
	}
	
	.modal h2 {
		background:url(/img/global/info.png) 0 50% no-repeat;
		margin:0px;
		padding:10px 0 10px 45px;
		border-bottom:1px solid #333;
		font-size:20px;
	}
	</style>
        
  
</head>

<body >
<div class="modal" id="yesno">
	<h2>This is a modal dialog</h2>

	<p>
		You can only interact with elements that are inside this dialog.
		To close it click a button or use the ESC key.
	</p>

	<!-- yes/no buttons -->
	<p>
		<button class="close"> Yes </button>
		<button class="close"> No </button>
	</p>
</div>


<form name="form1" id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" 
    onclick="Button1_Click1" />
</form>

      <script type="text/javascript">
          function triggeroverlay() {
              $("#yesno").overlay({
                  // some mask tweaks suitable for modal dialogs
                  mask: {
                      color: '#a2a2a2',
                      loadSpeed: 200,
                      opacity: 0.9
                  },
                  api: true
              }).load();
          }
        </script>
        
<script type ="text/javascript">
    // What is $(document).ready ? See: http://flowplayer.org/tools/documentation/basics.html#document_ready
    $(document).ready(function() {

        var triggers = $(".modalInput").overlay({

            // some mask tweaks suitable for modal dialogs
            mask: {
                color: '#808000',
                loadSpeed: 200,
                opacity: 0.9
            },

            closeOnClick: false
        });


        var buttons = $("#yesno button").click(function(e) {

            // get user input
            var yes = buttons.index(this) === 0;

            // do something with the answer
            triggers.eq(0).html("You clicked " + (yes ? "yes" : "no"));
        });


        $("#prompt form").submit(function(e) {

            // close the overlay
            triggers.eq(1).overlay().close();

            // get user input
            var input = $("input", this).val();

            // do something with the answer
            triggers.eq(1).html(input);

            // do not submit the form
            return e.preventDefault();
        });

    });
</script>

</body>


</html>


Here is the Code behind where i am calling "triggeroverlay" javascript function to display error to the user.

    public partial class _throw : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          

        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
         ClientScript.RegisterStartupScript(this.GetType(), "throwError", "<script>triggeroverlay();</script>");
        }
    }
}


I was reading this article about the same thing but didn't get it properly. Please help and give example where i am wrong and how to make it work.

http://weblogs.asp.net/infinitiesloop/archive/2006/11/02/Dealing-with-IE-_2600_quot_3B00_Operation-Aborted_2600_quot_3B002E00_-Or_2C00_-how-to-Crash-IE.aspx



 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge